Skip to main content

Requirements

  • A Meilisearch project
  • Self-hosted Meilisearch users: a Cohere API key

Cloud users

Open a support ticket requesting Meilisearch to activate search personalization for your project.

Self-hosted users

Relaunch your instance using the search personalization instance option:
meilisearch --experimental-personalization-api-key="COHERE_API_KEY"

Generating user context

Search personalization requires a description about the user performing the search. Meilisearch does not currently provide automated generation of user context. You’ll need to dynamically generate a plain-text user description for each search request. This should summarize relevant traits, such as:
  • Category preferences, like brand or size
  • Price sensitivity, like budget-conscious
  • Possible use cases, such as fitness and sport
  • Other assorted information, such as general interests or location
The re-ranking model is optimized to favor positive signals. For best results, focus on affirmatively stated preferences, behaviors, and affinities, such as “likes the color red” and “prefers cheaper brands” over “dislikes blue” and “is not interested in luxury brands”. Once search personalization is active and you have a pipeline in place to generate user profiles, you are ready to perform personalized searches. Submit a search query and include the personalize search parameter. personalize must be an object with a single field, userContext. Use the description you generated in the previous step as the value for userContext:
curl \
  -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \
  -H 'Content-Type: application/json' \
  --data-binary '{ 
    "q": "wireless keyboard",
    "personalize": {
      "userContext": "The user prefers compact mechanical keyboards from Keychron or Logitech, with a mid-range budget and quiet keys for remote work."
    }
  }'