Skip to content

Conversation

@awais786
Copy link
Contributor

@awais786 awais786 commented Nov 18, 2025

Add support for multi-modal search

#1134

Summary by CodeRabbit

  • New Features
    • Added experimental features management API to enable/disable multimodal search capabilities.
    • Introduced support for media and hybrid search parameters in search queries.
    • Extended embedder configuration with new fragment options for advanced search scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 18, 2025

Walkthrough

This PR introduces experimental features management to the Meilisearch Python client. New client methods enable retrieving, updating, enabling, and disabling experimental features like multimodal search. Configuration paths are expanded, REST embedder model fields for indexing and search fragments are added, and comprehensive test coverage validates the new functionality.

Changes

Cohort / File(s) Summary
Experimental Features API
meilisearch/client.py, meilisearch/config.py
Added four new client methods (get_experimental_features, update_experimental_features, enable_multimodal, disable_multimodal) to manage experimental features via HTTP delegation. Added experimental_features configuration path constant.
Embedder Model Extensions
meilisearch/models/embedders.py
Extended RestEmbedder class with two optional fields: indexing_fragments and search_fragments, both of type Optional[Dict[str, Dict[str, str]]].
Test Coverage and Samples
tests/client/test_experimental_features.py, .code-samples.meilisearch.yaml
Added new test module with five integration tests covering retrieval, updates, enabling, disabling, and multi-feature updates of experimental features. Added code sample demonstrating hybrid search with media parameters.

Sequence Diagram

sequenceDiagram
    participant Client
    participant HTTP Utilities
    participant Meilisearch API
    
    Note over Client: Experimental Features Management
    
    Client->>Client: get_experimental_features()
    Client->>HTTP Utilities: GET /experimental-features
    HTTP Utilities->>Meilisearch API: HTTP GET
    Meilisearch API-->>HTTP Utilities: feature settings dict
    HTTP Utilities-->>Client: return dict
    
    Client->>Client: update_experimental_features({features})
    Client->>HTTP Utilities: PATCH /experimental-features
    HTTP Utilities->>Meilisearch API: HTTP PATCH
    Meilisearch API-->>HTTP Utilities: updated features dict
    HTTP Utilities-->>Client: return dict
    
    Note over Client: Convenience methods delegate to update
    Client->>Client: enable_multimodal()
    Client->>Client: update_experimental_features({multimodal: true})
    
    Client->>Client: disable_multimodal()
    Client->>Client: update_experimental_features({multimodal: false})
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

The changes follow consistent, repetitive patterns with mostly additive modifications:

  • Four client methods exhibit uniform delegation to existing HTTP utilities
  • Test functions contain straightforward, similar assertions across all five tests
  • Configuration and model field additions are trivial constants and optional attributes
  • No complex logic flow changes or error handling pathways introduced

Possibly related PRs

  • meilisearch-python#1087: Directly related through modifications to meilisearch/models/embedders.py—this PR extends the RestEmbedder class with fragment configuration fields while the referenced PR involves core embedder model definitions.

Suggested labels

enhancement

Suggested reviewers

  • brunoocasali
  • sanders41

Poem

🐰 With whiskers twitched and code reviewed,
Experimental features now imbued!
Multimodal hops and fragments seek,
A Python client becomes more sleek. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Enable multi modal' directly addresses the main objective of the PR and aligns with the changes that add multimodal search support.
Docstring Coverage ✅ Passed Docstring coverage is 90.91% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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.

@Strift Strift linked an issue Nov 18, 2025 that may be closed by this pull request
3 tasks
@awais786 awais786 marked this pull request as ready for review November 21, 2025 14:43
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 (5)
meilisearch/client.py (4)

1000-1002: Enhance docstring to match established patterns.

The new methods should follow the comprehensive docstring format used throughout this file, including Parameters, Returns, and Raises sections. This improves maintainability and API documentation consistency.

Apply this diff to improve the docstring and type hint:

-    def get_experimental_features(self) -> dict:
-        """Get current experimental features settings."""
+    def get_experimental_features(self) -> Dict[str, Any]:
+        """Get current experimental features settings.
+
+        Returns
+        -------
+        features:
+            Dictionary containing the current experimental features configuration.
+
+        Raises
+        ------
+        MeilisearchApiError
+            An error containing details about why Meilisearch can't process your request. Meilisearch error codes are described here: https://www.meilisearch.com/docs/reference/errors/error_codes#meilisearch-errors
+        """
         return self.http.get(self.config.paths.experimental_features)

1004-1006: Enhance docstring and add parameter type hint.

The method should include a type hint for the features parameter and follow the comprehensive docstring format used throughout this file.

Apply this diff:

-    def update_experimental_features(self, features: dict) -> dict:
-        """Update experimental features settings."""
+    def update_experimental_features(self, features: Mapping[str, Any]) -> Dict[str, Any]:
+        """Update experimental features settings.
+
+        Parameters
+        ----------
+        features:
+            Dictionary containing experimental features to enable or disable (ex: {"multimodal": True}).
+
+        Returns
+        -------
+        features:
+            Dictionary containing the updated experimental features configuration.
+
+        Raises
+        ------
+        MeilisearchApiError
+            An error containing details about why Meilisearch can't process your request. Meilisearch error codes are described here: https://www.meilisearch.com/docs/reference/errors/error_codes#meilisearch-errors
+        """
         return self.http.patch(self.config.paths.experimental_features, body=features)

1008-1010: Enhance docstring to match established patterns.

The convenience method should include comprehensive documentation following the file's conventions.

Apply this diff:

-    def enable_multimodal(self) -> dict:
-        """Enable multimodal experimental feature."""
+    def enable_multimodal(self) -> Dict[str, Any]:
+        """Enable the multimodal experimental feature.
+
+        Returns
+        -------
+        features:
+            Dictionary containing the updated experimental features configuration.
+
+        Raises
+        ------
+        MeilisearchApiError
+            An error containing details about why Meilisearch can't process your request. Meilisearch error codes are described here: https://www.meilisearch.com/docs/reference/errors/error_codes#meilisearch-errors
+        """
         return self.update_experimental_features({"multimodal": True})

1012-1014: Enhance docstring to match established patterns.

The convenience method should include comprehensive documentation following the file's conventions.

Apply this diff:

-    def disable_multimodal(self) -> dict:
-        """Disable multimodal experimental feature."""
+    def disable_multimodal(self) -> Dict[str, Any]:
+        """Disable the multimodal experimental feature.
+
+        Returns
+        -------
+        features:
+            Dictionary containing the updated experimental features configuration.
+
+        Raises
+        ------
+        MeilisearchApiError
+            An error containing details about why Meilisearch can't process your request. Meilisearch error codes are described here: https://www.meilisearch.com/docs/reference/errors/error_codes#meilisearch-errors
+        """
         return self.update_experimental_features({"multimodal": False})
tests/client/test_experimental_features.py (1)

4-55: Consider adding test cleanup and error handling tests.

The tests modify global experimental features state but don't restore the original configuration afterward. This could affect other tests. Additionally, error handling paths are not covered.

Consider these improvements:

  1. Add cleanup to restore original state:
import pytest

@pytest.fixture
def cleanup_experimental_features(client):
    """Fixture to restore experimental features after test."""
    original_features = client.get_experimental_features()
    yield
    client.update_experimental_features(original_features)

def test_enable_multimodal(client, cleanup_experimental_features):
    """Test enabling multimodal experimental feature."""
    response = client.enable_multimodal()
    assert isinstance(response, dict)
    assert response.get("multimodal") is True
    
    # Verify it's enabled
    features = client.get_experimental_features()
    assert features.get("multimodal") is True
  1. Add error handling tests:
def test_update_experimental_features_with_invalid_feature(client):
    """Test updating with an invalid feature name."""
    # This behavior depends on the Meilisearch API - it may ignore unknown keys
    # or return an error. Verify the expected behavior.
    response = client.update_experimental_features({"invalid_feature": True})
    assert isinstance(response, dict)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fd4fff6 and 085e398.

📒 Files selected for processing (5)
  • .code-samples.meilisearch.yaml (1 hunks)
  • meilisearch/client.py (1 hunks)
  • meilisearch/config.py (1 hunks)
  • meilisearch/models/embedders.py (2 hunks)
  • tests/client/test_experimental_features.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
tests/client/test_experimental_features.py (3)
tests/conftest.py (1)
  • client (15-16)
meilisearch/client.py (4)
  • get_experimental_features (1000-1002)
  • update_experimental_features (1004-1006)
  • enable_multimodal (1008-1010)
  • disable_multimodal (1012-1014)
meilisearch/_httprequests.py (1)
  • get (95-96)
meilisearch/client.py (1)
meilisearch/_httprequests.py (2)
  • get (95-96)
  • patch (110-118)
🔇 Additional comments (3)
.code-samples.meilisearch.yaml (1)

766-779: Code sample effectively demonstrates multimodal search.

The new search_parameter_reference_media_1 example correctly illustrates hybrid search with media parameters. The syntax is accurate, formatting is consistent with surrounding examples, and the parameter combination (empty query with media and hybrid settings) properly showcases this feature.

Minor observations:

  • The embedder name "voyage" assumes it's a configured embedder; if not documented elsewhere, a clarifying comment could help users unfamiliar with available embedders.
  • The example is otherwise clear and complete.
meilisearch/config.py (1)

50-50: LGTM!

The new path constant follows the established pattern and naming convention consistently with other paths in the class.

meilisearch/models/embedders.py (1)

170-173: LGTM!

The new optional fields for multi-modal search are well-documented and appropriately typed. Using None as the default value maintains backward compatibility while extending the RestEmbedder API for fragment configuration.

Also applies to: 192-193

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