Solr 复杂的分面
我在刻面方面遇到问题。想象一下这种情况。产品可以属于多个类别。这是分面的常见行为:
类别
- Android (25)
- iPhone (55)
- other (25)
现在,当我选择“Android”时,我会使用“fq”=> 进行新查询。 “category:Android”,我将得到:
Category
- Android
- iPhone (15)
- other (2)
但这意味着有 15 个产品,属于“Android”和“iPhone”类别。我想要这样的东西:(“Android”OR“iPhone”)
类别
- Android
- iPhone(+5)
- 其他(+1)
意味着我将通过选择“Android(25)”获得25个结果,通过选择“iPhone( +5)”,所以最后我会得到 30 个搜索结果。
有谁知道这是否可以通过 SOLR 的分面实现?或者也许有多个查询并手动计算?
感谢您的建议!
I have problems with faceting. Imagine this situation. Product can be in more than one category. This is common behavior for faceting:
Category
- Android (25)
- iPhone (55)
- other (25)
Now when I select "Android", I make new query with "fq" => "category:Android", I will get:
Category
- Android
- iPhone (15)
- other (2)
But this means that there is 15 products, that are in categories "Android" AND "iPhone". I would like something like this: ("Android" OR "iPhone")
Category
- Android
- iPhone (+5)
- other (+1)
Meaning I will get 25 results by selecting "Android (25)" and another 5 by selecting "iPhone (+5)", so finally I will get 30 search results..
Does anyone know if this is possible with SOLR's faceting? Or perhaps with more than one query and calculate it manually?
Thanks for advice!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用否定选项进行新查询,例如
"fq" =>; “-category:Android”
- 然后您应该获得您正在寻找的方面计数。Try a new query with the negative of the selections, like
"fq" => "-category:Android"
- you should then get the facet counts you are looking for.根据您需要的所有排列,您可能需要查看查询方面 使您能够获取任意查询的计数。例如,您可以执行
facet.query=category:("Android" OR "iPhone")
并获取按category:("Android" OR "iPhone")< 键入的计数结果/代码>。而且,您可以对任意数量的您想要计数的查询执行此操作。因此,就您的情况而言,您可能可以通过直接字段方面和查询方面的某种组合来获得最终解决方案。
编辑:重新阅读您的问题,您可能还需要研究标记并排除额外
fq
的部分,具体取决于您如何允许用户“选择”选项。 (文档中的示例与您的原始设置相当接近,尽管我不确定最终行为是否完全如您所愿)。Depending on all the permutations you need, you probably want to look into query facets that enable you to get counts for arbitrary queries. For instance, you can do
facet.query=category:("Android" OR "iPhone")
and get a count results keyed oncategory:("Android" OR "iPhone")
. And, you can do this for any number of queries you want counts for. So, in your case, you can probably get to a final solution with some combination of straight field facets and query facets.Edit: Re-reading you question, you may also want to look into tagging and excluding parts of an extra
fq
, depending on how you are allowing your users to "select into" the choices. (The example in the docs is fairly close to your original setup, although I'm not sure the end behavior is exactly as you desire).