Understanding filters and facets

Filters and facets work together to make it possible for visitors to filter content using the UI. You configure filters and facets in the Customer Engagement Console (CEC), on the Administration page, in the Domain Settings section, on the Feature Configuration tab.

An overview of filters and facets

A filter is a search component that you can use to limit the type of content and attributes you want to be returned. Depending on your use case, filters can be visible to your visitors, or they might be used behind-the-scenes to only show a subset of results. An example of filters working behind the scenes is if you create a filter based on the blog_status attribute, and create a rule to show only blog_status=published blogs when site visitors in a specific context search for a term.

A facet is a dynamic search interface component that creates categories based on attribute values and makes it possible for visitors to filter search results using those categories. Facets can change based on a visitor's query.

For example, the Sitecore.com search page uses the product attribute as a facet. The different product names and counts of content items associated with those products change depending on the vistor's search. In the first screenshot, the visitor has searched for composable. This search has returned 8 content items for the product value Content Hub. In the second screenshot, the visitor has searched for dxp and the count for Content Hub is 4. This is because, for each of these searches, the facet feature recalculates the number of content items that fit the search criteria and contain the product facet value: Content Hub.

Screenshot of search on Sitecore.com for composable with the product facet outlined.
Screenshot of search on Sitecore.com for dxp with the product facet outlined.

When a visitor clicks on a facet, it generates a filter that refines the search results to those that meet the filter condition. The following screenshot shows the updated search results for dxp after the visitor clicks Content Hub in the product facet.

Screenshot of search for dxp filtered to show only content items with a product value of Content Hub.

Filter options

You do not usually need to make changes to filters after enabling them for an attribute. However, if you want to view or change filter options, you can do so by clicking to the right of any attribute in the Filters section of Feature Configuration.

The following lists the options available for each filter:

  • Filter type - determined automatically by the data type of the attribute. If the attribute is a number, the filter type defaults to Range. If the attribute is a string, the filter type defaults to Terms.

  • Multiple value operator - determines how to combine multiple values when filtering. The available options are Or, which is the default and represents a union of values, and And, which represents an intersection of values.

    Tip

    Although this value is configurable in the CEC, for API implementations, we recommend you set it using the API because it is more flexible. Any configuration set using the API overrides configuration in the CEC.

  • Analyzer - marks whether to use an analyzer on the attribute value. The only analyzer available for the filter feature is the lowercase analyzer, which converts input to lowercase letters, rendering the filter case-insensitive. You might want to use this analyzer if the capitalization in your metadata is inconsistent. For example, if some blogs have a content type of blog and others have a content type of Blog, using the lowercase analyzer would group all of them together when filtering. In this example, if you did not use the lowercase analyzer, there would be two separate filter options: Blog and blog. The default for this option is No analyzer.

  • Alias - this option is for internal use. It is not necessary for you to configure it.

Facet options

You enable an attribute as a facet from the attribute editing dialog. You do not need to make any further changes after doing this, but there are some options that can be configured in Feature Configuration if you need more control over how facets behave.

The following lists the facet options available in the Facets section of Feature Configuration:

  • Label - the display name for the attribute throughout the CEC. For ease of maintenance, we recommend you also use this as the title for facet options in the search experience.

  • Id - how the facet is referenced in API requests. We recommend you don't change this option after its initial configuration.

  • Aggregation type - set automatically using the data type of the attribute. The value of this parameter is Terms for strings and arrays of strings, and Histogram for numeric facets. Aggregation type determines how the occurrence of each attribute value is calculated.

    For example, the Content type facet is a string, so its aggregation type is Terms. That means that the number of indexed items belonging to that facet value is calculated individually. So the following image shows that there are 560 documents with the content type value of blogs.

    Screenshot of the "Blogs" filter option for content type with number 560 highlighted.

    For an attribute that has a numeric data type, such as Review rating, the aggregation type is Histogram, meaning that the frequency of attribute values is calculated using a range. So in the case of review ratings, the counts could be distributed in buckets from 1-2 stars, 2-3 stars, and so on. If you had 30 content items with a star rating of 4 and 32 content items with a star rating of 5, the count for content items with 4-5 stars would be calculated by adding the counts of the two separate attribute values together. This would result in a count of 62, as you can see in the following image.

    Screenshot of the "4-5 stars" filter option for review rating, with the number 62 highlighted.
  • Operator - defines how the facet will react to filters in the request. Available options are:

    • And - hard filters, filters on the facet's attribute, and filters on other attributes all apply when computing values and counts. In practice, this means that the visitor can't select more than one option for this facet (unless documents are multivalued). For example, consider a software company that is using the version attribute as a facet using the and operator. If a visitor clicks a version option, all other version facet options are disabled.

    • Dynamic Or - only hard filters and filters on other attributes are applied. In practice, this means that you can select multiple options for this facet, but the values will be changed by other facet selections. For example, imagine you have two different facets: author and content type, and the visitor clicks the content type option, blog. This filters out all content types except blog and reduces the number of content items for each author value to the number of blogs written by that author. Then, the visitor clicks an author option: James Parker. The number of content items for each content type now changes to include only those items written by the author, James Parker. The visitor can continue clicking options and the counts will change accordingly.

    • Static Or - only the hard filter for the page, if any is applied. This means that filters for this or other facets are disregarded. In practice, this means that the facet values will be static after the first page load and you can select multiple options.

  • Max - the maximum number of facet values returned. The default is 10. We recommend you keep the value of this parameter as low as possible. Setting Max above 50 can greatly impact site performance and the absolute maximum is 100. To display only a few values at a time in the search experience, use pagination for the facet in API calls or the SDK.

  • Minimum documents - the minimum number of content items that must contain a value for this facet in order for it to be returned. If not specified, the value of this parameter defaults to 1.

  • Order - sets the order facets are returned in. By default, this is set to Descending facet value count, which means that the values with the highest number of associated content items appear on top. You can also order facets alphabetically ascending or descending, but this might impact site performance compared to the default.

  • Boost list - used to boost certain values to the top of the facet list or exclude values from the list. In the following image, the News, Blogs, and Events values for the Content type facet are boosted to the top of the list, while the Others value is excluded.

    Note

    This parameter is only relevant for facets with an aggregation type of Terms.

    Screenshot of boost list dialog.
    Note

    If you include any values in the boost list, the rest of the values are displayed in ascending alphabetical order, regardless of the value of the Order option.

  • Interval - used to manually set the interval size for each range in the response. For example, if this is set to 3, value ranges would be 1-3, 3-6, 6-9, and so on. If it is set to 5, they would be 1-5, 5-10, 10-15, and so on. If merge buckets are enabled, it might override this setting to eliminate empty buckets.

    Note

    This parameter is only used for facets with an aggregation type of Histogram.

  • Merge buckets - allows merging buckets to even out the contents in the facet response. This ensures that no facet options are shown that have a count of 0. For example, if you had a numeric facet with 15 values between 10 and 20, 0 values between 20 and 30, and 24 values between 30 and 40, it would redistribute the buckets to eliminate the empty one.

    Note

    This parameter is only used for facets with an aggregation type of Histogram and is enabled by default for those facets.

Do you have some feedback for us?

If you have suggestions for improving this article,