Les*_*ial 4 solr full-text-search ruby-on-rails sunspot-rails
在太阳黑子solr中,我们可以通过facet对具有相似属性的记录进行分组.但是有可能从两个属性做一个facet过滤器吗?
我尝试在我的搜索中执行此操作:
facet_search = User.search do
facet :attribute1, :attribute2
end
facet_search.facet(:attribute1, :attribute2)
Run Code Online (Sandbox Code Playgroud)
有了这个,我一直得到nil值,我确信在attribute1和attribute2上有类似值的记录.
假设有两条记录在attribute1处的值为"orange".并且这两个记录在attribute2处的值为"eagles".
在太阳黑子中是否有一个功能可以用来根据两列分组记录,我该怎么做?
我在这里先向您的帮助表示感谢.
你真的想要过滤吗?Faceting只返回该属性的前n个唯一值.因此,如果attribute1包含颜色,您将返回橙色,红色,蓝色等.任何与您当前搜索匹配的独特颜色.单独进行分区不会过滤搜索结果.
根据您的问题,我认为您希望过滤attribute1中的某个值和attribute2中的某个值.为此,您的搜索看起来更像是:
facet_search = User.search do
# Filter my results...
with(:attribute1).equal_to("orange")
with(:attribute2).equal_to("eagle")
end
Run Code Online (Sandbox Code Playgroud)
facet :attribute1
如果您想获取要在UI或其他内容中显示的attribute1的唯一值,您仍可以包含.请注意,声明:attribute1作为构面不会对搜索强加过滤器.
归档时间: |
|
查看次数: |
1873 次 |
最近记录: |