Grouping documents by the query value
Sometimes, grouping results on the basis of field values is not enough. For example, imagine that we would like to group documents in some kind of price brackets—show the most relevant document for documents with the price range of 1.0 to 19.99, a document for documents with the price range of 20.00 to 50.0, and so on. Solr allows you to group results on the basis of queries results. This recipe will show you how to do that.
Getting ready
In this chapter, we will use the same index structure and test data as we used in the Grouping documents by the field value recipe in this chapter. Read it before we continue.
How to do it…
Because we are reusing the data and index structure from the Grouping documents by the field value recipe, we can start with the query. In order to group our documents on the basis of query results, we can send the following query:
http://localhost:8983/solr/cookbook/select?q=*:*&group=true&group.query=price:[20.0+TO+50.0]&...