我有一个使用 solr 的 Ruby on Rails 应用程序。我为此使用了太阳黑子 gem 。我也在生产环境中使用 websolr。
我知道我们可以使用 sunspot solr 进行全文搜索。但我也希望能够排除任何具有给定词的命中(以及最终结果)。
示例类:
class Article
searchable do
text :title
text :content
end
end
现在,我想搜索内容中包含“Obama” 的文章,但也想排除那些也有单词“Lady”的文章嘎嘎”。我知道我可以对返回的结果数组应用拒绝 block ,但我想在 Solr 级别处理这种情况。
希望我清楚地说明了我的问题。
预先感谢您的帮助。
最佳答案
来自 https://github.com/sunspot/sunspot/wiki/Fulltext-search
A small subset of the normal boolean query syntax is parsed: in particular, well-matched quotation marks can be used to demarcate phrases, and the + and - operators can be used to require or exclude words respectively
这就是你要找的吗?
关于ruby-on-rails - sunspot-solr:如何排除包含任何给定单词的搜索结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13754456/