假设我有一个名为 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:
这篇关于如何在 solr 结果中获得构面范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!