How to get facet ranges in solr results?(如何在 solr 结果中获得构面范围?)
问题描述
假设我有一个名为 price 的字段用于 Solr 中的文档,并且我对该字段进行了分面.我想将方面作为值范围(例如:0-100、100-500、500-1000 等).怎么做?
Assume that I have a field called price for the documents in Solr and I have that field faceted. I want to get the facets as ranges of values (eg: 0-100, 100-500, 500-1000, etc). How to do it?
我可以预先指定范围,但我也想知道是否可以根据文档中的值自动计算范围(比如 5 个值)?
I can specify the ranges beforehand, but I also want to know whether it is possible to calculate the ranges (say for 5 values) automatically based on the values in the documents?
推荐答案
要回答您的第一个问题,您可以通过使用通用构面查询支持来获取构面范围.这里是一个例子:
To answer your first question, you can get facet ranges by using the the generic facet query support. Here's an example:
http://localhost:8983/solr/select?q=video&rows=0&facet=true&facet.query=price:[*+TO+500]&facet.query=price:[500+TO+*]
至于您的第二个问题(自动建议构面范围),尚未实施.有人认为这种查询最好在您的应用程序上实现,而不是让 Solr猜测"最佳构面范围.
As for your second question (automatically suggesting facet ranges), that's not yet implemented. Some argue that this kind of querying would be best implemented on your application rather that letting Solr "guess" the best facet ranges.
以下是关于该主题的一些讨论:
Here are some discussions on the topic:
- (已归档)https://web.archive.org/web/20100416235126/http://old.nabble.com/Re:-faceted-browsing-p3753053.html
- (已归档)https://web.archive.org/web/20090430160232/http://www.nabble.com/Re:-Sorting-p6803791.html
- (存档)https://web.archive.org/web/20090504020754/http://www.nabble.com/Dynamically-calculated-range-facet-td11314725.html
这篇关于如何在 solr 结果中获得构面范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 solr 结果中获得构面范围?
基础教程推荐
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 降序排序:Java Map 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01