Skip to content

feat: add personalize parameter to Index.search#1249

Open
tcferreira wants to merge 2 commits into
meilisearch:mainfrom
tcferreira:feat/document-personalize-search
Open

feat: add personalize parameter to Index.search#1249
tcferreira wants to merge 2 commits into
meilisearch:mainfrom
tcferreira:feat/document-personalize-search

Conversation

@tcferreira

@tcferreira tcferreira commented Jun 21, 2026

Copy link
Copy Markdown

Summary

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 — this documents it in the
search docstring alongside the other common options. Closes #1245.

Notes

  • The Python SDK passes search parameters straight through
    (body = {"q": query, **opt_params}), so no code change is required for
    personalize to be sent to Meilisearch.
  • Integration coverage for the experimental personalization feature needs it
    enabled on the test backend (via update_experimental_features) plus the
    matching 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.search method now accepts an explicit, typed personalize parameter (containing a userContext string) 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

  • Updated Index.search signature to include personalize: Optional[...] = None.
  • When provided, personalize is added to the POST request body (alongside existing q / opt_params).
  • Updated the Index.search docstring to document the experimental personalize option (Meilisearch >= v1.47.0).
  • Added test_search_serializes_personalize to assert "personalize" is present in the serialized request body.

Notes

This PR introduces functional SDK support (not only documentation) by wiring personalize into the request serialization and validating it with test coverage.

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
@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 977cb109-845c-479e-92d3-ce4da2aa7042

📥 Commits

Reviewing files that changed from the base of the PR and between ee5952f and d1b8fbf.

📒 Files selected for processing (2)
  • meilisearch/index.py
  • tests/index/test_index_search_meilisearch.py

📝 Walkthrough

Walkthrough

The Index.search method is extended to accept an optional personalize parameter. The method signature, docstring, and request payload handling are updated to support serialization of the personalize option in the POST body. A new test verifies that the parameter is correctly included in outgoing requests.

Changes

Personalize Parameter Support in Index.search

Layer / File(s) Summary
Personalize parameter signature and documentation
meilisearch/index.py
Method signature now accepts optional personalize: Optional[Dict[str, Any]] parameter. Docstring documents personalize as experimental and specifies Meilisearch >= v1.47 requirement.
Personalize parameter request serialization
meilisearch/index.py
Request payload builder conditionally inserts "personalize" field into the POST body when the parameter is not None.
Test personalize parameter serialization
tests/index/test_index_search_meilisearch.py
New test test_search_serializes_personalize mocks the HTTP POST call and verifies that index.search with personalize parameter includes it in the request body alongside the query parameter.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • #1245: [Meilisearch v1.47.0] Add personalized search (experimental) — This PR fully addresses the linked issue's objective by implementing personalize parameter support in Index.search (POST endpoint), adding the parameter to the method signature, updating request serialization, and providing test coverage.

Poem

A bunny springs forth with a feature so keen,
The personalize parameter is now on the scene!
From signature to payload, the path is quite clear,
With tests to confirm what the users will hear. 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR adds personalize parameter to Index.search (POST endpoint) with proper typing and test coverage, addressing issue #1245. However, it does not update the GET search endpoint as required. Update the GET search endpoint to also support the personalize parameter to fully address the linked issue #1245 requirements.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a personalize parameter to the Index.search method.
Out of Scope Changes check ✅ Passed All changes are directly related to adding personalize parameter support to Index.search and its test coverage, staying within scope of the PR objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Strift Strift added the enhancement New feature or request label Jun 22, 2026

@Strift Strift left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @tcferreira thanks for this PR!

Please add

  • tests that pass personalize={"userContext": "..."} through Index.search and 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.
@tcferreira tcferreira changed the title docs: document the personalize search parameter feat: add personalize parameter to Index.search Jun 22, 2026
@tcferreira

Copy link
Copy Markdown
Author

Thanks @Strift! Addressed both points: personalize is now an explicit, typed parameter on Index.search (forwarded in the request body), and I added test_search_serializes_personalize asserting it ends up in the serialized body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Meilisearch v1.47.0] Add personalized search (experimental)

2 participants