Calling the Personalized Searc...

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

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).

POST
Request
Response
Body Parameters
filters
optional
Object
Defines the filtering options presented to the customer.
Example Request for Retrieving Facets
Responses
200


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:

Request for Retrieving Facets with Optional Parameters Example
Response


Applying Facets

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.

Example Request with Applied Facets


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.