PHP 中用于 PostgreSQL 的布尔搜索处理
这似乎是一个显而易见的问题,但目前似乎没有任何答案。
我希望尝试处理搜索查询,以使用 PHP 进行正确格式的 postgresql 全文搜索。我是正则表达式的新手,我似乎不知道从哪里开始。
我希望按照 Something AND ("Some Phrase" OR Some Other Phrase)
的方式进行查询,并将其转换为 'Something' & (('Some' & 'Phrase')|('Some' & 'Other' & 'Phrase'))
您也许可以向我指出一个可以执行此操作的库,但我不能似乎找到了一个,尽管我认为这是一个常见问题。感谢您的帮助!
This seems like an obvious question but there does not appear to be an answer anywhere at the moment.
I am looking to attempt to process a search query to go into a postgresql full-text search with correct formatting using PHP. I am a bit of newbie to regular expressions and I just can't seem to work out where to start.
I am looking to take a query along the lines ofSomething AND ("Some Phrase" OR Some Other Phrase)
and convert it to 'Something' & (('Some' & 'Phrase')|('Some' & 'Other' & 'Phrase'))
You may be able to point me to a library that does this, I can't seem to find one although I imagine it is a common problem. Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此代码将解析给定的示例并返回请求的输出。请注意,它有点脆弱:您可能需要验证表达式的格式以确保它与您发布的格式相似。
您可以像这样测试您的输入:
This code will parse the example as given and return the requested output. Be aware that it is somewhat brittle: You may need to validate the format of the expression to ensure that it is similar to the format you posted.
You can test your inputs like this: