Facet searching
In Solr, a facet provides us with a way to arrange the result into categories based on the index terms. For example, in our musicCatalogue
, we can arrange the songs based on genre (for example, rock, pop, world music, and so on). This feature is very helpful in e-commerce websites, where we need to see data in a categorical way. Let's see how we can enable faceting in our search queries. There are no special settings needed to get faceting to work in our musicCatalogue
example.
Let's open the query browser tab for our musicCatalgoue
example from the Solr Admin UI. This time, in the query input fields, we'll enable the facet
checkbox and input the genre
field in the facet.field
textbox, like this:
After clicking on Execute Query, we can see the following JSON output, which will contain a special JSON element. This element will contain facet_counts
:
"facet_counts": { "facet_queries": {}, "facet_fields": { "genre...