Facets

In Sitecore Search, you can use facets to classify your content. Facet values can be a string, a number, or a range. Often facets are displayed in the UI as part of the search experience.

To narrow results in a search results widget, you need to include the facets model or SearchResultsConfig and values for selected facets or array of SearchResultsStoreSelectedFacet.

SearchResultsConfig and facets

This object describes configuration for the search request and results, and is included in the useSearchResults query hook. You need to include a SearchResultsFacetConfigItem object in its facets value to configure how the facet is handled. By default, facets are compared using valueId.

Property

Type

Description

facets

SearchResultsStoreSelectedFacets

Object of key-value pairs where the keys are the facet name and the values are SearchResultsFacetConfigItem objects.

Note

Refer to the Sitecore Search interface for attribute names.

SearchResultsFacetConfigItem

Property

Type

Description

Values

type

FacetPayloadType

Required.

Describes the type of payload.

Default: valueId

text

rage

SearchResultsStoreSelectedFacet

The state object in useSearchResults contains the selectedFacets attribute, which is an array of SearchResultsStoreSelectedFacet objects that include SearchResultsStoreValueIdSelectedFacet, SearchResultsStoreRangeSelectedFacet, and SearchResultsStoreTextSelectedFacet.

SearchResultsStoreTextSelectedFacet

Extends BaseSearchResultsStoreSelectedFacet

Property

Type

Description

facetValueText

string

Required.

Text associated with the facet.

facetValueId

string

ID associated with the facet value.

SearchResultsStoreValueIdSelectedFacet

Extends BaseSearchResultsStoreSelectedFacet

Property

Type

Description

facetValueId

string

Required.

ID associated with the facet value.

SearchResultsStoreRangeSelectedFacet

Extends BaseSearchResultsStoreSelectedFacet

Property

Type

Description

min

number

Minimum facet value.

max

number

Maximum facet value.

BaseSearchResultsStoreSelectedFacet

This is the base type for selected facet objects.

Property

Type

Description

facetId

number

Required.

ID associated with the facet.

facetLabel

string

Display label associated with facet.

valueLabel

string

Display label associated with facet value.

Do you have some feedback for us?

If you have suggestions for improving this article,