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 |
|---|---|---|
|
|
SearchResultsStoreSelectedFacets |
Object of key-value pairs where the keys are the facet name and the values are |
Refer to the Sitecore Search interface for attribute names.
SearchResultsFacetConfigItem
|
Property |
Type |
Description |
Values |
|---|---|---|---|
|
|
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 |
|---|---|---|
|
|
string |
Required. Text associated with the facet. |
|
|
string |
ID associated with the facet value. |
SearchResultsStoreValueIdSelectedFacet
Extends BaseSearchResultsStoreSelectedFacet
|
Property |
Type |
Description |
|---|---|---|
|
|
string |
Required. ID associated with the facet value. |
SearchResultsStoreRangeSelectedFacet
Extends BaseSearchResultsStoreSelectedFacet
|
Property |
Type |
Description |
|---|---|---|
|
|
number |
Minimum facet value. |
|
|
number |
Maximum facet value. |
BaseSearchResultsStoreSelectedFacet
This is the base type for selected facet objects.
|
Property |
Type |
Description |
|---|---|---|
|
|
number |
Required. ID associated with the facet. |
|
|
string |
Display label associated with facet. |
|
|
string |
Display label associated with facet value. |