Add personalized search support to the search query - #752
Open
arcusbuilds wants to merge 1 commit into
Open
Conversation
Adds the experimental `personalize` search parameter introduced in Meilisearch v1.47.0, as requested in meilisearch#737. `SearchQuery.Personalize` covers POST /indexes/{uid}/search. It also covers non-federated POST /multi-search, since `MultiSearchQuery.Queries` is a list of `SearchQuery`. This SDK exposes no GET search method, so the issue's Search (GET) half has no surface to update here. The wire format is pinned by server-independent serialization tests. The integration test passes whether or not the Meilisearch instance has a personalization API key configured, since reranking cannot be exercised without one.
📝 WalkthroughWalkthroughAdds a ChangesPersonalized search
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Sequence Diagram(s)sequenceDiagram
participant Caller
participant SearchQuery
participant JsonSerializer
participant SearchEndpoint
Caller->>SearchQuery: set Personalize.UserContext
SearchQuery->>JsonSerializer: serialize query
JsonSerializer->>SearchEndpoint: send personalize.userContext
SearchEndpoint-->>Caller: return search results or feature_not_enabled
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Related issue
Fixes #737
What does this PR do?
Adds the experimental
personalizesearch parameter from Meilisearch 1.47.0. It is a newPersonalizeclass with a singleUserContextstring, exposed asSearchQuery.Personalize:This covers Search (POST). Search (GET) has no surface in this SDK: the only search call is the POST in
Index.Documents.cs, and there is no GET-based search method to update. Worth flagging for whoever adds one, the GET endpoint takes a flatpersonalizeUserContextstring rather than apersonalizeobject, so this class will not map onto it directly.Non-federated
/multi-searchpicks the parameter up without extra work, sinceMultiSearchQuery.Queriesis aList<SearchQuery>.Not included
Federated
/multi-searchneedsfederation.personalizeinstead. The server rejects per-querypersonalizewhen afederationobject is present, andFederatedMultiSearchQueryalways emits one, so federated personalization is currently unreachable from the SDK. I kept this PR scoped to the issue and left it out. Happy to open a separate PR for it if you want.Tests
Reranking needs a personalization API key on the instance, which neither
docker-compose.ymlnor CI sets, so the feature itself cannot run under test. Two things are covered instead:SearchQuerySerializationTestsasserts the request JSON directly, with no server involved.CustomSearchWithPersonalizesends a real request and passes whether or not a key is configured, so it will not start failing if CI ever gets one.All of the tests added here pass locally against Meilisearch 1.51.0.
PR checklist
Please check if your PR fulfills the following requirements:
AI tool disclosure
I used Claude Code to write the implementation and the tests, and to review the result. I verified the API shape by hand against a local Meilisearch 1.51.0 instance, including which error code comes back for each request shape, and I read through the whole diff before committing.
Summary by CodeRabbit
New Features
personalize.userContextformat for compatibility with the search API.Tests