如何在 solr 结果中获得构面范围?

How to get facet ranges in solr results?(如何在 solr 结果中获得构面范围?)

本文介绍了如何在 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 结果中获得构面范围?

基础教程推荐