facets( )

Categorizes search results according to the specified facets.

The facets() function allows you to categorize search results according to one or more specified fields.

For example, if you have a sports equipment store with products divided into collections of Basketball, Football, and Baseball equipment, you can apply collections as a facet to your search and get information about how many documents in the search results are included in each collection.

If you chained a facets() function to your search, your WixSearchResult will include an array of facet results.

Faceting is a useful tool for presenting categorization data to site visitors and allowing them to narrow down and navigate search results. Visitors can select one or more facets, and you can apply corresponding filters to your search results.

Facet Example

By default, facets() is set to none.

You cannot apply facets to your search if the documentType is set to "Site/Pages".

Only some fields can be used for faceting. You can check which fields are facetable in the schema for each documentType.

Method Declaration
Method Parameters

The fields to use as facets.

Was this helpful?