Facet Search

http://wiki.apache.org/solr/SolrFacetingOverview
http://wiki.apache.org/solr/SimpleFacetParameters

Faceted search is the dynamic clustering of items or search results into categories that let users drill into search results (or even skip searching entirely) by any value in any field. Each facet displayed also shows the number of hits within the search that match that category. Users can then "drill down" by applying specific contstraints to the search results. Faceted search is also called faceted browsing, faceted navigation, guided navigation and sometimes parametric search.

Faceted search takes the documents matched by a query and generates counts for various properties or categories. Links are usually provided that allows users to "drill down" or refine their search results based on the returned categories

The following example searches for all documents (*:*) and requests counts by the category field cat.

&q=*:*&facet=true&facet.field=cat

Notice that although only the first 10 documents are returned in the results list, the facet counts generated are for the complete set of documents that match the query.

We can facet multiple ways at the same time. The following example adds a facet on the boolean inStock field:

&q=*:*&facet=true&facet.field=cat&facet.field=inStock

Solr can also generate counts for arbitrary queries. The following example queries for ipod and shows prices below and above 100 by using range queries on the price field.

&q=ipod&facet=true&facet.query=price:[0 TO 100]&facet.query=price:[100 TO *]

One can even facet by date ranges. This example requests counts for the manufacture date (manufacturedate_dt field) for each year between 2004 and 2010.

&q=*:*&facet=true&facet.date=manufacturedate_dt&facet.date.start=2004-01-01T00:00:00Z
&facet.date.end=2010-01-01T00:00:00Z&facet.date.gap=+1YEAR

Faceted browsing is a way of classifying results that have already been returned into meaningful categories that are guaranteed to exist. Facets are used to help users narrow down search results.

Clicking a facet link in the example submits the original query, plus the Facet keyword as a new keyword. If the original query was q=Solr and the facet field was keywords and you clicked the replication link in Figure 2, the new query would be q=Solr AND keywords:replication.

It may require you to index your application content in new ways. Faceting is done on indexed fields and works best on non-tokenized words that are not lower-cased. Facet fields usually do not need to be stored.

Note also that Solr does not create the categories in the facets; they must be added by the application itself during indexing. Solr does provide the logic for figuring out what the facets are and their counts, given a facet field.

Faceted Search with Solr
Search smarter with Apache Solr, Part 1

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License