Skip to content

Personalized search

Our endpoint /v1/items/search, generates personalized search results tailored for each user in your application.

It considers user behavior, current trends, and more and returns a customized search result for each individual.

This endpoint takes several parameters to generate customized search results.

To implement this solution, please use the endpoint POST /v1/items/search. if you project personalizer project setup is completed, you chan check the endpoint in our sandbox.

You can find sample code for this implementation in our API documentaion.

Sample request body

{
  "user_id": "a0cc6beb-2909-459b-be55-62196af78ce4",
  "member_id": "df3456tg-2909-459b-be55-62196afedf85",
  "message": "Search for something...",
  "type": "individual",
  "price_lower": 1,
  "price_upper": 10000,
  "categories": [
    "category1",
    "category2"
  ],
  "flags": {
    "flag1": true,
    "flag2": false
  },
  "sort": {
    "column_name": "asc / desc"
  },
  "dynamic_filtering": [
    "column1",
    "column2"
  ],
  "details": false,
  "start": 0,
  "size": 10
}

As you can see in the above example, the values of parameters categories, flags, sort, dynamic_filtering need to come from your catalog, otherwise you will get and error. Here is a request body that you can use with all the optional fields removed.

{
  "user_id": "a0cc6beb-2909-459b-be55-62196af78ce4",
  "message": "Search for something...",
  "type": "individual",
  "price_lower": 1,
  "price_upper": 10000,
  "categories": [],
  "flags": { },
  "sort": {},
  "dynamic_filtering": [],
  "details": false,
  "start": 0,
  "size": 10
}

Explanation of Parameters

  • user_id: UUID of each unique user. Even for non-logged in users, saved in the browser local storage.
  • member_id: Represents the id of a logged-in unique user. It could be the user's phone number, Email address etc., that can uniquely identify the user across platforms.
  • message: Search query from the user
  • type: Can select "individual" or "group". If you have parent_item_id in your catalog, you may want to group your search results and return one variant from the group. In this case, select group. Otherwise, select individual.
  • price_lower: Minimum price filter for search result.
  • price_upper: Maximum price filter for search result.
  • categories: Category filter, as per setting in mapper
  • flags: As per flags set in the mapper, can be "true" or "false".
  • sort: Sorting preference.
  • dynamic_filtering: Takes the name of categories that you set in the mapper. This will give values from those categories in the search result at the end. This defines which values are filterable in your search result body. We have discussed in detail about this feature in a separate tutorial "Dynamic filtering"
  • details: If "true", gives product ID with full detail from the catalogue. If "false", only gives product ID.
  • start: Index number of the first result to show.
  • size: Number of results to show.

Note

In the ‘Environment setup’ > ‘Creating a new mapper’ section, we discussed setting up search_settings in the mapper, which affects this endpoint’s search results. Refer to that section when implementing this endpoint. Those settings heavily effect the response of this endpoint.