meilisearch-python-sdk 4.7.2__py3-none-any.whl → 4.9.0__py3-none-any.whl

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.

@@ -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
- >>> >>> documents = [
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
- >>> >>> documents = [
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:
@@ -1 +1 @@
1
- VERSION = "4.7.2"
1
+ VERSION = "4.9.0"
@@ -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())
@@ -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
@@ -94,6 +95,7 @@ class SearchResults(CamelBase, Generic[T]):
94
95
  page: int | None = None
95
96
  hits_per_page: int | None = None
96
97
  semantic_hit_count: int | None = None
98
+ query_vector: list[float] | None = None
97
99
 
98
100
 
99
101
  class SearchResultsWithUID(SearchResults, Generic[T]):
@@ -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
- @pydantic.field_validator("sort_facet_values_by") # type: ignore[attr-defined]
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):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meilisearch-python-sdk
3
- Version: 4.7.2
3
+ Version: 4.9.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
@@ -1,13 +1,13 @@
1
1
  meilisearch_python_sdk/__init__.py,sha256=SB0Jlm6FwT13J9xasZKseZzTWBk0hkfe1CWyWmIIZnE,258
2
2
  meilisearch_python_sdk/_batch.py,sha256=Hbt-M8Lt8ZDZqcKToUMzUd5zvT-gku709er4pRlvXWk,5065
3
- meilisearch_python_sdk/_client.py,sha256=KsQkSoZEAnXK2H0QWc-tOOczOAE8kuLUssxmd5j9dS4,77379
3
+ meilisearch_python_sdk/_client.py,sha256=bsGEST8aBJVMsul-RIKWutCAVjKh8Gx0ReCuwvSL7oA,81093
4
4
  meilisearch_python_sdk/_http_requests.py,sha256=O3M3n-t1jAKwccWowPbk-HPD3ExtHq8a3XhnZT5facs,6746
5
5
  meilisearch_python_sdk/_task.py,sha256=QgVcqMlZdURRS_oYpB_bTBa5dvT3Sp_-O0-s6TqAxHk,12485
6
6
  meilisearch_python_sdk/_utils.py,sha256=NoCDxJPhjABeuSxFTNCih585UDWdXEUBD_FvdgtScQw,1539
7
- meilisearch_python_sdk/_version.py,sha256=Zt3blf3grzBfdS51dr-gmLIruUhL0rGHx7IXjJqi54o,18
7
+ meilisearch_python_sdk/_version.py,sha256=bmQkTABtlbDMSgjET7LUES-O4ujaN2we_yeOqP1woIA,18
8
8
  meilisearch_python_sdk/decorators.py,sha256=njMn40P-qOzKGGQLCDpsBKWyj2ai10s4XG4IUBSHoD4,8674
9
9
  meilisearch_python_sdk/errors.py,sha256=RNNHXtXLBiCVZaLM2MeKKs9RbRuE-SLRttiPeVAEXgA,2133
10
- meilisearch_python_sdk/index.py,sha256=7yZV7wuGpY0h3n6670cedH4nTIRNzU124aVT-YyPlLY,347496
10
+ meilisearch_python_sdk/index.py,sha256=1hKuVPQPH1bpQ_3DrnihpypMZk5ZZok0-pU3RjO0Sfo,349340
11
11
  meilisearch_python_sdk/json_handler.py,sha256=c1rGKzYlE0dGfLygQjPqVUNfQkN1JvafBGmIx31JW8g,2044
12
12
  meilisearch_python_sdk/plugins.py,sha256=YySzTuVr4IrogTgrP8q-gZPsew8TwedopjWnTj5eV48,3607
13
13
  meilisearch_python_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -18,11 +18,11 @@ meilisearch_python_sdk/models/client.py,sha256=nefi6ViSaSd_mtopRAhM9tzzepwChFJUk
18
18
  meilisearch_python_sdk/models/documents.py,sha256=eT3FHrPND-g2IzNRyOHQApTTJ1WbFcGlqgxZ6aKrRgI,247
19
19
  meilisearch_python_sdk/models/health.py,sha256=hvruti7ylsk7bAh8RPOhTPcRrjx6MPgdkDFX9vZ5Qks,95
20
20
  meilisearch_python_sdk/models/index.py,sha256=WLQOi3_HChko134FkRU1H3_cJjhHJCFclcx4oDBlqHU,1228
21
- meilisearch_python_sdk/models/search.py,sha256=ZySZyA18QuJavz82gK7Kkqfp0fIxWVervCw24W6bToA,3487
22
- meilisearch_python_sdk/models/settings.py,sha256=inmP9PbjrgLVq0_9z3750Enhri3PX0lLj2HTLytWAt4,5323
21
+ meilisearch_python_sdk/models/search.py,sha256=U3ph1GW9Xkbw33pIlGDa7rlTGsdvqahjRJjPxUou8n8,3581
22
+ meilisearch_python_sdk/models/settings.py,sha256=3UdJWbrXfTrwvzu3Gq-aY1fDmAejysSz7yRQ-7yXCwQ,5736
23
23
  meilisearch_python_sdk/models/task.py,sha256=JVYF46ylD-XwqVVNq2offhLOkljaGxPyRVuF6PwLOBU,2174
24
24
  meilisearch_python_sdk/models/version.py,sha256=YDu-aj5H-d6nSaWRTXzlwWghmZAoiknaw250UyEd48I,215
25
- meilisearch_python_sdk-4.7.2.dist-info/METADATA,sha256=N_ZlULj05-wdmIV9GvxoS8Z5jvZp94HFOs0m3-s8jiA,9763
26
- meilisearch_python_sdk-4.7.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
- meilisearch_python_sdk-4.7.2.dist-info/licenses/LICENSE,sha256=xVzevI1TrlKfM0plmJ7vfK1Muu0V9n-dGE8RnDrOFlM,1069
28
- meilisearch_python_sdk-4.7.2.dist-info/RECORD,,
25
+ meilisearch_python_sdk-4.9.0.dist-info/METADATA,sha256=eMfrNaOBiXcGZHYREUf0xUpS5oZjFbd9OjonqoqSQ_E,9763
26
+ meilisearch_python_sdk-4.9.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
+ meilisearch_python_sdk-4.9.0.dist-info/licenses/LICENSE,sha256=xVzevI1TrlKfM0plmJ7vfK1Muu0V9n-dGE8RnDrOFlM,1069
28
+ meilisearch_python_sdk-4.9.0.dist-info/RECORD,,