Imagine a situation where you have an application that has a search feature for cars. One of the requirements is not only to show search results, but also to show the number of cars with the price period chosen by the user. There is also another thing—those queries must be fast because of the number of queries that will be run. Can Solr handle that? The answer is yes. This recipe will show you how to do it.
For getting the number of documents matching the query and subquery, follow these steps:
Let's start with creating an index with the following structure (just add this to your
schema.xml
file in the field definition section; we will use theprice
field to do the faceting):<field name="id" type="string" indexed="true" stored="true" required="true" /> <field name="name" type="text" indexed="true" stored="true" /> <field name="price" type="float" indexed="true" stored="true" />
Now let's index...