feat: add personalize parameter to Index.search#1249
Conversation
Meilisearch v1.47.0 adds experimental personalized search (a `personalize` object with a `userContext` string). `Index.search` forwards `opt_params` to the API as-is, so the parameter already works at runtime; document it alongside the other common search options. Closes meilisearch#1245
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe ChangesPersonalize Parameter Support in Index.search
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Strift
left a comment
There was a problem hiding this comment.
Hey @tcferreira thanks for this PR!
Please add
- tests that pass
personalize={"userContext": "..."}throughIndex.searchand assert it is serialized correctly in the request body - add explicit typed parameters in
Index.search(e.g.,personalize: Optional[Dict[str, Any]] = None)
Address review: expose `personalize` as an explicit, typed parameter on `Index.search` and forward it in the request body, instead of only documenting it as an `opt_params` key. Add a test asserting it is serialized correctly.
|
Thanks @Strift! Addressed both points: |
Summary
Meilisearch v1.47.0 adds experimental personalized search (a
personalizeobjectwith a
userContextstring).Index.searchforwardsopt_paramsto the APIas-is, so the parameter already works at runtime — this documents it in the
searchdocstring alongside the other common options. Closes #1245.Notes
(
body = {"q": query, **opt_params}), so no code change is required forpersonalizeto be sent to Meilisearch.enabled on the test backend (via
update_experimental_features) plus thematching setup; happy to add a test if you confirm the preferred fixture.
Summary
Adds support for Meilisearch v1.47.0’s experimental personalized search to the Python SDK. The
Index.searchmethod now accepts an explicit, typedpersonalizeparameter (containing auserContextstring) and forwards it to the Meilisearch API request body as"personalize". Documentation is updated accordingly, and a new unit test verifies the parameter is serialized in the outgoing request.Changes
Index.searchsignature to includepersonalize: Optional[...] = None.personalizeis added to the POST request body (alongside existingq/opt_params).Index.searchdocstring to document the experimentalpersonalizeoption (Meilisearch >= v1.47.0).test_search_serializes_personalizeto assert"personalize"is present in the serialized request body.Notes
This PR introduces functional SDK support (not only documentation) by wiring
personalizeinto the request serialization and validating it with test coverage.