Solr provides a [ faceting component] which is part of the standard request handler and can be used by various other request handlers to include "Facet counts" based on some simple criteria.

This page briefly provides some general background information:

Facet Indexing

Faceting is done on indexed rather than stored values. This is because the primary use for faceting is drill-down into a subset of hits resulting from a query, and so the chosen facet value is used to construct a filter query which literally matches that value in the index. For the stock Solr request handlers this is done by adding an fq=<facet-field>:<quoted facet-value> parameter and resubmitting the query.

Because faceting fields are often specified to serve two purposes, human-readable text and drill-down query value, they are frequently indexed differently from fields used for searching and sorting:

As an example, if I had an "author" field with a list of authors, such as:

I might want to index the same data differently in three different fields (perhaps using the Solr [:SchemaXml#Copy Fields:copyField] directive):

Then when the user drills down on the "Schildt, Herbert" string I would reissue the query with an added fq=author:"Schild, Herbert" parameter.

Facet Operation

Currently SimpleFacets has 3 modes of operation, selected by a combination of SimpleFacetParameters and [:SchemaXml: schema.xml] Field definitions:


Any number of [:SimpleFacetParameters#facet.query:facet.query] parameters can be passed to the request handler. The filter for each distinct facet.query is retrieved from the filterCache (or generated if not cached yet) and intersected with the filter for the base query to obtain the count.


Any number of [:SimpleFacetParameters#facet.field:facet.field] parameters can be passed to the request handler. For each facet.field, one of two approaches will be used based on the [:SimpleFacetParameters#facet.method:facet.method] or the field type: