meilisearch-python-sdk 3.1.0__py3-none-any.whl → 3.3.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
@@ -633,13 +638,19 @@ class AsyncClient(BaseClient):
633
638
  return Key(**response.json())
634
639
 
635
640
  async def multi_search(
636
- self, queries: list[SearchParams], *, hits_type: Any = JsonDict
637
- ) -> list[SearchResultsWithUID]:
641
+ self,
642
+ queries: list[SearchParams],
643
+ *,
644
+ federation: Federation | None = None,
645
+ hits_type: Any = JsonDict,
646
+ ) -> list[SearchResultsWithUID] | SearchResultsFederated:
638
647
  """Multi-index search.
639
648
 
640
649
  Args:
641
650
 
642
651
  queries: List of SearchParameters
652
+ federation: If included a single search result with hits built from all queries. This
653
+ parameter can only be used with Meilisearch >= v1.10.0. Defaults to None.
643
654
  hits_type: Allows for a custom type to be passed to use for hits. Defaults to
644
655
  JsonDict
645
656
 
@@ -664,11 +675,28 @@ class AsyncClient(BaseClient):
664
675
  >>> search_results = await client.search(queries)
665
676
  """
666
677
  url = "multi-search"
678
+ if federation:
679
+ processed_queries = []
680
+ for query in queries:
681
+ q = query.model_dump(by_alias=True)
682
+ del q["limit"]
683
+ del q["offset"]
684
+ processed_queries.append(q)
685
+ else:
686
+ processed_queries = [x.model_dump(by_alias=True) for x in queries]
687
+
667
688
  response = await self._http_requests.post(
668
689
  url,
669
- body={"queries": [x.model_dump(by_alias=True) for x in queries]}, # type: ignore[attr-defined]
690
+ body={
691
+ "federation": federation.model_dump(by_alias=True) if federation else None,
692
+ "queries": processed_queries,
693
+ },
670
694
  )
671
695
 
696
+ if federation:
697
+ results = response.json()
698
+ return SearchResultsFederated[hits_type](**results)
699
+
672
700
  return [SearchResultsWithUID[hits_type](**x) for x in response.json()["results"]]
673
701
 
674
702
  async def get_raw_index(self, uid: str) -> IndexInfo | None:
@@ -1510,13 +1538,19 @@ class Client(BaseClient):
1510
1538
  return Key(**response.json())
1511
1539
 
1512
1540
  def multi_search(
1513
- self, queries: list[SearchParams], *, hits_type: Any = JsonDict
1514
- ) -> list[SearchResultsWithUID]:
1541
+ self,
1542
+ queries: list[SearchParams],
1543
+ *,
1544
+ federation: Federation | None = None,
1545
+ hits_type: Any = JsonDict,
1546
+ ) -> list[SearchResultsWithUID] | SearchResultsFederated:
1515
1547
  """Multi-index search.
1516
1548
 
1517
1549
  Args:
1518
1550
 
1519
1551
  queries: List of SearchParameters
1552
+ federation: If included a single search result with hits built from all queries. This
1553
+ parameter can only be used with Meilisearch >= v1.10.0. Defaults to None.
1520
1554
  hits_type: Allows for a custom type to be passed to use for hits. Defaults to
1521
1555
  JsonDict
1522
1556
 
@@ -1541,11 +1575,28 @@ class Client(BaseClient):
1541
1575
  >>> search_results = client.search(queries)
1542
1576
  """
1543
1577
  url = "multi-search"
1578
+ if federation:
1579
+ processed_queries = []
1580
+ for query in queries:
1581
+ q = query.model_dump(by_alias=True)
1582
+ del q["limit"]
1583
+ del q["offset"]
1584
+ processed_queries.append(q)
1585
+ else:
1586
+ processed_queries = [x.model_dump(by_alias=True) for x in queries]
1587
+
1544
1588
  response = self._http_requests.post(
1545
1589
  url,
1546
- body={"queries": [x.model_dump(by_alias=True) for x in queries]}, # type: ignore[attr-defined]
1590
+ body={
1591
+ "federation": federation.model_dump(by_alias=True) if federation else None,
1592
+ "queries": processed_queries,
1593
+ },
1547
1594
  )
1548
1595
 
1596
+ if federation:
1597
+ results = response.json()
1598
+ return SearchResultsFederated[hits_type](**results)
1599
+
1549
1600
  return [SearchResultsWithUID[hits_type](**x) for x in response.json()["results"]]
1550
1601
 
1551
1602
  def get_raw_index(self, uid: str) -> IndexInfo | None:
@@ -1 +1 @@
1
- VERSION = "3.1.0"
1
+ VERSION = "3.3.0"
@@ -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,
@@ -781,11 +782,13 @@ class AsyncIndex(_BaseIndex):
781
782
  hits_per_page: int | None = None,
782
783
  page: int | None = None,
783
784
  attributes_to_search_on: list[str] | None = None,
785
+ distinct: str | None = None,
784
786
  show_ranking_score: bool = False,
785
787
  show_ranking_score_details: bool = False,
786
788
  ranking_score_threshold: float | None = None,
787
789
  vector: list[float] | None = None,
788
790
  hybrid: Hybrid | None = None,
791
+ locales: list[str] | None = None,
789
792
  ) -> SearchResults:
790
793
  """Search the index.
791
794
 
@@ -815,6 +818,9 @@ class AsyncIndex(_BaseIndex):
815
818
  page: Sets the specific results page to fetch.
816
819
  attributes_to_search_on: List of field names. Allow search over a subset of searchable
817
820
  attributes without modifying the index settings. Defaults to None.
821
+ distinct: If set the distinct value will return at most one result for the
822
+ filterable attribute. Note that a filterable attributes must be set for this work.
823
+ Defaults to None.
818
824
  show_ranking_score: If set to True the ranking score will be returned with each document
819
825
  in the search. Defaults to False.
820
826
  show_ranking_score_details: If set to True the ranking details will be returned with
@@ -842,6 +848,8 @@ class AsyncIndex(_BaseIndex):
842
848
  { "vectorStore": true }. Because this feature is experimental it may be removed or
843
849
  updated causing breaking changes in this library without a major version bump so use
844
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.
845
853
 
846
854
  Returns:
847
855
 
@@ -881,11 +889,13 @@ class AsyncIndex(_BaseIndex):
881
889
  hits_per_page=hits_per_page,
882
890
  page=page,
883
891
  attributes_to_search_on=attributes_to_search_on,
892
+ distinct=distinct,
884
893
  show_ranking_score=show_ranking_score,
885
894
  show_ranking_score_details=show_ranking_score_details,
886
895
  vector=vector,
887
896
  hybrid=hybrid,
888
897
  ranking_score_threshold=ranking_score_threshold,
898
+ locales=locales,
889
899
  )
890
900
  search_url = f"{self._base_url_with_uid}/search"
891
901
 
@@ -911,6 +921,7 @@ class AsyncIndex(_BaseIndex):
911
921
  hits_per_page=hits_per_page,
912
922
  page=page,
913
923
  attributes_to_search_on=attributes_to_search_on,
924
+ distinct=distinct,
914
925
  show_ranking_score=show_ranking_score,
915
926
  show_ranking_score_details=show_ranking_score_details,
916
927
  vector=vector,
@@ -943,6 +954,7 @@ class AsyncIndex(_BaseIndex):
943
954
  hits_per_page=hits_per_page,
944
955
  page=page,
945
956
  attributes_to_search_on=attributes_to_search_on,
957
+ distinct=distinct,
946
958
  show_ranking_score=show_ranking_score,
947
959
  show_ranking_score_details=show_ranking_score_details,
948
960
  vector=vector,
@@ -986,6 +998,7 @@ class AsyncIndex(_BaseIndex):
986
998
  hits_per_page=hits_per_page,
987
999
  page=page,
988
1000
  attributes_to_search_on=attributes_to_search_on,
1001
+ distinct=distinct,
989
1002
  show_ranking_score=show_ranking_score,
990
1003
  show_ranking_score_details=show_ranking_score_details,
991
1004
  vector=vector,
@@ -1044,6 +1057,7 @@ class AsyncIndex(_BaseIndex):
1044
1057
  show_ranking_score_details: bool = False,
1045
1058
  ranking_score_threshold: float | None = None,
1046
1059
  vector: list[float] | None = None,
1060
+ locales: list[str] | None = None,
1047
1061
  ) -> FacetSearchResults:
1048
1062
  """Search the index.
1049
1063
 
@@ -1095,6 +1109,8 @@ class AsyncIndex(_BaseIndex):
1095
1109
  { "vectorStore": true }. Because this feature is experimental it may be removed or
1096
1110
  updated causing breaking changes in this library without a major version bump so use
1097
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.
1098
1114
 
1099
1115
  Returns:
1100
1116
 
@@ -1144,6 +1160,7 @@ class AsyncIndex(_BaseIndex):
1144
1160
  show_ranking_score_details=show_ranking_score_details,
1145
1161
  ranking_score_threshold=ranking_score_threshold,
1146
1162
  vector=vector,
1163
+ locales=locales,
1147
1164
  )
1148
1165
  search_url = f"{self._base_url_with_uid}/facet-search"
1149
1166
 
@@ -2020,6 +2037,51 @@ class AsyncIndex(_BaseIndex):
2020
2037
 
2021
2038
  return TaskInfo(**response.json())
2022
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
+
2023
2085
  async def update_documents(
2024
2086
  self,
2025
2087
  documents: Sequence[JsonMapping],
@@ -4426,8 +4488,7 @@ class AsyncIndex(_BaseIndex):
4426
4488
 
4427
4489
  return TaskInfo(**response.json())
4428
4490
 
4429
- # TODO: Add back after embedder setting issue fixed https://github.com/meilisearch/meilisearch/issues/4585
4430
- async def reset_embedders(self) -> TaskInfo: # pragma: no cover
4491
+ async def reset_embedders(self) -> TaskInfo:
4431
4492
  """Reset an index's embedders settings to the default value.
4432
4493
 
4433
4494
  Returns:
@@ -4450,6 +4511,94 @@ class AsyncIndex(_BaseIndex):
4450
4511
 
4451
4512
  return TaskInfo(**response.json())
4452
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
+
4453
4602
  @staticmethod
4454
4603
  async def _run_plugins(
4455
4604
  plugins: Sequence[AsyncPlugin | AsyncDocumentPlugin | AsyncPostSearchPlugin],
@@ -5066,11 +5215,13 @@ class Index(_BaseIndex):
5066
5215
  hits_per_page: int | None = None,
5067
5216
  page: int | None = None,
5068
5217
  attributes_to_search_on: list[str] | None = None,
5218
+ distinct: str | None = None,
5069
5219
  show_ranking_score: bool = False,
5070
5220
  show_ranking_score_details: bool = False,
5071
5221
  ranking_score_threshold: float | None = None,
5072
5222
  vector: list[float] | None = None,
5073
5223
  hybrid: Hybrid | None = None,
5224
+ locales: list[str] | None = None,
5074
5225
  ) -> SearchResults:
5075
5226
  """Search the index.
5076
5227
 
@@ -5100,6 +5251,9 @@ class Index(_BaseIndex):
5100
5251
  page: Sets the specific results page to fetch.
5101
5252
  attributes_to_search_on: List of field names. Allow search over a subset of searchable
5102
5253
  attributes without modifying the index settings. Defaults to None.
5254
+ distinct: If set the distinct value will return at most one result for the
5255
+ filterable attribute. Note that a filterable attributes must be set for this work.
5256
+ Defaults to None.
5103
5257
  show_ranking_score: If set to True the ranking score will be returned with each document
5104
5258
  in the search. Defaults to False.
5105
5259
  show_ranking_score_details: If set to True the ranking details will be returned with
@@ -5127,6 +5281,8 @@ class Index(_BaseIndex):
5127
5281
  { "vectorStore": true }. Because this feature is experimental it may be removed or
5128
5282
  updated causing breaking changes in this library without a major version bump so use
5129
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.
5130
5286
 
5131
5287
  Returns:
5132
5288
 
@@ -5166,11 +5322,13 @@ class Index(_BaseIndex):
5166
5322
  hits_per_page=hits_per_page,
5167
5323
  page=page,
5168
5324
  attributes_to_search_on=attributes_to_search_on,
5325
+ distinct=distinct,
5169
5326
  show_ranking_score=show_ranking_score,
5170
5327
  show_ranking_score_details=show_ranking_score_details,
5171
5328
  vector=vector,
5172
5329
  hybrid=hybrid,
5173
5330
  ranking_score_threshold=ranking_score_threshold,
5331
+ locales=locales,
5174
5332
  )
5175
5333
 
5176
5334
  if self._pre_search_plugins:
@@ -5195,6 +5353,7 @@ class Index(_BaseIndex):
5195
5353
  hits_per_page=hits_per_page,
5196
5354
  page=page,
5197
5355
  attributes_to_search_on=attributes_to_search_on,
5356
+ distinct=distinct,
5198
5357
  show_ranking_score=show_ranking_score,
5199
5358
  show_ranking_score_details=show_ranking_score_details,
5200
5359
  vector=vector,
@@ -5237,6 +5396,7 @@ class Index(_BaseIndex):
5237
5396
  show_ranking_score_details: bool = False,
5238
5397
  ranking_score_threshold: float | None = None,
5239
5398
  vector: list[float] | None = None,
5399
+ locales: list[str] | None = None,
5240
5400
  ) -> FacetSearchResults:
5241
5401
  """Search the index.
5242
5402
 
@@ -5288,6 +5448,8 @@ class Index(_BaseIndex):
5288
5448
  { "vectorStore": true }. Because this feature is experimental it may be removed or
5289
5449
  updated causing breaking changes in this library without a major version bump so use
5290
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.
5291
5453
 
5292
5454
  Returns:
5293
5455
 
@@ -5337,6 +5499,7 @@ class Index(_BaseIndex):
5337
5499
  show_ranking_score_details=show_ranking_score_details,
5338
5500
  ranking_score_threshold=ranking_score_threshold,
5339
5501
  vector=vector,
5502
+ locales=locales,
5340
5503
  )
5341
5504
 
5342
5505
  if self._pre_facet_search_plugins:
@@ -5976,6 +6139,51 @@ class Index(_BaseIndex):
5976
6139
 
5977
6140
  return TaskInfo(**response.json())
5978
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
+
5979
6187
  def update_documents(
5980
6188
  self,
5981
6189
  documents: Sequence[JsonMapping],
@@ -8056,6 +8264,94 @@ class Index(_BaseIndex):
8056
8264
 
8057
8265
  return TaskInfo(**response.json())
8058
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
+
8059
8355
  @staticmethod
8060
8356
  def _run_plugins(
8061
8357
  plugins: Sequence[Plugin | DocumentPlugin | PostSearchPlugin],
@@ -8237,11 +8533,13 @@ def _process_search_parameters(
8237
8533
  hits_per_page: int | None = None,
8238
8534
  page: int | None = None,
8239
8535
  attributes_to_search_on: list[str] | None = None,
8536
+ distinct: str | None = None,
8240
8537
  show_ranking_score: bool = False,
8241
8538
  show_ranking_score_details: bool = False,
8242
8539
  ranking_score_threshold: float | None = None,
8243
8540
  vector: list[float] | None = None,
8244
8541
  hybrid: Hybrid | None = None,
8542
+ locales: list[str] | None = None,
8245
8543
  ) -> JsonDict:
8246
8544
  if attributes_to_retrieve is None:
8247
8545
  attributes_to_retrieve = ["*"]
@@ -8275,6 +8573,9 @@ def _process_search_parameters(
8275
8573
  if facet_query:
8276
8574
  body["facetQuery"] = facet_query
8277
8575
 
8576
+ if distinct:
8577
+ body["distinct"] = distinct
8578
+
8278
8579
  if show_ranking_score_details:
8279
8580
  body["showRankingScoreDetails"] = show_ranking_score_details
8280
8581
 
@@ -8284,6 +8585,9 @@ def _process_search_parameters(
8284
8585
  if hybrid:
8285
8586
  body["hybrid"] = hybrid.model_dump(by_alias=True)
8286
8587
 
8588
+ if locales:
8589
+ body["locales"] = locales
8590
+
8287
8591
  return body
8288
8592
 
8289
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.1.0
3
+ Version: 3.3.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>=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=HLbU0GLAh5TB-L9GuFHrCQEipiQusa94hyqak09ULOU,69865
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=3vf_fJuJ1GKgsLolRXa0KsZlsevgoI4iyhPFl5-KJnM,18
6
+ meilisearch_python_sdk/_version.py,sha256=PzSl7vO5fA6PZhs4iV8xBCu7yMgUgHHWOABscpEi88A,18
7
7
  meilisearch_python_sdk/decorators.py,sha256=KpS5gAgks28BtPMZJumRaXfgXK4A3QNVPR8Z4BpZC0g,8346
8
8
  meilisearch_python_sdk/errors.py,sha256=0sAKYt47-zFpKsEU6W8Qnvf4uHBynKtlGPpPl-5laSA,2085
9
- meilisearch_python_sdk/index.py,sha256=uW9m5gnLwHdQKiDf4DV0k4ksr252HzmkJQT3KCicg8g,314470
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.1.0.dist-info/LICENSE,sha256=xVzevI1TrlKfM0plmJ7vfK1Muu0V9n-dGE8RnDrOFlM,1069
24
- meilisearch_python_sdk-3.1.0.dist-info/METADATA,sha256=Nf5ywGBA550PlIm1bvQy3_WE0BjXa6n0QDDlkSgWt6Y,8491
25
- meilisearch_python_sdk-3.1.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
26
- meilisearch_python_sdk-3.1.0.dist-info/RECORD,,
23
+ meilisearch_python_sdk-3.3.0.dist-info/METADATA,sha256=KRcd87AO1_lX6bCTn511e6XQSpoSncX2bTbkCZXIpC0,9703
24
+ meilisearch_python_sdk-3.3.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
25
+ meilisearch_python_sdk-3.3.0.dist-info/licenses/LICENSE,sha256=xVzevI1TrlKfM0plmJ7vfK1Muu0V9n-dGE8RnDrOFlM,1069
26
+ meilisearch_python_sdk-3.3.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