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.

If a customer initiates a search on your site without typing anything into the search bar, then Personalized Search still returns results based on the settings you've configured for Personalized Site Search or Personalized Category Pages, as applicable, in the Monetate platform. Additionally, Personalized Search displays all the indexed facets from the mapped product catalog, excluding any that you've removed using the settings you've configured in the Monetate platform.

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. Use the include and exclude arrays to define which filters you want and do not want returned, respectively.

You must contact your dedicated Customer Success Manager (CSM) if you want to use a rating filter ("key": "rating") in the request.

Retrieving the Price Facet

Personalized Site Search treats the price facet differently from other facets, so displaying a Price filter for customers to sort results does not involve passing price in the include array. Instead, you must include in the request the rangeFilterSettings object with "monetate_price" as the value for key. See the definition of the rangeFilterSettings object in the reference for more information.

POST
Request
Response
Path Params
name
required
String
The client's account (for example, "a-1db61f7a") as it appears in the value of channel used in the Engine API request to obtain the search token.
instance
required
String
The client's account environment. The value must either be "p" for production or "d" for development.
domain
required
String
The client's domain (for example, "product.monetate.me") as it appears in the value of channel used in the Engine API request to obtain the search token.
Header Parameters
Content-type
required
String
The value must be "application/json."
Body Parameters
searchToken
required
String
A token used to authenticate the search request obtained by sending a request to the Engine API. See "Obtaining a Search Token" in "Calling the Personalized Search API" for more information.
filters
optional
Object
Defines the filtering options presented to the customer.
Example Request to Retrieve Facets
Responses
200


The facets appear on your site as filters that the customer can apply to further narrow the search results.

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.

If the customer selects only one value of only one facet, then Personalized Search ensures that all the returned records contain the facet attribute with the customer-selected value. However, if the customer selects multiple values for one facet, then the Boolean parameter singleSelect of the applyFilters object determines how Personalized Search applies them:

  • When singleSelect is true, then a record must contain all the selected values to be included in the response.
  • When singleSelect is false, then a record needs only to contain one of the selected values to be included in the response.

If constraints are added for multiple facets and singleSelect is false, then a record must have at least one value from each of the filter conditions provided.

POST
Request
Path Params
name
required
String
The client's account (for example, "a-1db61f7a") as it appears in the value of channel used in the Engine API request to obtain the search token.
instance
required
String
The client's account environment. The value must either be "p" for production or "d" for development.
domain
required
String
The client's domain (for example, "product.monetate.me") as it appears in the value of channel used in the Engine API request to obtain the search token.
Header Parameters
Content-type
required
String
The value must be "application/json."
Body Parameters
applyFilters
required
Object
Defines the selected facets and values the customer selected.
Example Request to Apply Facets
Responses
200