meilisearch-python-sdk 4.7.1__tar.gz → 4.8.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of meilisearch-python-sdk might be problematic. Click here for more details.
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/.pre-commit-config.yaml +2 -2
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/PKG-INFO +1 -1
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/_client.py +103 -2
- meilisearch_python_sdk-4.8.0/meilisearch_python_sdk/_version.py +1 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/index.py +35 -2
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/models/search.py +2 -1
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/models/settings.py +11 -2
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/models/task.py +1 -1
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/pyproject.toml +11 -11
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/tests/test_async_documents.py +5 -5
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/tests/test_documents.py +7 -5
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/tests/test_index.py +15 -0
- meilisearch_python_sdk-4.8.0/tests/test_settings_models.py +17 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/uv.lock +326 -278
- meilisearch_python_sdk-4.7.1/meilisearch_python_sdk/_version.py +0 -1
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/.github/FUNDING.yml +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/.github/release-draft-template.yaml +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/.github/renovate.json5 +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/.github/workflows/docs_publish.yml +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/.github/workflows/nightly_testing.yml +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/.github/workflows/pypi_publish.yml +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/.github/workflows/release-drafter.yml +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/.github/workflows/testing.yml +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/.gitignore +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/CONTRIBUTING.md +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/LICENSE +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/README.md +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/assets/add_in_batches.png +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/assets/searches.png +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/benchmark/run_benchmark.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/codecov.yml +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/datasets/small_movies.json +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/docker-compose.https.yml +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/docker-compose.yml +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/docs/.nojekyll +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/docs/CNAME +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/docs/async_client_api.md +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/docs/async_index_api.md +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/docs/client_api.md +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/docs/css/custom.css +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/docs/decorators_api.md +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/docs/index.md +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/docs/index_api.md +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/docs/js/umami.js +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/docs/json_handler.md +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/docs/plugins.md +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/docs/pydantic.md +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/.gitignore +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/README.md +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/__init__.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/add_documents_decorator.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/add_documents_in_batches.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/async_add_documents_decorator.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/async_add_documents_in_batches.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/async_documents_and_search_results.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/async_search_tracker.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/async_update_settings.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/documents_and_search_results.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/fastapi_example.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/orjson_example.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/pyproject.toml +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/requirements.txt +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/search_tracker.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/tests/__init__.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/tests/conftest.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/tests/test_async_examples.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/tests/test_examples.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/ujson_example.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/examples/update_settings.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/justfile +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/__init__.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/_batch.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/_http_requests.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/_task.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/_utils.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/decorators.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/errors.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/json_handler.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/models/__init__.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/models/batch.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/models/client.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/models/documents.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/models/health.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/models/index.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/models/version.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/plugins.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/py.typed +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/types.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/mkdocs.yaml +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/tests/__init__.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/tests/conftest.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/tests/test_async_client.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/tests/test_async_index.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/tests/test_async_index_plugins.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/tests/test_async_search.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/tests/test_client.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/tests/test_decorators.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/tests/test_errors.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/tests/test_index_plugins.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/tests/test_search.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/tests/test_utils.py +0 -0
- {meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/tests/test_version.py +0 -0
|
@@ -9,12 +9,12 @@ repos:
|
|
|
9
9
|
- id: end-of-file-fixer
|
|
10
10
|
- id: trailing-whitespace
|
|
11
11
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
12
|
-
rev: v1.
|
|
12
|
+
rev: v1.17.0
|
|
13
13
|
hooks:
|
|
14
14
|
- id: mypy
|
|
15
15
|
additional_dependencies: [pydantic, orjson, types-aiofiles, types-ujson]
|
|
16
16
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
17
|
-
rev: v0.
|
|
17
|
+
rev: v0.12.5
|
|
18
18
|
hooks:
|
|
19
19
|
- id: ruff-check
|
|
20
20
|
args: [--fix, --exit-non-zero-on-fix]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: meilisearch-python-sdk
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.8.0
|
|
4
4
|
Summary: A Python client providing both async and sync support for the Meilisearch API
|
|
5
5
|
Project-URL: repository, https://github.com/sanders41/meilisearch-python-sdk
|
|
6
6
|
Project-URL: homepage, https://github.com/sanders41/meilisearch-python-sdk
|
{meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/_client.py
RENAMED
|
@@ -689,6 +689,9 @@ class AsyncClient(BaseClient):
|
|
|
689
689
|
del q["limit"]
|
|
690
690
|
del q["offset"]
|
|
691
691
|
|
|
692
|
+
if query.media is None:
|
|
693
|
+
del q["media"]
|
|
694
|
+
|
|
692
695
|
processed_queries.append(q)
|
|
693
696
|
|
|
694
697
|
if federation:
|
|
@@ -1058,7 +1061,7 @@ class AsyncClient(BaseClient):
|
|
|
1058
1061
|
|
|
1059
1062
|
Examples
|
|
1060
1063
|
>>> from meilisearch_python_sdk import AsyncClient
|
|
1061
|
-
>>>
|
|
1064
|
+
>>> documents = [
|
|
1062
1065
|
>>> {"id": 1, "title": "Movie 1", "genre": "comedy"},
|
|
1063
1066
|
>>> {"id": 2, "title": "Movie 2", "genre": "drama"},
|
|
1064
1067
|
>>> ]
|
|
@@ -1075,6 +1078,56 @@ class AsyncClient(BaseClient):
|
|
|
1075
1078
|
raise_for_status=raise_for_status,
|
|
1076
1079
|
)
|
|
1077
1080
|
|
|
1081
|
+
# No cover because it requires multiple instances of Meilisearch
|
|
1082
|
+
async def transfer_documents( # pragma: no cover
|
|
1083
|
+
self,
|
|
1084
|
+
url: str,
|
|
1085
|
+
*,
|
|
1086
|
+
api_key: str | None = None,
|
|
1087
|
+
payload_size: str | None = None,
|
|
1088
|
+
indexes: JsonMapping | None = None,
|
|
1089
|
+
) -> TaskInfo:
|
|
1090
|
+
"""Transfer settings and documents from one Meilisearch instance to another.
|
|
1091
|
+
|
|
1092
|
+
Args:
|
|
1093
|
+
url: Where to send our settings and documents.
|
|
1094
|
+
api_key: The API key with the rights to send the requests. Usually the master key of
|
|
1095
|
+
the remote machine. Defaults to None.
|
|
1096
|
+
payload_size: Human readable size defining the size of the payloads to send. Defaults
|
|
1097
|
+
to 50 MiB.
|
|
1098
|
+
indexes: A set of patterns of matching the indexes you want to export. Defaults to all
|
|
1099
|
+
indexes without filter.
|
|
1100
|
+
|
|
1101
|
+
Returns:
|
|
1102
|
+
The details of the task.
|
|
1103
|
+
|
|
1104
|
+
Raises:
|
|
1105
|
+
MeilisearchCommunicationError: If there was an error communicating with the server.
|
|
1106
|
+
MeilisearchApiError: If the Meilisearch API returned an error.
|
|
1107
|
+
MeilisearchTimeoutError: If the connection times out.
|
|
1108
|
+
|
|
1109
|
+
Examples
|
|
1110
|
+
>>> from meilisearch_python_sdk import AsyncClient
|
|
1111
|
+
>>> async with Client("http://localhost.com", "masterKey") as client:
|
|
1112
|
+
>>> await index.transfer_documents(
|
|
1113
|
+
>>> "https://another-instance.com", api_key="otherMasterKey"
|
|
1114
|
+
>>> )
|
|
1115
|
+
"""
|
|
1116
|
+
payload: JsonDict = {"url": url}
|
|
1117
|
+
|
|
1118
|
+
if api_key:
|
|
1119
|
+
payload["apiKey"] = api_key
|
|
1120
|
+
|
|
1121
|
+
if payload:
|
|
1122
|
+
payload["payloadSize"] = payload_size
|
|
1123
|
+
|
|
1124
|
+
if indexes:
|
|
1125
|
+
payload["indexes"] = indexes
|
|
1126
|
+
|
|
1127
|
+
response = await self._http_requests.post(url, body=payload)
|
|
1128
|
+
|
|
1129
|
+
return TaskInfo(**response.json())
|
|
1130
|
+
|
|
1078
1131
|
|
|
1079
1132
|
class Client(BaseClient):
|
|
1080
1133
|
"""client to connect to the Meilisearch API."""
|
|
@@ -1968,7 +2021,7 @@ class Client(BaseClient):
|
|
|
1968
2021
|
|
|
1969
2022
|
Examples
|
|
1970
2023
|
>>> from meilisearch_python_sdk import Client
|
|
1971
|
-
>>>
|
|
2024
|
+
>>> documents = [
|
|
1972
2025
|
>>> {"id": 1, "title": "Movie 1", "genre": "comedy"},
|
|
1973
2026
|
>>> {"id": 2, "title": "Movie 2", "genre": "drama"},
|
|
1974
2027
|
>>> ]
|
|
@@ -1985,6 +2038,54 @@ class Client(BaseClient):
|
|
|
1985
2038
|
raise_for_status=raise_for_status,
|
|
1986
2039
|
)
|
|
1987
2040
|
|
|
2041
|
+
# No cover because it requires multiple instances of Meilisearch
|
|
2042
|
+
def transfer_documents( # pragma: no cover
|
|
2043
|
+
self,
|
|
2044
|
+
url: str,
|
|
2045
|
+
*,
|
|
2046
|
+
api_key: str | None = None,
|
|
2047
|
+
payload_size: str | None = None,
|
|
2048
|
+
indexes: JsonMapping | None = None,
|
|
2049
|
+
) -> TaskInfo:
|
|
2050
|
+
"""Transfer settings and documents from one Meilisearch instance to another.
|
|
2051
|
+
|
|
2052
|
+
Args:
|
|
2053
|
+
url: Where to send our settings and documents.
|
|
2054
|
+
api_key: The API key with the rights to send the requests. Usually the master key of
|
|
2055
|
+
the remote machine. Defaults to None.
|
|
2056
|
+
payload_size: Human readable size defining the size of the payloads to send. Defaults
|
|
2057
|
+
to 50 MiB.
|
|
2058
|
+
indexes: A set of patterns of matching the indexes you want to export. Defaults to all
|
|
2059
|
+
indexes without filter.
|
|
2060
|
+
|
|
2061
|
+
Returns:
|
|
2062
|
+
The details of the task.
|
|
2063
|
+
|
|
2064
|
+
Raises:
|
|
2065
|
+
MeilisearchCommunicationError: If there was an error communicating with the server.
|
|
2066
|
+
MeilisearchApiError: If the Meilisearch API returned an error.
|
|
2067
|
+
MeilisearchTimeoutError: If the connection times out.
|
|
2068
|
+
|
|
2069
|
+
Examples
|
|
2070
|
+
>>> from meilisearch_python_sdk import Client
|
|
2071
|
+
>>> client = Client("http://localhost.com", "masterKey")
|
|
2072
|
+
>>> index.transfer_documents("https://another-instance.com", api_key="otherMasterKey")
|
|
2073
|
+
"""
|
|
2074
|
+
payload: JsonDict = {"url": url}
|
|
2075
|
+
|
|
2076
|
+
if api_key:
|
|
2077
|
+
payload["apiKey"] = api_key
|
|
2078
|
+
|
|
2079
|
+
if payload:
|
|
2080
|
+
payload["payloadSize"] = payload_size
|
|
2081
|
+
|
|
2082
|
+
if indexes:
|
|
2083
|
+
payload["indexes"] = indexes
|
|
2084
|
+
|
|
2085
|
+
response = self._http_requests.post(url, body=payload)
|
|
2086
|
+
|
|
2087
|
+
return TaskInfo(**response.json())
|
|
2088
|
+
|
|
1988
2089
|
|
|
1989
2090
|
def _build_offset_limit_url(base: str, offset: int | None, limit: int | None) -> str:
|
|
1990
2091
|
if offset is not None and limit is not None:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = "4.8.0"
|
{meilisearch_python_sdk-4.7.1 → meilisearch_python_sdk-4.8.0}/meilisearch_python_sdk/index.py
RENAMED
|
@@ -725,6 +725,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
725
725
|
hybrid: Hybrid | None = None,
|
|
726
726
|
locales: list[str] | None = None,
|
|
727
727
|
retrieve_vectors: bool | None = None,
|
|
728
|
+
media: JsonMapping | None = None,
|
|
728
729
|
) -> SearchResults:
|
|
729
730
|
"""Search the index.
|
|
730
731
|
|
|
@@ -786,6 +787,13 @@ class AsyncIndex(_BaseIndex):
|
|
|
786
787
|
locales: Specifies the languages for the search. This parameter can only be used with
|
|
787
788
|
Milisearch >= v1.10.0. Defaults to None letting the Meilisearch pick.
|
|
788
789
|
retrieve_vectors: Return document vector data with search result.
|
|
790
|
+
media: The content of media is used as if it were a document to generate request
|
|
791
|
+
fragments from the searchFragments parameter. Defaults to None. This parameter can
|
|
792
|
+
only be used with Meilisearch >= v1.16.0. In order to use this feature in
|
|
793
|
+
Meilisearch v1.16.0 you first need to enable the feature by sending a PATCH request
|
|
794
|
+
to /experimental-features with { "multimodal": true }. Because this feature is
|
|
795
|
+
experimental it may be removed or updated causing breaking changes in this library
|
|
796
|
+
without a major version bump so use with caution.
|
|
789
797
|
|
|
790
798
|
Returns:
|
|
791
799
|
Results of the search
|
|
@@ -830,6 +838,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
830
838
|
ranking_score_threshold=ranking_score_threshold,
|
|
831
839
|
locales=locales,
|
|
832
840
|
retrieve_vectors=retrieve_vectors,
|
|
841
|
+
media=media,
|
|
833
842
|
)
|
|
834
843
|
search_url = f"{self._base_url_with_uid}/search"
|
|
835
844
|
|
|
@@ -1349,6 +1358,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
1349
1358
|
fields: list[str] | None = None,
|
|
1350
1359
|
filter: Filter | None = None,
|
|
1351
1360
|
retrieve_vectors: bool = False,
|
|
1361
|
+
sort: str | None = None,
|
|
1352
1362
|
) -> DocumentsInfo:
|
|
1353
1363
|
"""Get a batch documents from the index.
|
|
1354
1364
|
|
|
@@ -1362,6 +1372,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
1362
1372
|
retrieve_vectors: If set to True the vectors will be returned with each document.
|
|
1363
1373
|
Defaults to False. Note: This parameter can only be
|
|
1364
1374
|
used with Meilisearch >= v1.13.0
|
|
1375
|
+
sort: Attribute by which to sort the results. Defaults to None.
|
|
1365
1376
|
|
|
1366
1377
|
Returns:
|
|
1367
1378
|
Documents info.
|
|
@@ -1382,6 +1393,9 @@ class AsyncIndex(_BaseIndex):
|
|
|
1382
1393
|
"limit": limit,
|
|
1383
1394
|
}
|
|
1384
1395
|
|
|
1396
|
+
if sort:
|
|
1397
|
+
parameters["sort"] = sort
|
|
1398
|
+
|
|
1385
1399
|
if retrieve_vectors:
|
|
1386
1400
|
parameters["retrieveVectors"] = "true"
|
|
1387
1401
|
|
|
@@ -5151,6 +5165,7 @@ class Index(_BaseIndex):
|
|
|
5151
5165
|
hybrid: Hybrid | None = None,
|
|
5152
5166
|
locales: list[str] | None = None,
|
|
5153
5167
|
retrieve_vectors: bool | None = None,
|
|
5168
|
+
media: JsonMapping | None = None,
|
|
5154
5169
|
) -> SearchResults:
|
|
5155
5170
|
"""Search the index.
|
|
5156
5171
|
|
|
@@ -5212,6 +5227,13 @@ class Index(_BaseIndex):
|
|
|
5212
5227
|
locales: Specifies the languages for the search. This parameter can only be used with
|
|
5213
5228
|
Milisearch >= v1.10.0. Defaults to None letting the Meilisearch pick.
|
|
5214
5229
|
retrieve_vectors: Return document vector data with search result.
|
|
5230
|
+
media: The content of media is used as if it were a document to generate request
|
|
5231
|
+
fragments from the searchFragments parameter. Defaults to None. This parameter can
|
|
5232
|
+
only be used with Meilisearch >= v1.16.0. In order to use this feature in
|
|
5233
|
+
Meilisearch v1.16.0 you first need to enable the feature by sending a PATCH request
|
|
5234
|
+
to /experimental-features with { "multimodal": true }. Because this feature is
|
|
5235
|
+
experimental it may be removed or updated causing breaking changes in this library
|
|
5236
|
+
without a major version bump so use with caution.
|
|
5215
5237
|
|
|
5216
5238
|
Returns:
|
|
5217
5239
|
Results of the search
|
|
@@ -5256,6 +5278,7 @@ class Index(_BaseIndex):
|
|
|
5256
5278
|
ranking_score_threshold=ranking_score_threshold,
|
|
5257
5279
|
locales=locales,
|
|
5258
5280
|
retrieve_vectors=retrieve_vectors,
|
|
5281
|
+
media=media,
|
|
5259
5282
|
)
|
|
5260
5283
|
|
|
5261
5284
|
if self._pre_search_plugins:
|
|
@@ -5584,6 +5607,7 @@ class Index(_BaseIndex):
|
|
|
5584
5607
|
fields: list[str] | None = None,
|
|
5585
5608
|
filter: Filter | None = None,
|
|
5586
5609
|
retrieve_vectors: bool = False,
|
|
5610
|
+
sort: str | None = None,
|
|
5587
5611
|
) -> DocumentsInfo:
|
|
5588
5612
|
"""Get a batch documents from the index.
|
|
5589
5613
|
|
|
@@ -5597,6 +5621,7 @@ class Index(_BaseIndex):
|
|
|
5597
5621
|
retrieve_vectors: If set to True the vectors will be returned with each document.
|
|
5598
5622
|
Defaults to False. Note: This parameter can only be
|
|
5599
5623
|
used with Meilisearch >= v1.13.0
|
|
5624
|
+
sort: Attribute by which to sort the results. Defaults to None.
|
|
5600
5625
|
|
|
5601
5626
|
Returns:
|
|
5602
5627
|
Documents info.
|
|
@@ -5617,6 +5642,9 @@ class Index(_BaseIndex):
|
|
|
5617
5642
|
"limit": limit,
|
|
5618
5643
|
}
|
|
5619
5644
|
|
|
5645
|
+
if sort:
|
|
5646
|
+
parameters["sort"] = sort
|
|
5647
|
+
|
|
5620
5648
|
if retrieve_vectors:
|
|
5621
5649
|
parameters["retrieveVectors"] = "true"
|
|
5622
5650
|
|
|
@@ -5633,6 +5661,7 @@ class Index(_BaseIndex):
|
|
|
5633
5661
|
parameters["fields"] = fields
|
|
5634
5662
|
|
|
5635
5663
|
parameters["filter"] = filter
|
|
5664
|
+
|
|
5636
5665
|
response = self._http_requests.post(f"{self._documents_url}/fetch", body=parameters)
|
|
5637
5666
|
|
|
5638
5667
|
return DocumentsInfo(**response.json())
|
|
@@ -8261,7 +8290,7 @@ async def _async_load_documents_from_file(
|
|
|
8261
8290
|
and not csv_delimiter.isascii()
|
|
8262
8291
|
):
|
|
8263
8292
|
raise ValueError("csv_delimiter must be a single ascii character")
|
|
8264
|
-
with open(file_path) as f: # noqa:
|
|
8293
|
+
with open(file_path) as f: # noqa: ASYNC230
|
|
8265
8294
|
if csv_delimiter:
|
|
8266
8295
|
documents = await loop.run_in_executor(
|
|
8267
8296
|
None, partial(DictReader, f, delimiter=csv_delimiter)
|
|
@@ -8271,7 +8300,7 @@ async def _async_load_documents_from_file(
|
|
|
8271
8300
|
return list(documents)
|
|
8272
8301
|
|
|
8273
8302
|
if file_path.suffix == ".ndjson":
|
|
8274
|
-
with open(file_path) as f: # noqa:
|
|
8303
|
+
with open(file_path) as f: # noqa: ASYNC230
|
|
8275
8304
|
return [await loop.run_in_executor(None, partial(json_handler.loads, x)) for x in f]
|
|
8276
8305
|
|
|
8277
8306
|
async with aiofiles.open(file_path) as f: # type: ignore
|
|
@@ -8390,6 +8419,7 @@ def _process_search_parameters(
|
|
|
8390
8419
|
locales: list[str] | None = None,
|
|
8391
8420
|
retrieve_vectors: bool | None = None,
|
|
8392
8421
|
exhaustive_facet_count: bool | None = None,
|
|
8422
|
+
media: JsonMapping | None = None,
|
|
8393
8423
|
) -> JsonDict:
|
|
8394
8424
|
if attributes_to_retrieve is None:
|
|
8395
8425
|
attributes_to_retrieve = ["*"]
|
|
@@ -8444,6 +8474,9 @@ def _process_search_parameters(
|
|
|
8444
8474
|
if exhaustive_facet_count is not None:
|
|
8445
8475
|
body["exhaustivefacetCount"] = exhaustive_facet_count
|
|
8446
8476
|
|
|
8477
|
+
if media is not None:
|
|
8478
|
+
body["media"] = media
|
|
8479
|
+
|
|
8447
8480
|
return body
|
|
8448
8481
|
|
|
8449
8482
|
|
|
@@ -6,7 +6,7 @@ from camel_converter.pydantic_base import CamelBase
|
|
|
6
6
|
from pydantic import Field, field_validator
|
|
7
7
|
|
|
8
8
|
from meilisearch_python_sdk.errors import MeilisearchError
|
|
9
|
-
from meilisearch_python_sdk.types import Filter, JsonDict
|
|
9
|
+
from meilisearch_python_sdk.types import Filter, JsonDict, JsonMapping
|
|
10
10
|
|
|
11
11
|
T = TypeVar("T")
|
|
12
12
|
|
|
@@ -71,6 +71,7 @@ class SearchParams(CamelBase):
|
|
|
71
71
|
hybrid: Hybrid | None = None
|
|
72
72
|
locales: list[str] | None = None
|
|
73
73
|
retrieve_vectors: bool | None = None
|
|
74
|
+
media: JsonMapping | None = None
|
|
74
75
|
|
|
75
76
|
@field_validator("ranking_score_threshold", mode="before") # type: ignore[attr-defined]
|
|
76
77
|
@classmethod
|
|
@@ -3,8 +3,8 @@ from __future__ import annotations
|
|
|
3
3
|
from enum import Enum
|
|
4
4
|
from typing import Literal
|
|
5
5
|
|
|
6
|
-
import pydantic
|
|
7
6
|
from camel_converter.pydantic_base import CamelBase
|
|
7
|
+
from pydantic import field_validator, model_validator
|
|
8
8
|
|
|
9
9
|
from meilisearch_python_sdk.types import JsonDict
|
|
10
10
|
|
|
@@ -26,7 +26,7 @@ class Faceting(CamelBase):
|
|
|
26
26
|
max_values_per_facet: int
|
|
27
27
|
sort_facet_values_by: dict[str, str] | None = None
|
|
28
28
|
|
|
29
|
-
@
|
|
29
|
+
@field_validator("sort_facet_values_by") # type: ignore[attr-defined]
|
|
30
30
|
@classmethod
|
|
31
31
|
def validate_facet_order(cls, v: dict[str, str] | None) -> dict[str, str] | None:
|
|
32
32
|
if not v: # pragma: no cover
|
|
@@ -96,6 +96,15 @@ class RestEmbedder(CamelBase):
|
|
|
96
96
|
request: JsonDict
|
|
97
97
|
response: JsonDict
|
|
98
98
|
binary_quantized: bool | None = None
|
|
99
|
+
indexing_fragments: JsonDict | None = None
|
|
100
|
+
search_fragment: JsonDict | None = None
|
|
101
|
+
|
|
102
|
+
@model_validator(mode="after")
|
|
103
|
+
def check_document_template(self) -> RestEmbedder:
|
|
104
|
+
if self.indexing_fragments is not None and self.document_template is not None:
|
|
105
|
+
raise ValueError("document_template must be None when indexing_fragments is set")
|
|
106
|
+
|
|
107
|
+
return self
|
|
99
108
|
|
|
100
109
|
|
|
101
110
|
class UserProvidedEmbedder(CamelBase):
|
|
@@ -41,20 +41,20 @@ all = ["orjson", "ujson"]
|
|
|
41
41
|
[dependency-groups]
|
|
42
42
|
dev = [
|
|
43
43
|
"mkdocs==1.6.1",
|
|
44
|
-
"mkdocs-material==9.6.
|
|
45
|
-
"mkdocstrings[python]==0.
|
|
46
|
-
"mypy[faster-cache]==1.
|
|
44
|
+
"mkdocs-material==9.6.16",
|
|
45
|
+
"mkdocstrings[python]==0.30.0",
|
|
46
|
+
"mypy[faster-cache]==1.17.1",
|
|
47
47
|
"pre-commit==4.2.0",
|
|
48
|
-
"pytest==8.4.
|
|
48
|
+
"pytest==8.4.1",
|
|
49
49
|
"pytest-cov==6.2.1",
|
|
50
|
-
"pytest-asyncio==1.
|
|
51
|
-
"pytest-xdist==3.
|
|
52
|
-
"ruff==0.
|
|
53
|
-
"types-aiofiles==24.1.0.
|
|
54
|
-
"typing-extensions==4.14.
|
|
50
|
+
"pytest-asyncio==1.1.0",
|
|
51
|
+
"pytest-xdist==3.8.0",
|
|
52
|
+
"ruff==0.12.7",
|
|
53
|
+
"types-aiofiles==24.1.0.20250801",
|
|
54
|
+
"typing-extensions==4.14.1",
|
|
55
55
|
"types-ujson==5.10.0.20250326",
|
|
56
|
-
"meilisearch==0.
|
|
57
|
-
"rich==14.
|
|
56
|
+
"meilisearch==0.36.0",
|
|
57
|
+
"rich==14.1.0",
|
|
58
58
|
]
|
|
59
59
|
|
|
60
60
|
[tool.hatch.version]
|
|
@@ -728,14 +728,14 @@ async def test_get_documents_populated(async_index_with_documents):
|
|
|
728
728
|
|
|
729
729
|
async def test_get_documents_offset_optional_params(async_index_with_documents):
|
|
730
730
|
index = await async_index_with_documents()
|
|
731
|
-
|
|
732
|
-
|
|
731
|
+
update_response = await index.update_sortable_attributes(["title"])
|
|
732
|
+
await async_wait_for_task(index.http_client, update_response.task_uid)
|
|
733
733
|
response_offset_limit = await index.get_documents(
|
|
734
|
-
limit=3, offset=1, fields=["title", "overview"]
|
|
734
|
+
limit=3, offset=1, fields=["title", "overview"], sort="title:asc"
|
|
735
735
|
)
|
|
736
|
+
|
|
736
737
|
assert len(response_offset_limit.results) == 3
|
|
737
|
-
assert
|
|
738
|
-
assert response_offset_limit.results[0]["overview"] == response.results[1]["overview"]
|
|
738
|
+
assert ["title", "overview"] == list(response_offset_limit.results[0].keys())
|
|
739
739
|
|
|
740
740
|
|
|
741
741
|
async def test_get_documents_filter(async_index_with_documents):
|
|
@@ -648,12 +648,14 @@ def test_get_documents_populated(index_with_documents):
|
|
|
648
648
|
|
|
649
649
|
def test_get_documents_offset_optional_params(index_with_documents):
|
|
650
650
|
index = index_with_documents()
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
response_offset_limit = index.get_documents(
|
|
651
|
+
update_response = index.update_sortable_attributes(["title"])
|
|
652
|
+
wait_for_task(index.http_client, update_response.task_uid)
|
|
653
|
+
response_offset_limit = index.get_documents(
|
|
654
|
+
limit=3, offset=1, fields=["title", "overview"], sort="title:asc"
|
|
655
|
+
)
|
|
656
|
+
|
|
654
657
|
assert len(response_offset_limit.results) == 3
|
|
655
|
-
assert
|
|
656
|
-
assert response_offset_limit.results[0]["overview"] == response.results[1]["overview"]
|
|
658
|
+
assert ["title", "overview"] == list(response_offset_limit.results[0].keys())
|
|
657
659
|
|
|
658
660
|
|
|
659
661
|
def test_get_documents_filter(index_with_documents):
|
|
@@ -4,6 +4,7 @@ from httpx import Response
|
|
|
4
4
|
from meilisearch_python_sdk._http_requests import HttpRequests
|
|
5
5
|
from meilisearch_python_sdk._task import wait_for_task
|
|
6
6
|
from meilisearch_python_sdk.errors import MeilisearchApiError
|
|
7
|
+
from meilisearch_python_sdk.index import _process_search_parameters
|
|
7
8
|
from meilisearch_python_sdk.models.settings import (
|
|
8
9
|
Embedders,
|
|
9
10
|
Faceting,
|
|
@@ -1007,3 +1008,17 @@ def test_reset_prefix_search_opt_out(empty_index):
|
|
|
1007
1008
|
result = index.get_settings()
|
|
1008
1009
|
|
|
1009
1010
|
assert result.prefix_search == "indexingTime"
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
def test_process_search_parameters_media():
|
|
1014
|
+
expected = {"test": "test"}
|
|
1015
|
+
result = _process_search_parameters(media=expected)
|
|
1016
|
+
|
|
1017
|
+
assert result.get("media") is not None
|
|
1018
|
+
assert result["media"] == expected
|
|
1019
|
+
|
|
1020
|
+
|
|
1021
|
+
def test_process_search_parameters_no_media():
|
|
1022
|
+
result = _process_search_parameters()
|
|
1023
|
+
|
|
1024
|
+
assert "media" not in result.keys()
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from meilisearch_python_sdk.models.settings import RestEmbedder
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_index_settings_with_document_template_error():
|
|
7
|
+
with pytest.raises(ValueError) as e:
|
|
8
|
+
RestEmbedder(
|
|
9
|
+
url="https://test.com",
|
|
10
|
+
dimensions=128,
|
|
11
|
+
document_template="test",
|
|
12
|
+
request={"test": "test"},
|
|
13
|
+
response={"test": "test"},
|
|
14
|
+
indexing_fragments={"test": "test"},
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
assert "document_template must be None when indexing_fragments is set" in str(e.value)
|