Skip to content

Conversation

kumarUjjawal
Copy link
Contributor

@kumarUjjawal kumarUjjawal commented Sep 30, 2025

Pull Request

Related issue

Fixes #698

What does this PR do?

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Summary by CodeRabbit

  • New Features

    • Search queries can now include media data for multimodal retrieval.
    • Added an experimental toggle to enable multimodal capabilities.
    • Embedders now support fragment configurations for indexing and search, enabling multimodal embeddings.
  • Documentation

    • Added a code sample demonstrating a search request that includes media alongside hybrid retrieval.
    • Updated example text in the embedders template for clarity.

Copy link
Contributor

coderabbitai bot commented Sep 30, 2025

Walkthrough

Adds multimodal support across the SDK: new experimental feature flag, search query media payload, and embedder fragment settings for indexing and search. Updates code samples to demonstrate media usage and adjusts a sample template. Includes constructors/builders, serialization, and tests for new fields.

Changes

Cohort / File(s) Summary of changes
Experimental features: multimodal flag
src/features.rs
Adds multimodal to ExperimentalFeaturesResult (serde default), optional multimodal to ExperimentalFeatures, initializes in new, and a set_multimodal(bool) builder; tests updated.
Search query: media support
src/search.rs
Adds media: Option<Value> to SearchQuery, initializes in new, and builder with_media(Value) to attach media to search requests.
Embedder fragments (indexing/search)
src/settings.rs
Introduces EmbedderFragment { value: serde_json::Value }; adds indexing_fragments and search_fragments to Embedder (optional HashMap). Serialization updated; tests added to assert indexingFragments and searchFragments.
Docs / Samples update
.code-samples.meilisearch.yaml
Adds search_parameter_reference_media_1 example using with_media(json!(...)); minor text tweak in update_embedders_1 document template.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as Client App
  participant SDK as SDK (this repo)
  participant MS as Meilisearch Server

  rect rgba(230,240,255,0.6)
    note over SDK: Settings update with fragments
    App->>SDK: Embedder{ indexingFragments, searchFragments }
    SDK->>MS: PUT /indexes/:uid/settings/embedders (JSON with fragments)
    MS-->>SDK: 200 Accepted/Task
    SDK-->>App: Task info
  end

  rect rgba(230,255,230,0.6)
    note over SDK: Enable experimental multimodal
    App->>SDK: ExperimentalFeatures.set_multimodal(true)
    SDK->>MS: PATCH /experimental-features { multimodal: true }
    MS-->>SDK: { multimodal: true, ... }
    SDK-->>App: ExperimentalFeaturesResult
  end

  rect rgba(255,245,230,0.6)
    note over SDK: Search with media payload
    App->>SDK: SearchQuery.with_media(Value)
    SDK->>MS: POST /indexes/:uid/search { media: {...}, ... }
    MS-->>SDK: Search results
    SDK-->>App: Results
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • irevoire
  • curquiza

Poem

I thump the keys with whiskered pride,
Fragments filed, media allied.
Multimodal moonlight, queries bloom,
Embeddings hum in sample’s room.
Hop, compile—features align;
Carrots of JSON, crisp and fine.
Shipping now—on rabbit time! 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title “Add support for multi-modal search” succinctly captures the primary functionality introduced by the changes. It directly aligns with modifications such as enabling media payloads in search queries, updating experimental feature flags, and extending embedder settings. The phrasing remains concise, clear, and easily understood by team members reviewing commit history.
Linked Issues Check ✅ Passed The pull request implements all coding objectives of issue #698 by updating the SDK’s settings API to support indexingFragments and searchFragments, adding corresponding EmbedderFragment tests, and including a new code sample under search_parameter_reference_media_1. It also incorporates experimental API adjustments by extending ExperimentalFeatures with a multimodal flag and adding media support in SearchQuery to fully enable multi-modal search. These changes satisfy the linked issue’s requirements for settings, tests, and documentation.
Out of Scope Changes Check ✅ Passed All modifications are directly related to enabling multi-modal search support in accordance with issue #698. The only other change is a minor textual update in a code sample template, which remains within the scope of illustrating the new feature. There are no unrelated or extraneous code alterations present in this pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (6)
src/search.rs (3)

411-414: Media field shape looks good; keep as optional.

Adds media: Option<Value> with proper serde skipping. Consider documenting expected JSON shape (object of fragments) since this is experimental.


703-707: Builder ergonomics: consider a fallible generic helper.

with_media(Value) is fine. Optionally add try_with_media<T: Serialize>(&self, media: &T) -> Result<&mut Self, serde_json::Error> or with_media_json<T: Serialize>(&mut self, media: T) to avoid requiring callers to pre-build Value.

+impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
+    /// Attach media fragments from any serializable structure.
+    pub fn with_media_json<'b, T: Serialize>(
+        &'b mut self,
+        media: T,
+    ) -> &'b mut SearchQuery<'a, Http> {
+        self.media = serde_json::to_value(media).ok();
+        self
+    }
+}

1110-1136: Serialization test is solid; add a negative case.

Great direct check that media serializes as expected. Consider an extra test asserting media is omitted when unset.

.code-samples.meilisearch.yaml (1)

1944-1957: New sample aligns with API additions.

Example shows .with_media(json!(...)) alongside hybrid search; this mirrors the new builder. Optionally preface with a note in docs that the multimodal experimental feature must be enabled.

src/settings.rs (2)

150-157: Embedder fragments exposed—API surface looks correct.

indexing_fragments and search_fragments as Option<HashMap<String, EmbedderFragment>> with camelCase serialization aligns with expected wire format. Consider adding brief docs stating these are experimental.


3157-3241: Good serialization coverage for fragments.

Test validates both indexingFragments and searchFragments, plus request/response. Consider also asserting a round‑trip from_value::<Embedder>(serialized) to catch deserialization regressions.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 910f9e9 and f72885d.

📒 Files selected for processing (4)
  • .code-samples.meilisearch.yaml (1 hunks)
  • src/features.rs (6 hunks)
  • src/search.rs (4 hunks)
  • src/settings.rs (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-12T13:28:23.700Z
Learnt from: LukasKalbertodt
PR: meilisearch/meilisearch-rust#625
File: src/search.rs:368-370
Timestamp: 2025-06-12T13:28:23.700Z
Learning: In the Meilisearch Rust client, `SearchQuery` serializes its per-query federation settings under the key `federationOptions`; only the top-level multi-search parameter is named `federation`.

Applied to files:

  • src/search.rs
🧬 Code graph analysis (1)
src/search.rs (2)
src/indexes.rs (26)
  • client (186-188)
  • client (232-234)
  • client (320-322)
  • client (376-378)
  • client (428-430)
  • client (473-475)
  • client (522-525)
  • client (556-558)
  • client (634-636)
  • client (700-702)
  • client (970-972)
  • client (1038-1040)
  • client (1089-1091)
  • client (1133-1135)
  • client (1186-1188)
  • client (1245-1247)
  • new (81-89)
  • new (1783-1790)
  • new (1994-2000)
  • index (2171-2171)
  • index (2188-2189)
  • index (2226-2226)
  • index (2298-2298)
  • index (2326-2326)
  • index (2352-2352)
  • index (2379-2379)
src/features.rs (1)
  • new (56-66)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: integration-tests
🔇 Additional comments (7)
src/settings.rs (2)

2815-2815: Import addition OK.

use serde_json::json; required for tests.


159-163: Struct matches Meilisearch 1.16 spec

The EmbedderFragment { value: serde_json::Value } definition correctly wraps each fragment’s payload under a "value" key as required by the server schema. No changes needed.

src/features.rs (5)

17-19: Backward-compatible result field.

multimodal: bool with #[serde(default)] avoids breaking on older servers.


50-52: Request knob for multimodal.

Optional multimodal field mirrors the response; consistent with existing flags.


64-65: Constructor default None—consistent.

Keeps updates explicit.


149-152: Setter reads cleanly.

set_multimodal matches existing builder style.


168-178: Test covers end-to-end toggle.

Verifies update + get for multimodal. Looks good.

Copy link

codecov bot commented Sep 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.14%. Comparing base (910f9e9) to head (f72885d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #712      +/-   ##
==========================================
+ Coverage   85.89%   86.14%   +0.24%     
==========================================
  Files          19       19              
  Lines        5950     6057     +107     
==========================================
+ Hits         5111     5218     +107     
  Misses        839      839              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v1.16.0] Add support for multi-modal search
1 participant