Sometimes grouping results on the basis of field values is not enough. For example, imagine that we would like to group documents in price brackets, that is, we would like to show the most relevant document for documents with price range of 1.0 to 19.99, a document for documents with price range of 20.00 to 50.0, and so on. Solr allows us to group results on the basis of query results. This recipe will show you how to do that.
In this chapter we will use the same index structure and test data as we used in the Using field values to group results recipe in this chapter. Please read it before continuing.
As we are reusing the data and index structure from the Using field values to group results 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/select?q=*:*&group=true&group.query=price:[20.0+TO+50.0]&group.query=price...