When faceting is used, it is usually used in the context of faceted navigation, in which a facet value becomes a navigation choice for the user to filter on. In Solr, that becomes an additional filter query in a subsequent search. The total matching documents of that search should be equal to the facet value count. In this section, we'll review how to build the filter queries. We won't show an example for facet query faceting because there's nothing to do—the facet query is a query and can be supplied directly as an fq
parameter.
For the case of field value faceting, consider the first example in the chapter where r_official
has a value Bootleg
. Generating a filter query for this couldn't be simpler: fq=r_official:Bootleg
. But what if the value contained a space or some other problematic character? You'd have to escape it using quotes or backslash escaping...