Solr's faceting is broken down into five types. They are as follows:
field
: This is the most common type of faceting which counts the number of occurrences of each indexed term in a field. The facet counts are grouped in the output under the name facet_fields
.range
: Given a numeric or date field, this creates facets for a set of ranges. The facet counts are grouped in the output under the name facet_ranges
.query
: This is a very flexible type of faceting which counts the number of documents matching each specified query. The facet counts are grouped in the output under facet_queries
.pivot
: Also known as decision tree faceting, this type of faceting allows recursive faceting across a set of fields. Results are grouped under facet_pivot
.interval
: A Solr 4.10-only feature, an interval facet is similar to a query facet with range queries. While the same results can be achieved using query facets with range queries, interval facets are implemented differently and, therefore, have different performance characteristics.In the rest of this chapter, we will describe how to do these different types of facets. But before that, there is one common parameter to enable faceting:
In all of the examples in this chapter, we always set facet=true
.