meilisearch-python-sdk 3.2.0__py3-none-any.whl → 3.4.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.

@@ -22,7 +22,12 @@ from meilisearch_python_sdk.models.client import (
22
22
  )
23
23
  from meilisearch_python_sdk.models.health import Health
24
24
  from meilisearch_python_sdk.models.index import IndexInfo
25
- from meilisearch_python_sdk.models.search import SearchParams, SearchResultsWithUID
25
+ from meilisearch_python_sdk.models.search import (
26
+ Federation,
27
+ SearchParams,
28
+ SearchResultsFederated,
29
+ SearchResultsWithUID,
30
+ )
26
31
  from meilisearch_python_sdk.models.settings import MeilisearchSettings
27
32
  from meilisearch_python_sdk.models.task import TaskInfo, TaskResult, TaskStatus
28
33
  from meilisearch_python_sdk.models.version import Version
@@ -145,6 +150,7 @@ class AsyncClient(BaseClient):
145
150
  verify: str | bool | SSLContext = True,
146
151
  custom_headers: dict[str, str] | None = None,
147
152
  json_handler: BuiltinHandler | OrjsonHandler | UjsonHandler | None = None,
153
+ http2: bool = False,
148
154
  ) -> None:
149
155
  """Class initializer.
150
156
 
@@ -163,11 +169,12 @@ class AsyncClient(BaseClient):
163
169
  (uses the json module from the standard library), OrjsonHandler (uses orjson), or
164
170
  UjsonHandler (uses ujson). Note that in order use orjson or ujson the corresponding
165
171
  extra needs to be included. Default: BuiltinHandler.
172
+ http2: Whether or not to use HTTP/2. Defaults to False.
166
173
  """
167
174
  super().__init__(api_key, custom_headers, json_handler)
168
175
 
169
176
  self.http_client = HttpxAsyncClient(
170
- base_url=url, timeout=timeout, headers=self._headers, verify=verify
177
+ base_url=url, timeout=timeout, headers=self._headers, verify=verify, http2=http2
171
178
  )
172
179
  self._http_requests = AsyncHttpRequests(self.http_client, json_handler=self.json_handler)
173
180
 
@@ -633,13 +640,20 @@ class AsyncClient(BaseClient):
633
640
  return Key(**response.json())
634
641
 
635
642
  async def multi_search(
636
- self, queries: list[SearchParams], *, hits_type: Any = JsonDict
637
- ) -> list[SearchResultsWithUID]:
643
+ self,
644
+ queries: list[SearchParams],
645
+ *,
646
+ federation: Federation | None = None,
647
+ hits_type: Any = JsonDict,
648
+ ) -> list[SearchResultsWithUID] | SearchResultsFederated:
638
649
  """Multi-index search.
639
650
 
640
651
  Args:
641
652
 
642
653
  queries: List of SearchParameters
654
+ federation: If included a single search result with hits built from all queries will
655
+ be returned. This parameter can only be used with Meilisearch >= v1.10.0. Defaults
656
+ to None.
643
657
  hits_type: Allows for a custom type to be passed to use for hits. Defaults to
644
658
  JsonDict
645
659
 
@@ -664,11 +678,28 @@ class AsyncClient(BaseClient):
664
678
  >>> search_results = await client.search(queries)
665
679
  """
666
680
  url = "multi-search"
681
+ if federation:
682
+ processed_queries = []
683
+ for query in queries:
684
+ q = query.model_dump(by_alias=True)
685
+ del q["limit"]
686
+ del q["offset"]
687
+ processed_queries.append(q)
688
+ else:
689
+ processed_queries = [x.model_dump(by_alias=True) for x in queries]
690
+
667
691
  response = await self._http_requests.post(
668
692
  url,
669
- body={"queries": [x.model_dump(by_alias=True) for x in queries]}, # type: ignore[attr-defined]
693
+ body={
694
+ "federation": federation.model_dump(by_alias=True) if federation else None,
695
+ "queries": processed_queries,
696
+ },
670
697
  )
671
698
 
699
+ if federation:
700
+ results = response.json()
701
+ return SearchResultsFederated[hits_type](**results)
702
+
672
703
  return [SearchResultsWithUID[hits_type](**x) for x in response.json()["results"]]
673
704
 
674
705
  async def get_raw_index(self, uid: str) -> IndexInfo | None:
@@ -1044,6 +1075,7 @@ class Client(BaseClient):
1044
1075
  verify: str | bool | SSLContext = True,
1045
1076
  custom_headers: dict[str, str] | None = None,
1046
1077
  json_handler: BuiltinHandler | OrjsonHandler | UjsonHandler | None = None,
1078
+ http2: bool = False,
1047
1079
  ) -> None:
1048
1080
  """Class initializer.
1049
1081
 
@@ -1062,12 +1094,14 @@ class Client(BaseClient):
1062
1094
  (uses the json module from the standard library), OrjsonHandler (uses orjson), or
1063
1095
  UjsonHandler (uses ujson). Note that in order use orjson or ujson the corresponding
1064
1096
  extra needs to be included. Default: BuiltinHandler.
1097
+ http2: If set to True, the client will use HTTP/2. Defaults to False.
1065
1098
  """
1066
1099
  super().__init__(api_key, custom_headers, json_handler)
1067
1100
 
1068
1101
  self.http_client = HttpxClient(
1069
- base_url=url, timeout=timeout, headers=self._headers, verify=verify
1102
+ base_url=url, timeout=timeout, headers=self._headers, verify=verify, http2=http2
1070
1103
  )
1104
+
1071
1105
  self._http_requests = HttpRequests(self.http_client, json_handler=self.json_handler)
1072
1106
 
1073
1107
  def create_dump(self) -> TaskInfo:
@@ -1510,13 +1544,20 @@ class Client(BaseClient):
1510
1544
  return Key(**response.json())
1511
1545
 
1512
1546
  def multi_search(
1513
- self, queries: list[SearchParams], *, hits_type: Any = JsonDict
1514
- ) -> list[SearchResultsWithUID]:
1547
+ self,
1548
+ queries: list[SearchParams],
1549
+ *,
1550
+ federation: Federation | None = None,
1551
+ hits_type: Any = JsonDict,
1552
+ ) -> list[SearchResultsWithUID] | SearchResultsFederated:
1515
1553
  """Multi-index search.
1516
1554
 
1517
1555
  Args:
1518
1556
 
1519
1557
  queries: List of SearchParameters
1558
+ federation: If included a single search result with hits built from all queries will
1559
+ be returned. This parameter can only be used with Meilisearch >= v1.10.0. Defaults
1560
+ to None.
1520
1561
  hits_type: Allows for a custom type to be passed to use for hits. Defaults to
1521
1562
  JsonDict
1522
1563
 
@@ -1541,11 +1582,28 @@ class Client(BaseClient):
1541
1582
  >>> search_results = client.search(queries)
1542
1583
  """
1543
1584
  url = "multi-search"
1585
+ if federation:
1586
+ processed_queries = []
1587
+ for query in queries:
1588
+ q = query.model_dump(by_alias=True)
1589
+ del q["limit"]
1590
+ del q["offset"]
1591
+ processed_queries.append(q)
1592
+ else:
1593
+ processed_queries = [x.model_dump(by_alias=True) for x in queries]
1594
+
1544
1595
  response = self._http_requests.post(
1545
1596
  url,
1546
- body={"queries": [x.model_dump(by_alias=True) for x in queries]}, # type: ignore[attr-defined]
1597
+ body={
1598
+ "federation": federation.model_dump(by_alias=True) if federation else None,
1599
+ "queries": processed_queries,
1600
+ },
1547
1601
  )
1548
1602
 
1603
+ if federation:
1604
+ results = response.json()
1605
+ return SearchResultsFederated[hits_type](**results)
1606
+
1549
1607
  return [SearchResultsWithUID[hits_type](**x) for x in response.json()["results"]]
1550
1608
 
1551
1609
  def get_raw_index(self, uid: str) -> IndexInfo | None:
@@ -1 +1 @@
1
- VERSION = "3.2.0"
1
+ VERSION = "3.4.0"
@@ -26,6 +26,7 @@ def async_add_documents(
26
26
  batch_size: int | None = None,
27
27
  primary_key: str | None = None,
28
28
  wait_for_task: bool = False,
29
+ verify: bool = True,
29
30
  ) -> Callable:
30
31
  """Decorator that takes the returned documents from a function and asyncronously adds them to Meilisearch.
31
32
 
@@ -42,6 +43,7 @@ def async_add_documents(
42
43
  Defaults to None.
43
44
  wait_for_task: If set to `True` the decorator will wait for the document addition to finish
44
45
  indexing before returning, otherwise it will return right away. Default = False.
46
+ verify: If set to `False` the decorator will not verify the SSL certificate of the server.
45
47
 
46
48
  Returns:
47
49
 
@@ -89,7 +91,9 @@ def async_add_documents(
89
91
  )
90
92
  return result
91
93
 
92
- async with AsyncClient(connection_info.url, connection_info.api_key) as client:
94
+ async with AsyncClient(
95
+ connection_info.url, connection_info.api_key, verify=verify
96
+ ) as client:
93
97
  await _async_add_documents(
94
98
  client, index_name, result, batch_size, primary_key, wait_for_task
95
99
  )
@@ -108,6 +112,7 @@ def add_documents(
108
112
  batch_size: int | None = None,
109
113
  primary_key: str | None = None,
110
114
  wait_for_task: bool = False,
115
+ verify: bool = True,
111
116
  ) -> Callable:
112
117
  """Decorator that takes the returned documents from a function and adds them to Meilisearch.
113
118
 
@@ -124,6 +129,7 @@ def add_documents(
124
129
  Defaults to None.
125
130
  wait_for_task: If set to `True` the decorator will wait for the document addition to finish
126
131
  indexing before returning, otherwise it will return right away. Default = False.
132
+ verify: If set to `False` the decorator will not verify the SSL certificate of the server.
127
133
 
128
134
  Returns:
129
135
 
@@ -171,7 +177,9 @@ def add_documents(
171
177
  )
172
178
  return result
173
179
 
174
- decorator_client = Client(url=connection_info.url, api_key=connection_info.api_key)
180
+ decorator_client = Client(
181
+ url=connection_info.url, api_key=connection_info.api_key, verify=verify
182
+ )
175
183
  _add_documents(
176
184
  decorator_client,
177
185
  index_name,
@@ -30,6 +30,7 @@ from meilisearch_python_sdk.models.settings import (
30
30
  Embedders,
31
31
  Faceting,
32
32
  HuggingFaceEmbedder,
33
+ LocalizedAttributes,
33
34
  MeilisearchSettings,
34
35
  OllamaEmbedder,
35
36
  OpenAiEmbedder,
@@ -787,6 +788,7 @@ class AsyncIndex(_BaseIndex):
787
788
  ranking_score_threshold: float | None = None,
788
789
  vector: list[float] | None = None,
789
790
  hybrid: Hybrid | None = None,
791
+ locales: list[str] | None = None,
790
792
  ) -> SearchResults:
791
793
  """Search the index.
792
794
 
@@ -846,6 +848,8 @@ class AsyncIndex(_BaseIndex):
846
848
  { "vectorStore": true }. Because this feature is experimental it may be removed or
847
849
  updated causing breaking changes in this library without a major version bump so use
848
850
  with caution.
851
+ locales: Specifies the languages for the search. This parameter can only be used with
852
+ Milisearch >= v1.10.0. Defaults to None letting the Meilisearch pick.
849
853
 
850
854
  Returns:
851
855
 
@@ -891,6 +895,7 @@ class AsyncIndex(_BaseIndex):
891
895
  vector=vector,
892
896
  hybrid=hybrid,
893
897
  ranking_score_threshold=ranking_score_threshold,
898
+ locales=locales,
894
899
  )
895
900
  search_url = f"{self._base_url_with_uid}/search"
896
901
 
@@ -1052,6 +1057,7 @@ class AsyncIndex(_BaseIndex):
1052
1057
  show_ranking_score_details: bool = False,
1053
1058
  ranking_score_threshold: float | None = None,
1054
1059
  vector: list[float] | None = None,
1060
+ locales: list[str] | None = None,
1055
1061
  ) -> FacetSearchResults:
1056
1062
  """Search the index.
1057
1063
 
@@ -1103,6 +1109,8 @@ class AsyncIndex(_BaseIndex):
1103
1109
  { "vectorStore": true }. Because this feature is experimental it may be removed or
1104
1110
  updated causing breaking changes in this library without a major version bump so use
1105
1111
  with caution.
1112
+ locales: Specifies the languages for the search. This parameter can only be used with
1113
+ Milisearch >= v1.10.0. Defaults to None letting the Meilisearch pick.
1106
1114
 
1107
1115
  Returns:
1108
1116
 
@@ -1152,6 +1160,7 @@ class AsyncIndex(_BaseIndex):
1152
1160
  show_ranking_score_details=show_ranking_score_details,
1153
1161
  ranking_score_threshold=ranking_score_threshold,
1154
1162
  vector=vector,
1163
+ locales=locales,
1155
1164
  )
1156
1165
  search_url = f"{self._base_url_with_uid}/facet-search"
1157
1166
 
@@ -2028,6 +2037,51 @@ class AsyncIndex(_BaseIndex):
2028
2037
 
2029
2038
  return TaskInfo(**response.json())
2030
2039
 
2040
+ async def edit_documents(
2041
+ self, function: str, *, context: JsonDict | None = None, filter: str | None = None
2042
+ ) -> TaskInfo:
2043
+ """Edit documents with a function.
2044
+
2045
+ Edit documents is only available in Meilisearch >= v1.10.0, and is experimental in
2046
+ Meilisearch v1.10.0. In order to use this feature you first need to enable it by
2047
+ sending a PATCH request to /experimental-features with { "editDocumentsByFunction": true }.
2048
+
2049
+ Args:
2050
+
2051
+ function: Rhai function to use to update the documents.
2052
+ context: Parameters to use in the function. Defaults to None.
2053
+ filter: Filter the documents before applying the function. Defaults to None.
2054
+
2055
+ Returns:
2056
+
2057
+ The details of the task.
2058
+
2059
+ Raises:
2060
+
2061
+ MeilisearchError: If the file path is not valid
2062
+ MeilisearchCommunicationError: If there was an error communicating with the server.
2063
+ MeilisearchApiError: If the Meilisearch API returned an error.
2064
+
2065
+ Examples:
2066
+
2067
+ >>> from meilisearch_python_sdk import AsyncClient
2068
+ >>> async with AsyncClient("http://localhost.com", "masterKey") as client:
2069
+ >>> index = client.index("movies")
2070
+ >>> await index.edit_documents("doc.title = `${doc.title.to_upper()}`")
2071
+ """
2072
+ url = f"{self._documents_url}/edit"
2073
+ payload: JsonDict = {"function": function}
2074
+
2075
+ if context:
2076
+ payload["context"] = context
2077
+
2078
+ if filter:
2079
+ payload["filter"] = filter
2080
+
2081
+ response = await self._http_requests.post(url, payload)
2082
+
2083
+ return TaskInfo(**response.json())
2084
+
2031
2085
  async def update_documents(
2032
2086
  self,
2033
2087
  documents: Sequence[JsonMapping],
@@ -4434,8 +4488,7 @@ class AsyncIndex(_BaseIndex):
4434
4488
 
4435
4489
  return TaskInfo(**response.json())
4436
4490
 
4437
- # TODO: Add back after embedder setting issue fixed https://github.com/meilisearch/meilisearch/issues/4585
4438
- async def reset_embedders(self) -> TaskInfo: # pragma: no cover
4491
+ async def reset_embedders(self) -> TaskInfo:
4439
4492
  """Reset an index's embedders settings to the default value.
4440
4493
 
4441
4494
  Returns:
@@ -4458,6 +4511,94 @@ class AsyncIndex(_BaseIndex):
4458
4511
 
4459
4512
  return TaskInfo(**response.json())
4460
4513
 
4514
+ async def get_localized_attributes(self) -> list[LocalizedAttributes] | None:
4515
+ """Get localized attributes settings for the index.
4516
+
4517
+ Returns:
4518
+
4519
+ Localized attributes for the index.
4520
+
4521
+ Raises:
4522
+
4523
+ MeilisearchCommunicationError: If there was an error communicating with the server.
4524
+ MeilisearchApiError: If the Meilisearch API returned an error.
4525
+
4526
+ Examples:
4527
+
4528
+ >>> from meilisearch_async_client import AsyncClient
4529
+ >>> async with AsyncClient("http://localhost.com", "masterKey") as client:
4530
+ >>> index = client.index("movies")
4531
+ >>> localized_attributes = await index.get_localized_attributes()
4532
+ """
4533
+ response = await self._http_requests.get(f"{self._settings_url}/localized-attributes")
4534
+
4535
+ if not response.json():
4536
+ return None
4537
+
4538
+ return [LocalizedAttributes(**x) for x in response.json()]
4539
+
4540
+ async def update_localized_attributes(
4541
+ self, localized_attributes: list[LocalizedAttributes], *, compress: bool = False
4542
+ ) -> TaskInfo:
4543
+ """Update the localized attributes settings for an index.
4544
+
4545
+ Args:
4546
+
4547
+ localized_attributes: The localized attributes value.
4548
+ compress: If set to True the data will be sent in gzip format. Defaults to False.
4549
+
4550
+ Returns:
4551
+
4552
+ Task to track the action.
4553
+
4554
+ Raises:
4555
+
4556
+ MeilisearchCommunicationError: If there was an error communicating with the server.
4557
+ MeilisearchApiError: If the Meilisearch API returned an error.
4558
+
4559
+ Examples:
4560
+
4561
+ >>> from meilisearch_python_sdk import AsyncClient
4562
+ >>> from meilisearch_python_sdk.models.settings import LocalizedAttributes
4563
+ >>>
4564
+ >>>
4565
+ >>> async with AsyncClient("http://localhost.com", "masterKey") as client:
4566
+ >>> index = client.index("movies")
4567
+ >>> await index.update_localized_attributes([
4568
+ >>> LocalizedAttributes(locales=["eng", "spa"], attribute_patterns=["*"]),
4569
+ >>> LocalizedAttributes(locales=["ita"], attribute_patterns=["*_it"]),
4570
+ >>> ])
4571
+ """
4572
+ payload = [x.model_dump(by_alias=True) for x in localized_attributes]
4573
+ response = await self._http_requests.put(
4574
+ f"{self._settings_url}/localized-attributes", payload, compress=compress
4575
+ )
4576
+
4577
+ return TaskInfo(**response.json())
4578
+
4579
+ async def reset_localized_attributes(self) -> TaskInfo:
4580
+ """Reset an index's localized attributes settings to the default value.
4581
+
4582
+ Returns:
4583
+
4584
+ The details of the task status.
4585
+
4586
+ Raises:
4587
+
4588
+ MeilisearchCommunicationError: If there was an error communicating with the server.
4589
+ MeilisearchApiError: If the Meilisearch API returned an error.
4590
+
4591
+ Examples:
4592
+
4593
+ >>> from meilisearch_async_client import AsyncClient
4594
+ >>> async with AsyncClient("http://localhost.com", "masterKey") as client:
4595
+ >>> index = client.index("movies")
4596
+ >>> await index.reset_localized_attributes()
4597
+ """
4598
+ response = await self._http_requests.delete(f"{self._settings_url}/localized-attributes")
4599
+
4600
+ return TaskInfo(**response.json())
4601
+
4461
4602
  @staticmethod
4462
4603
  async def _run_plugins(
4463
4604
  plugins: Sequence[AsyncPlugin | AsyncDocumentPlugin | AsyncPostSearchPlugin],
@@ -5080,6 +5221,7 @@ class Index(_BaseIndex):
5080
5221
  ranking_score_threshold: float | None = None,
5081
5222
  vector: list[float] | None = None,
5082
5223
  hybrid: Hybrid | None = None,
5224
+ locales: list[str] | None = None,
5083
5225
  ) -> SearchResults:
5084
5226
  """Search the index.
5085
5227
 
@@ -5139,6 +5281,8 @@ class Index(_BaseIndex):
5139
5281
  { "vectorStore": true }. Because this feature is experimental it may be removed or
5140
5282
  updated causing breaking changes in this library without a major version bump so use
5141
5283
  with caution.
5284
+ locales: Specifies the languages for the search. This parameter can only be used with
5285
+ Milisearch >= v1.10.0. Defaults to None letting the Meilisearch pick.
5142
5286
 
5143
5287
  Returns:
5144
5288
 
@@ -5184,6 +5328,7 @@ class Index(_BaseIndex):
5184
5328
  vector=vector,
5185
5329
  hybrid=hybrid,
5186
5330
  ranking_score_threshold=ranking_score_threshold,
5331
+ locales=locales,
5187
5332
  )
5188
5333
 
5189
5334
  if self._pre_search_plugins:
@@ -5251,6 +5396,7 @@ class Index(_BaseIndex):
5251
5396
  show_ranking_score_details: bool = False,
5252
5397
  ranking_score_threshold: float | None = None,
5253
5398
  vector: list[float] | None = None,
5399
+ locales: list[str] | None = None,
5254
5400
  ) -> FacetSearchResults:
5255
5401
  """Search the index.
5256
5402
 
@@ -5302,6 +5448,8 @@ class Index(_BaseIndex):
5302
5448
  { "vectorStore": true }. Because this feature is experimental it may be removed or
5303
5449
  updated causing breaking changes in this library without a major version bump so use
5304
5450
  with caution.
5451
+ locales: Specifies the languages for the search. This parameter can only be used with
5452
+ Milisearch >= v1.10.0. Defaults to None letting the Meilisearch pick.
5305
5453
 
5306
5454
  Returns:
5307
5455
 
@@ -5351,6 +5499,7 @@ class Index(_BaseIndex):
5351
5499
  show_ranking_score_details=show_ranking_score_details,
5352
5500
  ranking_score_threshold=ranking_score_threshold,
5353
5501
  vector=vector,
5502
+ locales=locales,
5354
5503
  )
5355
5504
 
5356
5505
  if self._pre_facet_search_plugins:
@@ -5990,6 +6139,51 @@ class Index(_BaseIndex):
5990
6139
 
5991
6140
  return TaskInfo(**response.json())
5992
6141
 
6142
+ def edit_documents(
6143
+ self, function: str, *, context: JsonDict | None = None, filter: str | None = None
6144
+ ) -> TaskInfo:
6145
+ """Edit documents with a function.
6146
+
6147
+ Edit documents is only available in Meilisearch >= v1.10.0, and is experimental in
6148
+ Meilisearch v1.10.0. In order to use this feature you first need to enable it by
6149
+ sending a PATCH request to /experimental-features with { "editDocumentsByFunction": true }.
6150
+
6151
+ Args:
6152
+
6153
+ function: Rhai function to use to update the documents.
6154
+ context: Parameters to use in the function. Defaults to None.
6155
+ filter: Filter the documents before applying the function. Defaults to None.
6156
+
6157
+ Returns:
6158
+
6159
+ The details of the task.
6160
+
6161
+ Raises:
6162
+
6163
+ MeilisearchError: If the file path is not valid
6164
+ MeilisearchCommunicationError: If there was an error communicating with the server.
6165
+ MeilisearchApiError: If the Meilisearch API returned an error.
6166
+
6167
+ Examples:
6168
+
6169
+ >>> from meilisearch_python_sdk import Client
6170
+ >>> client = Client("http://localhost.com", "masterKey")
6171
+ >>> index = client.index("movies")
6172
+ >>> index.edit_documents("doc.title = `${doc.title.to_upper()}`")
6173
+ """
6174
+ url = f"{self._documents_url}/edit"
6175
+ payload: JsonDict = {"function": function}
6176
+
6177
+ if context:
6178
+ payload["context"] = context
6179
+
6180
+ if filter:
6181
+ payload["filter"] = filter
6182
+
6183
+ response = self._http_requests.post(url, payload)
6184
+
6185
+ return TaskInfo(**response.json())
6186
+
5993
6187
  def update_documents(
5994
6188
  self,
5995
6189
  documents: Sequence[JsonMapping],
@@ -8070,6 +8264,94 @@ class Index(_BaseIndex):
8070
8264
 
8071
8265
  return TaskInfo(**response.json())
8072
8266
 
8267
+ def get_localized_attributes(self) -> list[LocalizedAttributes] | None:
8268
+ """Get localized attributes settings for the index.
8269
+
8270
+ Returns:
8271
+
8272
+ Localized attributes for the index.
8273
+
8274
+ Raises:
8275
+
8276
+ MeilisearchCommunicationError: If there was an error communicating with the server.
8277
+ MeilisearchApiError: If the Meilisearch API returned an error.
8278
+
8279
+ Examples:
8280
+
8281
+ >>> from meilisearch_async_client import AsyncClient
8282
+ >>> client = Client("http://localhost.com", "masterKey")
8283
+ >>> index = client.index("movies")
8284
+ >>> localized_attributes = await index.get_localized_attributes()
8285
+ """
8286
+ response = self._http_requests.get(f"{self._settings_url}/localized-attributes")
8287
+
8288
+ if not response.json():
8289
+ return None
8290
+
8291
+ return [LocalizedAttributes(**x) for x in response.json()]
8292
+
8293
+ def update_localized_attributes(
8294
+ self, localized_attributes: list[LocalizedAttributes], *, compress: bool = False
8295
+ ) -> TaskInfo:
8296
+ """Update the localized attributes settings for an index.
8297
+
8298
+ Args:
8299
+
8300
+ localized_attributes: The localized attributes value.
8301
+ compress: If set to True the data will be sent in gzip format. Defaults to False.
8302
+
8303
+ Returns:
8304
+
8305
+ Task to track the action.
8306
+
8307
+ Raises:
8308
+
8309
+ MeilisearchCommunicationError: If there was an error communicating with the server.
8310
+ MeilisearchApiError: If the Meilisearch API returned an error.
8311
+
8312
+ Examples:
8313
+
8314
+ >>> from meilisearch_python_sdk import AsyncClient
8315
+ >>> from meilisearch_python_sdk.models.settings import LocalizedAttributes
8316
+ >>>
8317
+ >>>
8318
+ >>> client = Client("http://localhost.com", "masterKey")
8319
+ >>> index = client.index("movies")
8320
+ >>> index.update_localized_attributes([
8321
+ >>> LocalizedAttributes(locales=["eng", "spa"], attribute_patterns=["*"]),
8322
+ >>> LocalizedAttributes(locales=["ita"], attribute_patterns=["*_it"]),
8323
+ >>> ])
8324
+ """
8325
+ payload = [x.model_dump(by_alias=True) for x in localized_attributes]
8326
+ response = self._http_requests.put(
8327
+ f"{self._settings_url}/localized-attributes", payload, compress=compress
8328
+ )
8329
+
8330
+ return TaskInfo(**response.json())
8331
+
8332
+ def reset_localized_attributes(self) -> TaskInfo:
8333
+ """Reset an index's localized attributes settings to the default value.
8334
+
8335
+ Returns:
8336
+
8337
+ The details of the task status.
8338
+
8339
+ Raises:
8340
+
8341
+ MeilisearchCommunicationError: If there was an error communicating with the server.
8342
+ MeilisearchApiError: If the Meilisearch API returned an error.
8343
+
8344
+ Examples:
8345
+
8346
+ >>> from meilisearch_async_client import AsyncClient
8347
+ >>> Client("http://localhost.com", "masterKey") as client:
8348
+ >>> index = client.index("movies")
8349
+ >>> index.reset_localized_attributes()
8350
+ """
8351
+ response = self._http_requests.delete(f"{self._settings_url}/localized-attributes")
8352
+
8353
+ return TaskInfo(**response.json())
8354
+
8073
8355
  @staticmethod
8074
8356
  def _run_plugins(
8075
8357
  plugins: Sequence[Plugin | DocumentPlugin | PostSearchPlugin],
@@ -8257,6 +8539,7 @@ def _process_search_parameters(
8257
8539
  ranking_score_threshold: float | None = None,
8258
8540
  vector: list[float] | None = None,
8259
8541
  hybrid: Hybrid | None = None,
8542
+ locales: list[str] | None = None,
8260
8543
  ) -> JsonDict:
8261
8544
  if attributes_to_retrieve is None:
8262
8545
  attributes_to_retrieve = ["*"]
@@ -8302,6 +8585,9 @@ def _process_search_parameters(
8302
8585
  if hybrid:
8303
8586
  body["hybrid"] = hybrid.model_dump(by_alias=True)
8304
8587
 
8588
+ if locales:
8589
+ body["locales"] = locales
8590
+
8305
8591
  return body
8306
8592
 
8307
8593
 
@@ -27,6 +27,11 @@ class Hybrid(CamelBase):
27
27
  embedder: str | None = None
28
28
 
29
29
 
30
+ class Federation(CamelBase):
31
+ limit: int = 20
32
+ offset: int = 0
33
+
34
+
30
35
  class SearchParams(CamelBase):
31
36
  index_uid: str
32
37
  query: str | None = Field(None, alias="q")
@@ -52,6 +57,7 @@ class SearchParams(CamelBase):
52
57
  ranking_score_threshold: float | None = None
53
58
  vector: list[float] | None = None
54
59
  hybrid: Hybrid | None = None
60
+ locales: list[str] | None = None
55
61
 
56
62
  @field_validator("ranking_score_threshold", mode="before") # type: ignore[attr-defined]
57
63
  @classmethod
@@ -81,6 +87,20 @@ class SearchResultsWithUID(SearchResults, Generic[T]):
81
87
  index_uid: str
82
88
 
83
89
 
90
+ class SearchResultsFederated(CamelBase, Generic[T]):
91
+ hits: list[T]
92
+ offset: int | None = None
93
+ limit: int | None = None
94
+ estimated_total_hits: int | None = None
95
+ processing_time_ms: int
96
+ facet_distribution: JsonDict | None = None
97
+ total_pages: int | None = None
98
+ total_hits: int | None = None
99
+ page: int | None = None
100
+ hits_per_page: int | None = None
101
+ semantic_hit_count: int | None = None
102
+
103
+
84
104
  class SimilarSearchResults(CamelBase, Generic[T]):
85
105
  hits: list[T]
86
106
  id: str
@@ -48,6 +48,7 @@ class Distribution(CamelBase):
48
48
 
49
49
  class OpenAiEmbedder(CamelBase):
50
50
  source: str = "openAi"
51
+ url: str | None = None
51
52
  model: str | None = None # Defaults to text-embedding-ada-002
52
53
  dimensions: int | None = None # Uses the model default
53
54
  api_key: str | None = None # Can be provided through a CLI option or environment variable
@@ -68,6 +69,7 @@ class OllamaEmbedder(CamelBase):
68
69
  url: str | None = None
69
70
  api_key: str | None = None
70
71
  model: str
72
+ dimensions: int | None = None
71
73
  document_template: str | None = None
72
74
  distribution: Distribution | None = None
73
75
 
@@ -78,12 +80,10 @@ class RestEmbedder(CamelBase):
78
80
  api_key: str | None = None
79
81
  dimensions: int
80
82
  document_template: str | None = None
81
- input_field: list[str] | None = None
82
- input_type: str = "text"
83
- query: JsonDict = {}
84
- path_to_embeddings: list[str] | None = None
85
- embedding_object: list[str] | None = None
86
83
  distribution: Distribution | None = None
84
+ headers: JsonDict | None = None
85
+ request: JsonDict
86
+ response: JsonDict
87
87
 
88
88
 
89
89
  class UserProvidedEmbedder(CamelBase):
@@ -104,6 +104,11 @@ class ProximityPrecision(str, Enum):
104
104
  BY_ATTRIBUTE = "byAttribute"
105
105
 
106
106
 
107
+ class LocalizedAttributes(CamelBase):
108
+ locales: list[str]
109
+ attribute_patterns: list[str]
110
+
111
+
107
112
  class MeilisearchSettings(CamelBase):
108
113
  synonyms: JsonDict | None = None
109
114
  stop_words: list[str] | None = None
@@ -132,3 +137,4 @@ class MeilisearchSettings(CamelBase):
132
137
  ]
133
138
  | None
134
139
  ) = None # Optional[Embedders] = None
140
+ localized_attributes: list[LocalizedAttributes] | None = None
@@ -1,36 +1,57 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: meilisearch-python-sdk
3
- Version: 3.2.0
3
+ Version: 3.4.0
4
4
  Summary: A Python client providing both async and sync support for the Meilisearch API
5
- Home-page: https://github.com/sanders41/meilisearch-python-sdk
6
- License: MIT
7
- Keywords: meilisearch,async,python,client,sdk
8
- Author: Paul Sanders
9
- Author-email: psanders1@gmail.com
10
- Requires-Python: >=3.9,<4.0
5
+ Project-URL: repository, https://github.com/sanders41/meilisearch-python-sdk
6
+ Project-URL: homepage, https://github.com/sanders41/meilisearch-python-sdk
7
+ Project-URL: documentation, https://meilisearch-python-sdk.paulsanders.dev
8
+ Author-email: Paul Sanders <paul@paulsanders.dev>
9
+ License: MIT License
10
+
11
+ Copyright (c) 2021 Paul Sanders
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+ License-File: LICENSE
31
+ Keywords: async,client,meilisearch,python,sdk
11
32
  Classifier: Development Status :: 5 - Production/Stable
12
33
  Classifier: Intended Audience :: Developers
13
34
  Classifier: License :: OSI Approved :: MIT License
14
35
  Classifier: Operating System :: OS Independent
15
- Classifier: Programming Language :: Python :: 3
16
36
  Classifier: Programming Language :: Python :: 3.9
17
37
  Classifier: Programming Language :: Python :: 3.10
18
38
  Classifier: Programming Language :: Python :: 3.11
19
39
  Classifier: Programming Language :: Python :: 3.12
20
40
  Classifier: Typing :: Typed
41
+ Requires-Python: >=3.9
42
+ Requires-Dist: aiofiles>=0.7
43
+ Requires-Dist: camel-converter>=1.0.0
44
+ Requires-Dist: eval-type-backport>=0.2.0; python_version < '3.10'
45
+ Requires-Dist: httpx[http2]>=0.17
46
+ Requires-Dist: pydantic>=2.0.0
47
+ Requires-Dist: pyjwt>=2.3.0
21
48
  Provides-Extra: all
49
+ Requires-Dist: orjson; extra == 'all'
50
+ Requires-Dist: ujson; extra == 'all'
22
51
  Provides-Extra: orjson
52
+ Requires-Dist: orjson>=3.10.6; extra == 'orjson'
23
53
  Provides-Extra: ujson
24
- Requires-Dist: PyJWT (>=2.3.0)
25
- Requires-Dist: aiofiles (>=0.7)
26
- Requires-Dist: camel-converter (>=1.0.0)
27
- Requires-Dist: eval-type-backport (>=0.2.0) ; python_version < "3.10"
28
- Requires-Dist: httpx (>=0.17)
29
- Requires-Dist: orjson (>=3.10.6) ; extra == "orjson" or extra == "all"
30
- Requires-Dist: pydantic (>=2.0.0)
31
- Requires-Dist: ujson (>=5.10.0) ; extra == "ujson" or extra == "all"
32
- Project-URL: Documentation, https://meilisearch-python-sdk.paulsanders.dev
33
- Project-URL: Repository, https://github.com/sanders41/meilisearch-python-sdk
54
+ Requires-Dist: ujson>=5.10.0; extra == 'ujson'
34
55
  Description-Content-Type: text/markdown
35
56
 
36
57
  # Meilisearch Python SDK
@@ -256,4 +277,3 @@ See our [docs](https://meilisearch-python-sdk.paulsanders.dev) for the full docu
256
277
 
257
278
  Contributions to this project are welcome. If you are interested in contributing please see our
258
279
  [contributing guide](CONTRIBUTING.md)
259
-
@@ -1,26 +1,26 @@
1
1
  meilisearch_python_sdk/__init__.py,sha256=SB0Jlm6FwT13J9xasZKseZzTWBk0hkfe1CWyWmIIZnE,258
2
- meilisearch_python_sdk/_client.py,sha256=I4HVtgzuwlQ-BmyUlVXQTZ3dJR7YIhyfs0qQTXEYBfM,68170
2
+ meilisearch_python_sdk/_client.py,sha256=8QSMTzpyIZQ9dOIsvhPNtvdbBfIk8e1LCBtE5V9Qdak,70166
3
3
  meilisearch_python_sdk/_http_requests.py,sha256=TwpqsOvfgaJ1lQXwam1q1_UC6NvRWy4m9W3c5KNe0RI,6741
4
4
  meilisearch_python_sdk/_task.py,sha256=dB0cpX1u7HDM1OW_TC8gSiGJe985bNCz7hPMZW_qogY,12352
5
5
  meilisearch_python_sdk/_utils.py,sha256=k6SYMJSiVjfF-vlhQRMaE1ziJsVf5FrL94mFwrMfdLY,957
6
- meilisearch_python_sdk/_version.py,sha256=mSmBHX16HKPBdzS8NyxhHeyB1rvV3HpaiWcXae7jexg,18
7
- meilisearch_python_sdk/decorators.py,sha256=KpS5gAgks28BtPMZJumRaXfgXK4A3QNVPR8Z4BpZC0g,8346
6
+ meilisearch_python_sdk/_version.py,sha256=khmbxbSXtOr6w4Q7KaaU-Qmove9qu95Y6VPgNPeIc6w,18
7
+ meilisearch_python_sdk/decorators.py,sha256=hNrMvuLJKPNQDULkL1yMZYG7A9OVYbT7nass4URtEZM,8684
8
8
  meilisearch_python_sdk/errors.py,sha256=0sAKYt47-zFpKsEU6W8Qnvf4uHBynKtlGPpPl-5laSA,2085
9
- meilisearch_python_sdk/index.py,sha256=Rj_NudSqTIZAdB7WXntlY1zKQpVD-nPCNzmKEzU4U2c,315305
9
+ meilisearch_python_sdk/index.py,sha256=2y2_gDuxtflmnduPtm7LdTZzrn-sOvFU0rAZDFmcP6c,326043
10
10
  meilisearch_python_sdk/json_handler.py,sha256=q_87zSnJfDNuVEI9cEvuOQOGBC7AGWJMEqCh2kGAAqA,2107
11
+ meilisearch_python_sdk/plugins.py,sha256=YySzTuVr4IrogTgrP8q-gZPsew8TwedopjWnTj5eV48,3607
12
+ meilisearch_python_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ meilisearch_python_sdk/types.py,sha256=VBzt-JF6w1f5V_aTAM3NetDQxs9fscnRy8t-Y1HWZXM,404
11
14
  meilisearch_python_sdk/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
15
  meilisearch_python_sdk/models/client.py,sha256=wBZzO1n6DDQq7F9Acf1rCWYEYRY19g04uFiEf9JCMjc,2423
13
16
  meilisearch_python_sdk/models/documents.py,sha256=eT3FHrPND-g2IzNRyOHQApTTJ1WbFcGlqgxZ6aKrRgI,247
14
17
  meilisearch_python_sdk/models/health.py,sha256=hvruti7ylsk7bAh8RPOhTPcRrjx6MPgdkDFX9vZ5Qks,95
15
18
  meilisearch_python_sdk/models/index.py,sha256=GGwuhx5Wsn5iyj1ov3f4eWjfw6ttM8WzvyrnSsC4vRg,1132
16
- meilisearch_python_sdk/models/search.py,sha256=roaP0ElXMfa-NQF_bS3wuAEHHxTRJpT-qSnTsls5qjw,2586
17
- meilisearch_python_sdk/models/settings.py,sha256=FugCLAMESWQknHoViD84XfghlEWXcYIlnufb05Qq6IQ,3852
19
+ meilisearch_python_sdk/models/search.py,sha256=LH64_TunWxfCJOhxMCnFA-bMZOf7fVx6s3G9qhnfDTc,3121
20
+ meilisearch_python_sdk/models/settings.py,sha256=A8SocaQldrdo1chvxhS522zZR4foJcvZy7Cg2GiBi_M,3968
18
21
  meilisearch_python_sdk/models/task.py,sha256=P3NLaZhrY8H02Q9lDEkoq-3Z6_qGESglOxs4dNRyMWg,2100
19
22
  meilisearch_python_sdk/models/version.py,sha256=YDu-aj5H-d6nSaWRTXzlwWghmZAoiknaw250UyEd48I,215
20
- meilisearch_python_sdk/plugins.py,sha256=YySzTuVr4IrogTgrP8q-gZPsew8TwedopjWnTj5eV48,3607
21
- meilisearch_python_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- meilisearch_python_sdk/types.py,sha256=VBzt-JF6w1f5V_aTAM3NetDQxs9fscnRy8t-Y1HWZXM,404
23
- meilisearch_python_sdk-3.2.0.dist-info/LICENSE,sha256=xVzevI1TrlKfM0plmJ7vfK1Muu0V9n-dGE8RnDrOFlM,1069
24
- meilisearch_python_sdk-3.2.0.dist-info/METADATA,sha256=t6stZcURVCa41rT656-_-m-mM71bWDTk0f7YsyFiKtQ,8491
25
- meilisearch_python_sdk-3.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
26
- meilisearch_python_sdk-3.2.0.dist-info/RECORD,,
23
+ meilisearch_python_sdk-3.4.0.dist-info/METADATA,sha256=LmLRvyswlZ_4wEMu_5kZw2o-imPfQKHoGUARlNcC248,9710
24
+ meilisearch_python_sdk-3.4.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
25
+ meilisearch_python_sdk-3.4.0.dist-info/licenses/LICENSE,sha256=xVzevI1TrlKfM0plmJ7vfK1Muu0V9n-dGE8RnDrOFlM,1069
26
+ meilisearch_python_sdk-3.4.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: hatchling 1.25.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any