1. Search request

The Facet interface

In Sitecore Search, content can be displayed in facets. A facet is a dynamic search interface component that creates categories based on attribute values. With facets, users can easily filter search results using the categories.

Facet interface

NameTypeDescription
allbooleanRequests all facet types.
maxnumberMaximum number of facet types.
sortFacetSortSorting order requested.
typesArrayList of facet types.

FacetSort interface

NameTypeDescription
namestringAlphabetically or numerically sort type.

text or count.
orderstringAscending or descending sort.

asc or desc.

FacetType interface

NameTypeDescription
afterstringName of previous facet type in list..
excludeArrayNames of facet types to exclude.
filterFacetTypeFilterFacetTypeFilterOr or FacetTypeFilterAnd
filtering_optionsArrayList of FacetTypeFilteringOptions enumerator values.

FacetTypeFilteringOptions.HARD_FILTERS, FacetTypeFilteringOptions.OTHER_FACET_VALUES, and    FacetTypeFilteringOptions.OWN_VALUES
keyphrasestringPhrase to search.
maxnumberMaximum number of facet types to return.
min_countnumberMinimum number of facet types to return.
namestringName of facet type.
sortArrayList of sorting options for the facet type.

Sort interface

NameTypeDescription
choicesbooleanFlag to request a list of all sort options in the response.

true or false
valueSortItemObject describing how items are sorted.

SortItem interface

NameTypeDescription
namestringAlphabetically or numerically sort type.

text or count.
orderstringAscending or descending sort.

asc or desc.
Note

Unless indicated otherwise, all values are optional.

The following code block lists the various methods related to facets and is accessible through the WidgetRequest object. After the installation of the JS Data package into your project, these methods and their documentation are available in your IDE.


/** search.facet */
getSearchFacet(): Facet;
setSearchFacet(value: Facet): IWidgetItem;
resetSearchFacet(): IWidgetItem;
updateSearchFacet(value: Facet): IWidgetItem;

/** search.facet.all */
getSearchFacetAll(): boolean;
setSearchFacetAll(value: boolean): IWidgetItem;
resetSearchFacetAll(): IWidgetItem;

/** search.facet.max */
getSearchFacetMax(): number;
setSearchFacetMax(value: number): IWidgetItem;
resetSearchFacetMax(): IWidgetItem;

/** search.facet.sort */
getSearchFacetSort(): FacetSort;
setSearchFacetSort(value: FacetSort): IWidgetItem;
resetSearchFacetSort(): IWidgetItem;
updateSearchFacetSort(value: FacetSort): IWidgetItem;

/** search.facet.sort.name */
getSearchFacetSortName(): string;
setSearchFacetSortName(value: string): IWidgetItem;
resetSearchFacetSortName(): IWidgetItem;

/** search.facet.sort.order */
getSearchFacetSortOrder(): string;
setSearchFacetSortOrder(value: string): IWidgetItem;
resetSearchFacetSortOrder(): IWidgetItem;

/** search.facet.types */
getSearchFacetTypes(): Array<FacetType>;
setSearchFacetTypes(value: Array<FacetType>): IWidgetItem;
resetSearchFacetTypes(): IWidgetItem;
addSearchFacetType(value: FacetType): IWidgetItem;
removeSearchFacetType(value: FacetType, filter?: (v: any) => boolean): IWidgetItem;
If you have suggestions for improving this article, let us know!