Retrieve and Apply Facets
Facets are attribute categories for records that customers can use to further filter results. For example, if a customer searches for shirts, the available facets might include size, color, or material type. Refer to the Facets section of Search Results Customizations as well as Manage Facets for Category Pages in the Monetate Knowledge Base for more information.
Within a Personalized Search API request, you can both retrieve applicable facets to display to customers and apply facets to filter results.
Retrieving facets is a computationally expensive operation. For best performance, you should minimize the number of times you retrieve them. For example, if you're paginating search results, retrieve facets only on the first query.
To retrieve facets in a Personalized Search API request, add the filtersToReturn object with its enabled parameter set to true.
You must contact your dedicated Customer Success Manager (CSM) if you want to use a rating filter ("key": "rating" in the request).
The facets appear on your site as filters that the customer can apply to further narrow the search results.
The following example is a request with more optional parameters in the filtersToReturn object, along with the response:
Applying facets to a query filters the results based on the selected facets and values. Run this query after a customer selects the facets they want to filter by. Apply facets in a query by using the applyFilters object.
Applying facets to a query filters the results based on the selected facets and values. Run this query after a customer selects the facets they want to filter by. Apply facets in a query by using the applyFilters object.
Applying facets filters out any record for which the facet attribute doesn't match the specified value. You can apply multiple facets to further filter results.
The singleSelect parameter determines the result when multiple values are specified for a facet. When it's set to true, the records returned must contain all the values. When it's set to false, the records returned must contain at least one of the values.