Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get facet ranges in solr results?

Tags:

java

solr

lucene

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?

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?

like image 950
cnu Avatar asked Aug 29 '08 04:08

cnu


People also ask

What is faceted search in Solr?

What Is Faceted Search? Faceted search is the dynamic clustering of items or search results into categories that let users drill into search results (or even skip searching entirely) by any value in any field. Each facet displayed also shows the number of hits within the search that match that category.

What is facet pivot in SOLR?

Solr pivot faceting or decision tree faceting or sub faceting used to provide more details view of index data. we can calculate sub facet of parent facet or generate tree like structure of data and display it in the application which helps us take better decision.

What is a facet query?

A facet is a search interface component that allows the end user to refine a query by selecting filters based on item metadata(i.e., field values). The search results that don't match the end user's selection disappear from the result list.

How can I get Solr query?

You can search for "solr" by loading the Admin UI Query tab, enter "solr" in the q param (replacing *:* , which matches all documents), and "Execute Query". See the Searching section below for more information. To index your own data, re-run the directory indexing command pointed to your own directory of documents.


1 Answers

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+*]

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:

  • (Archived) https://web.archive.org/web/20100416235126/http://old.nabble.com/Re:-faceted-browsing-p3753053.html
  • (Archived) https://web.archive.org/web/20090430160232/http://www.nabble.com/Re:-Sorting-p6803791.html
  • (Archived) https://web.archive.org/web/20090504020754/http://www.nabble.com/Dynamically-calculated-range-facet-td11314725.html
like image 108
Mauricio Scheffer Avatar answered Sep 23 '22 14:09

Mauricio Scheffer