|
| 1 | +--- |
| 2 | +title: Performing personalized search queries |
| 3 | +description: Search personalization uses context about the person performing the search to provide results more relevant to that specific user. This article guides you through configuring and performing personalized search queries. |
| 4 | +--- |
| 5 | + |
| 6 | +## Requirements |
| 7 | + |
| 8 | +- A Meilisearch project |
| 9 | +- Self-hosted Meilisearch users: a Cohere API key |
| 10 | + |
| 11 | +## Activate personalized search |
| 12 | + |
| 13 | +### Cloud users |
| 14 | + |
| 15 | +Open a support ticket requesting Meilisearch to activate search personalization for your project. |
| 16 | + |
| 17 | +### Self-hosted users |
| 18 | + |
| 19 | +Relaunch your instance using the search personalization instance option: |
| 20 | + |
| 21 | +```sh |
| 22 | +meilisearch --experimental-personalization-api-key="COHERE_API_KEY" |
| 23 | +``` |
| 24 | + |
| 25 | +## Generating user context |
| 26 | + |
| 27 | +Search personalization requires a description about the user performing the search. Meilisearch does not currently provide automated generation of user context. |
| 28 | + |
| 29 | +You’ll need to **dynamically generate a plain-text user description** for each search request. This should summarize relevant traits, such as: |
| 30 | + |
| 31 | +- Category preferences, like brand or size |
| 32 | +- Price sensitivity, like budget-conscious |
| 33 | +- Possible use cases, such as fitness and sport |
| 34 | +- Other assorted information, such as general interests or location |
| 35 | + |
| 36 | +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". |
| 37 | + |
| 38 | +## Perform a personalized search |
| 39 | + |
| 40 | +Once search personalization is active and you have a pipeline in place to generate user profiles, you are ready to perform personalized searches. |
| 41 | + |
| 42 | +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`: |
| 43 | + |
| 44 | +```sh |
| 45 | +curl \ |
| 46 | + -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ |
| 47 | + -H 'Content-Type: application/json' \ |
| 48 | + --data-binary '{ |
| 49 | + "q": "wireless keyboard", |
| 50 | + "personalize": { |
| 51 | + "userContext": "The user prefers compact mechanical keyboards from Keychron or Logitech, with a mid-range budget and quiet keys for remote work." |
| 52 | + } |
| 53 | + }' |
| 54 | +``` |
0 commit comments