如何使用两个搜索文本参数进行 Postgres 搜索,pg-search + 搜索过滤器 1 + 搜索过滤器 2。
如何在 pg_Search 中搜索输出我想要联合“过滤器 1”&&“过滤器 1”
@output = PgSearch.multisearch("filter 1") + PgSearch.multisearch("filter 2")
最佳答案
我是 pg_search 的作者和维护者。
在 PostgreSQL 全文搜索中,搜索词默认由 AND 连接。因此,您可以简单地这样做:
@output = PgSearch.multisearch("filter 1 filter 2")
假设您在字符串变量中有查询词,它看起来类似于以下之一:
@output = PgSearch.multisearch("#{query1} #{query2}") # if query1 and query2 are strings
@output = PgSearch.multisearch(queries.join(" ")) # if queries is an array of strings
通过 OR 加入要复杂得多。我还没有一个简单的解决方案,尽管它应该是可能的。
关于ruby-on-rails - 如何使用两个搜索文本参数进行 postgres 搜索,Search FILter text 1 && search filter text 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9991421/