Facets
In Sitecore Search, facets are categories based on attribute values that visitors can use to filter search results. They are dynamic, based on a visitor's query and currently displayed search results.
To use an attribute as a facet, you need to enable it as a facet. You can configure more options to control facet behavior, if required, on the Feature Configuration tab in the Domain Settings section.
When used as facets, numeric attributes such as integers are grouped together in ranges to provide meaningful selection options for the site visitor. For example, for a product price attribute, instead of showing every individual price as a filter option, Sitecore Search groups the prices into meaningful ranges like:
-
$0–$499
-
$500–$999
-
$1,000 and above.
These ranges appear as facets in the search UI, allowing users to quickly narrow down their results by selecting a price range that fits their budget.
The following image shows the documentation search page of Sitecore.com. On the left you can see Website and Role facets and their values. The displayed results include the list of content available that contain apps in the description attribute.
The following image shows the same page with the Developer role selected. You can see that the list of facet values under Website and the results have changed for content available that contain apps in the description attribute.
Use cases
Here are some use cases that require the use of facets in your Sitecore Search implementation.
Configuring the list of facets
In addition to configuring how many facets to return, you can configure how they are sorted before preparing the list. For a facet, you can also configure which facets to boost in or exclude from the list.
Facets in long URLs
When a URL contains encoded facets, the URL might be long and harder for search engines to optimize during SEO.
To create more meaningful encodings, and as a result have shorter URLs and boost your SEO score, use the facetValueText field instead of the facetId field in the API response.
In the response received from Search, your developer has access to the text value for every result listed.