

Table of Contents
1. Overview
Solr provide facility to group or cluster search result into categories that let users drill into search results by any value in any field. Solr faceting is used in many applications to give an overall idea about how the data resides in the index.In this article, we will discuss the first part of Solr faceting i.e Solr Field Value Faceting.
“Field should be indexed (indexed=”true”) to enable faceting on that field”
“To Enable facet component need to pass facet=true in query request ”
2. Field Value Faceting Parameters with an example
Let’s have a quick look at some of the common parameters that used in Solr field value faceting.We will use films index in examples.
2.1 facet.field
Specify the name of the field you want to facet on.If this parameter not specified in the query than other parameters will not consider.
Let’s assume that we want all the films that have genre:Thriller
http://localhost:8983/solr/query?q=genre:Thriller
to retrive facet count for directed_by field, we simply add below params in our query.
facet=true& facet.field=directed_by
2.2 facet.limit
As you see in above example by default solr will return all the facet values in the response, To control facet result set size need to set facet.limit parameter.
facet=true& facet.field=directed_by& facet.limit=10
now solr will give only 10 facet value in response as below.
2.3 facet.sort
Solr by default sort facet result by count, if we want to sort facet result by alphabetic order then pass index in facet.sort parameter.
facet=true& facet.field=directed_by& facet.limit=10& facet.sort=index
By executing above query solr will give facet output in alphabetic order as below:
2.4 facet.missing
If we want to count all results that match the query but does not contain any value in that field for that documents, need to set this param.
facet=true &facet.field=directed_by &facet.limit=10 &facet.sort=index &facet.missing=true
when we execute above query it will return missing value in a specified field.
2.5 facet.mincount
This parameter specify the minimum counts required for a facet field to be included in the response. If a field’s counts are below the minimum, the field’s facet is not returned.
Let’s assume we want directed_by facet which has mincount is 3.
facet=true &facet.field=directed_by &facet.limit=10 &facet.sort=index &facet.missing=true &facet.mincount=3
When we execute above query solr will return facet values which have 3 or more counts.
2.6 facet.threads
Performance is biggest factor in any analytics application. Solr provide multi-threaded support to provide fast result. Default value of this param is 0 which indicate that main thread will compute all the result.
2.7 facet.prefix
facet.prefix parameter used to limit the facet terms which starting with given string prefix. By default it is case sensitive.
Let’s consider an example where we want facet which starts with Jac string prefix.
facet=true &facet.field=directed_by &facet.limit=10 &facet.sort=index &facet.missing=true &facet.prefix=Jac
while executing above query we will get facet result which starts with Jac
2.8 facet.contains
As facet.prefix only limit facet result which starts with the specified string, if want to limit facet result with contains given string use facet.contains parameters as below.
facet=true &facet.field=directed_by &facet.limit=10 &facet.sort=index &facet.missing=true &facet.contains=Jac
while executing above query we will get facet result which contains with Jac
2.9 facet.contains.ignoreCase
If we want to get solr facet.contains result case insensitive,we need to pass facet.contains.ignoreCase=true.Sample query would as below.
facet=true &facet.field=directed_by &facet.limit=10 &facet.sort=index &facet.missing=true &facet.contains=Jac &facet.contains.ignoreCase=true
3. Conclusion
In this article we have discuss solr field value faceting with details parameter explanation with example.
4. References
Refer Solr Reference Guide for more details.