Skip to content

Conversation

@awais786
Copy link
Owner

@awais786 awais786 commented Nov 14, 2025

We want to update this SDK to allow using indexing and search fragments to enable multi-modal search. This feature is introduced in Meilisearch 1.16.

For more information, see the embedder settings API.

NB: As of Meilisearch 1.16, this feature is experimental. This might require updating the API related to experimental features.

Tasks

Update settings methods to allow configuring indexingFraments and searchFragments

Add new tests cases

Add code sample in .code-samples.meilisearch.yaml under the search_parameter_reference_media_1 key. The example should be similar to this CURL example

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces multimodal embedder support to the Meilisearch Python SDK, enabling AI-powered search with multiple data types (text, images, etc.). The changes include new fragment-based embedding configuration, a dedicated search method for media queries, experimental features API, and an index compaction feature.

  • Added indexing_fragments and search_fragments fields to RestEmbedder for multimodal document processing
  • Introduced search_with_media() method for performing searches using media parameters instead of text queries
  • Added experimental features API with get_experimental_features(), update_experimental_features(), enable_multimodal(), and disable_multimodal() methods
  • Implemented compact() method for triggering index compaction
  • Version bumped from 0.37.1 to 0.38.0

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/settings/test_settings_fragments.py Comprehensive test suite for fragment configuration in embedders, validating that indexingFragments and searchFragments can be configured without triggering AI calls
tests/settings/test_settings_embedders.py Updated timeout values for HuggingFace and composite embedder tests to accommodate longer model download times (60 seconds)
tests/index/test_index_search_media.py New test suite for the search_with_media method using mocked HTTP responses to validate parameter handling
tests/index/test_index.py Added test for the new compact() method that verifies document count preservation and indexing state
tests/client/test_client_experimental_features.py Complete test coverage for experimental features API including get, update, enable/disable, and idempotency tests
tests/conftest.py Added enable_multimodal fixture, mock_embedder_server fixture with HTTP server, and index_with_rest_embedder fixture for testing
meilisearch/models/embedders.py Extended RestEmbedder model with indexing_fragments and search_fragments fields for multimodal support
meilisearch/index.py Added search_with_media() method for media-based searches and compact() method for index compaction
meilisearch/config.py Added experimental_features path to Paths configuration
meilisearch/client.py Implemented experimental features management methods for enabling/disabling multimodal functionality
meilisearch/version.py Bumped version to 0.38.0 to reflect new features
.code-samples.meilisearch.yaml Added compact_index_1 code sample for documentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

update_an_index_1: |-
client.index('movies').update(primary_key='id')
compact_index_1: |-
client.index('movies').compact()
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The indentation of the code sample is inconsistent with other entries in this YAML file. The code should start with 2 spaces (like other entries) but it starts with 4 spaces. This should be:

compact_index_1: |-
  client.index('movies').compact()

instead of:

compact_index_1: |-
    client.index('movies').compact()
Suggested change
client.index('movies').compact()
client.index('movies').compact()

Copilot uses AI. Check for mistakes.
Comment on lines 56 to 57


Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

There are extra blank lines at the end of this file. The file should end with a single newline (line 56 is already blank), so lines 57-58 should be removed.

Suggested change

Copilot uses AI. Check for mistakes.

assert isinstance(response, dict)
assert "hits" in response
# This validates that SDK correctly sends media without requiring q parameter
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The comment on this line is incomplete. It starts with "# This validates that SDK correctly sends media without requiring q parameter" but appears to be cut off. Consider completing the comment or removing it if no additional explanation is needed.

Suggested change
# This validates that SDK correctly sends media without requiring q parameter
# This validates that the SDK correctly sends media without requiring the 'q' parameter.

Copilot uses AI. Check for mistakes.
Comment on lines 192 to 194
except Exception:
# If it fails, that's also acceptable as the feature might require enabling
pass
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The bare except Exception: clause at line 192 is too broad and could mask unexpected errors. Consider catching a specific exception type (e.g., MeilisearchApiError) or at least logging/asserting something about the exception to ensure the test is failing for the expected reason. The current implementation makes it impossible to distinguish between different failure modes.

Suggested change
except Exception:
# If it fails, that's also acceptable as the feature might require enabling
pass
except Exception as e:
# If it fails, that's also acceptable as the feature might require enabling
pytest.fail(f"Fragments configuration failed with exception: {e}")

Copilot uses AI. Check for mistakes.
Returns
-------
task_info: TaskInfo
Contains information to track the progress of the compaction task.
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The docstring for the compact method is missing a "Raises" section. Similar methods in this file (e.g., search, update_localized_attributes) document that they can raise MeilisearchApiError. For consistency and completeness, this method should also document potential exceptions:

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
Suggested change
Contains information to track the progress of the compaction task.
Contains information to track the progress of the compaction task.
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

Copilot uses AI. Check for mistakes.
Comment on lines 7 to 9
import pytest


Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

Import of 'pytest' is not used.

Suggested change
import pytest

Copilot uses AI. Check for mistakes.
"""
from http.server import HTTPServer, BaseHTTPRequestHandler
import threading
import json
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

This import of module json is redundant, as it was previously imported on line 2.

Suggested change
import json

Copilot uses AI. Check for mistakes.
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.

4 participants