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 结果中获得构面范围?
基础教程推荐
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
