Skip to content

feat: add personalized search (experimental) - #971

Open
GabrielBBaldez wants to merge 2 commits into
meilisearch:mainfrom
GabrielBBaldez:fix/personalized-search
Open

feat: add personalized search (experimental)#971
GabrielBBaldez wants to merge 2 commits into
meilisearch:mainfrom
GabrielBBaldez:fix/personalized-search

Conversation

@GabrielBBaldez

@GabrielBBaldez GabrielBBaldez commented Jun 16, 2026

Copy link
Copy Markdown

Adds support for the personalize search parameter introduced in Meilisearch 1.47.0. Closes #970.

  • New Personalize model (model/Personalize.java) with a userContext field, mirroring the existing Hybrid model (lombok builder + toJSONObject()).
  • SearchRequest and IndexSearchRequest now accept an optional personalize object and serialize it into the request body. IndexSearchRequest covers federated / multi-search, which 1.47.0 also supports per the issue note.
  • Unit tests in SearchRequestTest and IndexSearchRequestTest covering the serialization and getters.

Usage:

SearchRequest.builder()
    .q("...")
    .personalize(Personalize.builder().userContext("The user prefers ...").build())
    .build();

Note: the SDK performs search over POST (Search / Index.search), so there is no separate GET search path in the client to update — personalize is added to the POST request body.

Summary by CodeRabbit

  • New Features

    • Added support for the optional personalize search parameter.
    • Search requests can now include a personalization context, such as a user context, through the builder API.
    • Personalization is supported for both standard and index-based search requests.
    • Personalization details are included in serialized search requests when provided.
  • Tests

    • Added coverage confirming personalization context is correctly included and accessible in search requests.

@coderabbitai

coderabbitai Bot commented Jun 16, 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 Plus

Run ID: 99cc664f-eea1-48a8-9182-4d50342d88d2

📥 Commits

Reviewing files that changed from the base of the PR and between 9139d4f and 2c3e2de.

📒 Files selected for processing (1)
  • src/main/java/com/meilisearch/sdk/SearchRequest.java

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

Introduces a Personalize model with a userContext field and JSON serialization. Adds an optional personalize field to SearchRequest and IndexSearchRequest. Tests verify serialized JSON and getter values.

Changes

Personalized Search Support

Layer / File(s) Summary
Personalize model and request integration
src/main/java/com/meilisearch/sdk/model/Personalize.java, src/main/java/com/meilisearch/sdk/SearchRequest.java, src/main/java/com/meilisearch/sdk/IndexSearchRequest.java
Adds Personalize with toJSONObject() and toString(). Both request classes serialize non-null personalize values.
Personalize serialization tests
src/test/java/com/meilisearch/sdk/SearchRequestTest.java, src/test/java/com/meilisearch/sdk/IndexSearchRequestTest.java
Builds requests with Personalize, parses the JSON output, and checks userContext and getter values.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 2c3e2

This is a localized search API addition with request serialization coverage; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant SearchRequest
  participant Personalize
  Caller->>SearchRequest: Build request with personalize
  SearchRequest->>Personalize: toJSONObject()
  Personalize-->>SearchRequest: JSON object with userContext
  SearchRequest-->>Caller: Serialized request JSON
Loading

Poem

A rabbit adds context to the search request,
Personalize keeps the JSON shape correct,
SearchRequest carries the new field,
IndexSearchRequest carries it as well,
Tests check the context in place,
The request hops forward with grace.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 identifies the primary change: adding experimental personalized search support.
Linked Issues check ✅ Passed The changes satisfy issue #970 by adding the Personalize model, supporting userContext serialization in SearchRequest and IndexSearchRequest, covering federated search request serialization, and addin…
Out of Scope Changes check ✅ Passed All production and test changes directly support personalized search and the requirements in issue #970. No unrelated changes are identified.
Full details: Linked Issues check

Explanation

The changes satisfy issue #970 by adding the Personalize model, supporting userContext serialization in SearchRequest and IndexSearchRequest, covering federated search request serialization, and adding unit tests. The provided context states that the SDK has no separate GET search path to update.

✨ 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.

@Strift Strift added the enhancement New feature or request label Jun 18, 2026
SearchRequest gained showPerformanceDetails on main while this branch added
personalize; both fields belong and both are serialized in toJSONObject.
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