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

@@ -470,6 +470,25 @@ class AsyncIndex(_BaseIndex):
470
470
 
471
471
  return plugins
472
472
 
473
+ async def compact(self) -> TaskInfo:
474
+ """Appends a new task to the queue to compact the database.
475
+
476
+ This defragments the LMDB database potentially speeds up indexing and searching.
477
+ NOTE: This is only available in Meilisearch v1.23.0+
478
+
479
+ Raises:
480
+ MeilisearchCommunicationError: If there was an error communicating with the server.
481
+ MeilisearchApiError: If the Meilisearch API returned an error.
482
+
483
+ Examples
484
+ >>> from meilisearch_python_sdk import AsyncClient
485
+ >>> async with AsyncClient("http://localhost.com", "masterKey") as client:
486
+ >>> index = client.index("movies")
487
+ >>> index.compact()
488
+ """
489
+ response = await self._http_requests.post(f"{self._base_url_with_uid}/compact")
490
+ return TaskInfo(**response.json())
491
+
473
492
  async def delete(self) -> TaskInfo:
474
493
  """Deletes the index.
475
494
 
@@ -4921,6 +4940,25 @@ class Index(_BaseIndex):
4921
4940
 
4922
4941
  return plugins
4923
4942
 
4943
+ def compact(self) -> TaskInfo:
4944
+ """Appends a new task to the queue to compact the database.
4945
+
4946
+ This defragments the LMDB database potentially speeds up indexing and searching.
4947
+ NOTE: This is only available in Meilisearch v1.23.0+
4948
+
4949
+ Raises:
4950
+ MeilisearchCommunicationError: If there was an error communicating with the server.
4951
+ MeilisearchApiError: If the Meilisearch API returned an error.
4952
+
4953
+ Examples
4954
+ >>> from meilisearch_python_sdk import Client
4955
+ >>> with Client("http://localhost.com", "masterKey") as client:
4956
+ >>> index = client.index("movies")
4957
+ >>> index.compact()
4958
+ """
4959
+ response = self._http_requests.post(f"{self._base_url_with_uid}/compact")
4960
+ return TaskInfo(**response.json())
4961
+
4924
4962
  def delete(self) -> TaskInfo:
4925
4963
  """Deletes the index.
4926
4964
 
@@ -4933,9 +4971,9 @@ class Index(_BaseIndex):
4933
4971
 
4934
4972
  Examples
4935
4973
  >>> from meilisearch_python_sdk import Client
4936
- >>> client = Client("http://localhost.com", "masterKey")
4937
- >>> index = client.index("movies")
4938
- >>> index.delete()
4974
+ >>> with Client("http://localhost.com", "masterKey") as client:
4975
+ >>> index = client.index("movies")
4976
+ >>> index.delete()
4939
4977
  """
4940
4978
  response = self._http_requests.delete(self._base_url_with_uid)
4941
4979
  return TaskInfo(**response.json())
@@ -4952,9 +4990,9 @@ class Index(_BaseIndex):
4952
4990
 
4953
4991
  Examples
4954
4992
  >>> from meilisearch_python_sdk import Client
4955
- >>> client = Client("http://localhost.com", "masterKey")
4956
- >>> index = client.index("movies")
4957
- >>> index.delete_if_exists()
4993
+ >>> with Client("http://localhost.com", "masterKey") as client:
4994
+ >>> index = client.index("movies")
4995
+ >>> index.delete_if_exists()
4958
4996
  """
4959
4997
  response = self.delete()
4960
4998
  status = wait_for_task(self.http_client, response.task_uid, timeout_in_ms=100000)
@@ -4978,9 +5016,9 @@ class Index(_BaseIndex):
4978
5016
 
4979
5017
  Examples
4980
5018
  >>> from meilisearch_python_sdk import Client
4981
- >>> client = Client("http://localhost.com", "masterKey")
4982
- >>> index = client.index("movies")
4983
- >>> updated_index = index.update()
5019
+ >>> with Client("http://localhost.com", "masterKey") as client:
5020
+ >>> index = client.index("movies")
5021
+ >>> updated_index = index.update()
4984
5022
  """
4985
5023
  payload = {"primaryKey": primary_key}
4986
5024
  response = self._http_requests.patch(self._base_url_with_uid, payload)
@@ -5001,9 +5039,9 @@ class Index(_BaseIndex):
5001
5039
 
5002
5040
  Examples
5003
5041
  >>> from meilisearch_python_sdk import Client
5004
- >>> client = Client("http://localhost.com", "masterKey")
5005
- >>> index = client.index("movies")
5006
- >>> index_info = index.fetch_info()
5042
+ >>> with Client("http://localhost.com", "masterKey") as client:
5043
+ >>> index = client.index("movies")
5044
+ >>> index_info = index.fetch_info()
5007
5045
  """
5008
5046
  response = self._http_requests.get(self._base_url_with_uid)
5009
5047
  index_dict = response.json()
@@ -5024,9 +5062,9 @@ class Index(_BaseIndex):
5024
5062
 
5025
5063
  Examples
5026
5064
  >>> from meilisearch_python_sdk import Client
5027
- >>> client = Client("http://localhost.com", "masterKey")
5028
- >>> index = client.index("movies")
5029
- >>> primary_key = index.get_primary_key()
5065
+ >>> with Client("http://localhost.com", "masterKey") as client:
5066
+ >>> index = client.index("movies")
5067
+ >>> primary_key = index.get_primary_key()
5030
5068
  """
5031
5069
  info = self.fetch_info()
5032
5070
  return info.primary_key
@@ -5083,8 +5121,8 @@ class Index(_BaseIndex):
5083
5121
 
5084
5122
  Examples
5085
5123
  >>> from meilisearch_python_sdk import Client
5086
- >>> client = Client("http://localhost.com", "masterKey")
5087
- >>> index = index.create(client, "movies")
5124
+ >>> with Client("http://localhost.com", "masterKey") as client:
5125
+ >>> index = index.create(client, "movies")
5088
5126
  """
5089
5127
  if not primary_key:
5090
5128
  payload = {"uid": uid}
@@ -5128,9 +5166,9 @@ class Index(_BaseIndex):
5128
5166
 
5129
5167
  Examples
5130
5168
  >>> from meilisearch_python_sdk import Client
5131
- >>> client = Client("http://localhost.com", "masterKey")
5132
- >>> index = client.index("movies")
5133
- >>> stats = index.get_stats()
5169
+ >>> with Client("http://localhost.com", "masterKey") as client:
5170
+ >>> index = client.index("movies")
5171
+ >>> stats = index.get_stats()
5134
5172
  """
5135
5173
  response = self._http_requests.get(self._stats_url)
5136
5174
 
@@ -5244,9 +5282,9 @@ class Index(_BaseIndex):
5244
5282
 
5245
5283
  Examples
5246
5284
  >>> from meilisearch_python_sdk import Client
5247
- >>> client = Client("http://localhost.com", "masterKey")
5248
- >>> index = client.index("movies")
5249
- >>> search_results = index.search("Tron")
5285
+ >>> with Client("http://localhost.com", "masterKey") as client:
5286
+ >>> index = client.index("movies")
5287
+ >>> search_results = index.search("Tron")
5250
5288
  """
5251
5289
  if ranking_score_threshold:
5252
5290
  _validate_ranking_score_threshold(ranking_score_threshold)
@@ -5415,13 +5453,13 @@ class Index(_BaseIndex):
5415
5453
 
5416
5454
  Examples
5417
5455
  >>> from meilisearch_python_sdk import Client
5418
- >>> client = Client("http://localhost.com", "masterKey")
5419
- >>> index = client.index("movies")
5420
- >>> search_results = index.search(
5421
- >>> "Tron",
5422
- >>> facet_name="genre",
5423
- >>> facet_query="Sci-fi"
5424
- >>> )
5456
+ >>> with Client("http://localhost.com", "masterKey") as client:
5457
+ >>> index = client.index("movies")
5458
+ >>> search_results = index.search(
5459
+ >>> "Tron",
5460
+ >>> facet_name="genre",
5461
+ >>> facet_query="Sci-fi"
5462
+ >>> )
5425
5463
  """
5426
5464
  if ranking_score_threshold:
5427
5465
  _validate_ranking_score_threshold(ranking_score_threshold)
@@ -5534,9 +5572,9 @@ class Index(_BaseIndex):
5534
5572
 
5535
5573
  Examples
5536
5574
  >>> from meilisearch_python_sdk import Client
5537
- >>> client = Client("http://localhost.com", "masterKey")
5538
- >>> index = client.index("movies")
5539
- >>> search_results = index.search_similar_documents("123")
5575
+ >>> with Client("http://localhost.com", "masterKey") as client:
5576
+ >>> index = client.index("movies")
5577
+ >>> search_results = index.search_similar_documents("123")
5540
5578
  """
5541
5579
  payload = {
5542
5580
  "id": id,
@@ -5583,9 +5621,9 @@ class Index(_BaseIndex):
5583
5621
 
5584
5622
  Examples
5585
5623
  >>> from meilisearch_python_sdk import Client
5586
- >>> client = Client("http://localhost.com", "masterKey")
5587
- >>> index = client.index("movies")
5588
- >>> document = index.get_document("1234")
5624
+ >>> with Client("http://localhost.com", "masterKey") as client:
5625
+ >>> index = client.index("movies")
5626
+ >>> document = index.get_document("1234")
5589
5627
  """
5590
5628
  parameters: JsonDict = {}
5591
5629
 
@@ -5633,9 +5671,9 @@ class Index(_BaseIndex):
5633
5671
 
5634
5672
  Examples
5635
5673
  >>> from meilisearch_python_sdk import Client
5636
- >>> client = Client("http://localhost.com", "masterKey")
5637
- >>> index = client.index("movies")
5638
- >>> documents = index.get_documents()
5674
+ >>> with Client("http://localhost.com", "masterKey") as client:
5675
+ >>> index = client.index("movies")
5676
+ >>> documents = index.get_documents()
5639
5677
  """
5640
5678
  parameters: JsonDict = {
5641
5679
  "offset": offset,
@@ -5694,9 +5732,9 @@ class Index(_BaseIndex):
5694
5732
  >>> {"id": 1, "title": "Movie 1", "genre": "comedy"},
5695
5733
  >>> {"id": 2, "title": "Movie 2", "genre": "drama"},
5696
5734
  >>> ]
5697
- >>> client = Client("http://localhost.com", "masterKey")
5698
- >>> index = client.index("movies")
5699
- >>> index.add_documents(documents)
5735
+ >>> with Client("http://localhost.com", "masterKey") as client:
5736
+ >>> index = client.index("movies")
5737
+ >>> index.add_documents(documents)
5700
5738
  """
5701
5739
  if primary_key:
5702
5740
  url = _build_encoded_url(self._documents_url, {"primaryKey": primary_key})
@@ -5753,9 +5791,9 @@ class Index(_BaseIndex):
5753
5791
  >>> {"id": 1, "title": "Movie 1", "genre": "comedy"},
5754
5792
  >>> {"id": 2, "title": "Movie 2", "genre": "drama"},
5755
5793
  >>> ]
5756
- >>> client = Client("http://localhost.com", "masterKey")
5757
- >>> index = client.index("movies")
5758
- >>> index.add_documents_in_batches(documents)
5794
+ >>> with Client("http://localhost.com", "masterKey") as client:
5795
+ >>> index = client.index("movies")
5796
+ >>> index.add_documents_in_batches(documents)
5759
5797
  """
5760
5798
  return [
5761
5799
  self.add_documents(x, primary_key, compress=compress)
@@ -5800,9 +5838,9 @@ class Index(_BaseIndex):
5800
5838
  >>> from pathlib import Path
5801
5839
  >>> from meilisearch_python_sdk import Client
5802
5840
  >>> directory_path = Path("/path/to/directory/containing/files")
5803
- >>> client = Client("http://localhost.com", "masterKey")
5804
- >>> index = client.index("movies")
5805
- >>> index.add_documents_from_directory(directory_path)
5841
+ >>> with Client("http://localhost.com", "masterKey") as client:
5842
+ >>> index = client.index("movies")
5843
+ >>> index.add_documents_from_directory(directory_path)
5806
5844
  """
5807
5845
  directory = Path(directory_path) if isinstance(directory_path, str) else directory_path
5808
5846
 
@@ -5876,9 +5914,9 @@ class Index(_BaseIndex):
5876
5914
  >>> from pathlib import Path
5877
5915
  >>> from meilisearch_python_sdk import Client
5878
5916
  >>> directory_path = Path("/path/to/directory/containing/files")
5879
- >>> client = Client("http://localhost.com", "masterKey")
5880
- >>> index = client.index("movies")
5881
- >>> index.add_documents_from_directory_in_batches(directory_path)
5917
+ >>> with Client("http://localhost.com", "masterKey") as client:
5918
+ >>> index = client.index("movies")
5919
+ >>> index.add_documents_from_directory_in_batches(directory_path)
5882
5920
  """
5883
5921
  directory = Path(directory_path) if isinstance(directory_path, str) else directory_path
5884
5922
 
@@ -5949,9 +5987,9 @@ class Index(_BaseIndex):
5949
5987
  >>> from pathlib import Path
5950
5988
  >>> from meilisearch_python_sdk import Client
5951
5989
  >>> file_path = Path("/path/to/file.json")
5952
- >>> client = Client("http://localhost.com", "masterKey")
5953
- >>> index = client.index("movies")
5954
- >>> index.add_documents_from_file(file_path)
5990
+ >>> with Client("http://localhost.com", "masterKey") as client:
5991
+ >>> index = client.index("movies")
5992
+ >>> index.add_documents_from_file(file_path)
5955
5993
  """
5956
5994
  documents = _load_documents_from_file(file_path, json_handler=self._json_handler)
5957
5995
 
@@ -5991,9 +6029,9 @@ class Index(_BaseIndex):
5991
6029
  >>> from pathlib import Path
5992
6030
  >>> from meilisearch_python_sdk import Client
5993
6031
  >>> file_path = Path("/path/to/file.json")
5994
- >>> client = Client("http://localhost.com", "masterKey")
5995
- >>> index = client.index("movies")
5996
- >>> index.add_documents_from_file_in_batches(file_path)
6032
+ >>> with Client("http://localhost.com", "masterKey") as client:
6033
+ >>> index = client.index("movies")
6034
+ >>> index.add_documents_from_file_in_batches(file_path)
5997
6035
  """
5998
6036
  documents = _load_documents_from_file(
5999
6037
  file_path, csv_delimiter, json_handler=self._json_handler
@@ -6042,9 +6080,9 @@ class Index(_BaseIndex):
6042
6080
  >>> from pathlib import Path
6043
6081
  >>> from meilisearch_python_sdk import Client
6044
6082
  >>> file_path = Path("/path/to/file.csv")
6045
- >>> client = Client("http://localhost.com", "masterKey")
6046
- >>> index = client.index("movies")
6047
- >>> index.add_documents_from_raw_file(file_path)
6083
+ >>> with Client("http://localhost.com", "masterKey") as client:
6084
+ >>> index = client.index("movies")
6085
+ >>> index.add_documents_from_raw_file(file_path)
6048
6086
  """
6049
6087
  upload_path = Path(file_path) if isinstance(file_path, str) else file_path
6050
6088
  if not upload_path.exists():
@@ -6110,9 +6148,9 @@ class Index(_BaseIndex):
6110
6148
 
6111
6149
  Examples
6112
6150
  >>> from meilisearch_python_sdk import Client
6113
- >>> client = Client("http://localhost.com", "masterKey")
6114
- >>> index = client.index("movies")
6115
- >>> index.edit_documents("doc.title = `${doc.title.to_upper()}`")
6151
+ >>> with Client("http://localhost.com", "masterKey") as client:
6152
+ >>> index = client.index("movies")
6153
+ >>> index.edit_documents("doc.title = `${doc.title.to_upper()}`")
6116
6154
  """
6117
6155
  url = f"{self._documents_url}/edit"
6118
6156
  payload: JsonDict = {"function": function}
@@ -6155,9 +6193,9 @@ class Index(_BaseIndex):
6155
6193
  >>> {"id": 1, "title": "Movie 1", "genre": "comedy"},
6156
6194
  >>> {"id": 2, "title": "Movie 2", "genre": "drama"},
6157
6195
  >>> ]
6158
- >>> client = Client("http://localhost.com", "masterKey")
6159
- >>> index = client.index("movies")
6160
- >>> index.update_documents(documents)
6196
+ >>> with Client("http://localhost.com", "masterKey") as client:
6197
+ >>> index = client.index("movies")
6198
+ >>> index.update_documents(documents)
6161
6199
  """
6162
6200
  if primary_key:
6163
6201
  url = _build_encoded_url(self._documents_url, {"primaryKey": primary_key})
@@ -6218,9 +6256,9 @@ class Index(_BaseIndex):
6218
6256
  >>> {"id": 1, "title": "Movie 1", "genre": "comedy"},
6219
6257
  >>> {"id": 2, "title": "Movie 2", "genre": "drama"},
6220
6258
  >>> ]
6221
- >>> client = Client("http://localhost.com", "masterKey")
6222
- >>> index = client.index("movies")
6223
- >>> index.update_documents_in_batches(documents)
6259
+ >>> with Client("http://localhost.com", "masterKey") client:
6260
+ >>> index = client.index("movies")
6261
+ >>> index.update_documents_in_batches(documents)
6224
6262
  """
6225
6263
  return [
6226
6264
  self.update_documents(x, primary_key, compress=compress)
@@ -6265,9 +6303,9 @@ class Index(_BaseIndex):
6265
6303
  >>> from pathlib import Path
6266
6304
  >>> from meilisearch_python_sdk import Client
6267
6305
  >>> directory_path = Path("/path/to/directory/containing/files")
6268
- >>> client = Client("http://localhost.com", "masterKey")
6269
- >>> index = client.index("movies")
6270
- >>> index.update_documents_from_directory(directory_path)
6306
+ >>> with Client("http://localhost.com", "masterKey") as client:
6307
+ >>> index = client.index("movies")
6308
+ >>> index.update_documents_from_directory(directory_path)
6271
6309
  """
6272
6310
  directory = Path(directory_path) if isinstance(directory_path, str) else directory_path
6273
6311
 
@@ -6340,9 +6378,9 @@ class Index(_BaseIndex):
6340
6378
  >>> from pathlib import Path
6341
6379
  >>> from meilisearch_python_sdk import Client
6342
6380
  >>> directory_path = Path("/path/to/directory/containing/files")
6343
- >>> client = Client("http://localhost.com", "masterKey")
6344
- >>> index = client.index("movies")
6345
- >>> index.update_documents_from_directory_in_batches(directory_path)
6381
+ >>> with Client("http://localhost.com", "masterKey") as client:
6382
+ >>> index = client.index("movies")
6383
+ >>> index.update_documents_from_directory_in_batches(directory_path)
6346
6384
  """
6347
6385
  directory = Path(directory_path) if isinstance(directory_path, str) else directory_path
6348
6386
 
@@ -6415,9 +6453,9 @@ class Index(_BaseIndex):
6415
6453
  >>> from pathlib import Path
6416
6454
  >>> from meilisearch_python_sdk import Client
6417
6455
  >>> file_path = Path("/path/to/file.json")
6418
- >>> client = Client("http://localhost.com", "masterKey") as client:
6419
- >>> index = client.index("movies")
6420
- >>> index.update_documents_from_file(file_path)
6456
+ >>> with Client("http://localhost.com", "masterKey") as client:
6457
+ >>> index = client.index("movies")
6458
+ >>> index.update_documents_from_file(file_path)
6421
6459
  """
6422
6460
  documents = _load_documents_from_file(
6423
6461
  file_path, csv_delimiter, json_handler=self._json_handler
@@ -6454,9 +6492,9 @@ class Index(_BaseIndex):
6454
6492
  >>> from pathlib import Path
6455
6493
  >>> from meilisearch_python_sdk import Client
6456
6494
  >>> file_path = Path("/path/to/file.json")
6457
- >>> client = Client("http://localhost.com", "masterKey") as client:
6458
- >>> index = client.index("movies")
6459
- >>> index.update_documents_from_file_in_batches(file_path)
6495
+ >>> with Client("http://localhost.com", "masterKey") as client:
6496
+ >>> index = client.index("movies")
6497
+ >>> index.update_documents_from_file_in_batches(file_path)
6460
6498
  """
6461
6499
  documents = _load_documents_from_file(file_path, json_handler=self._json_handler)
6462
6500
 
@@ -6503,9 +6541,9 @@ class Index(_BaseIndex):
6503
6541
  >>> from pathlib import Path
6504
6542
  >>> from meilisearch_python_sdk import Client
6505
6543
  >>> file_path = Path("/path/to/file.csv")
6506
- >>> client = Client("http://localhost.com", "masterKey")
6507
- >>> index = client.index("movies")
6508
- >>> index.update_documents_from_raw_file(file_path)
6544
+ >>> with Client("http://localhost.com", "masterKey") as client:
6545
+ >>> index = client.index("movies")
6546
+ >>> index.update_documents_from_raw_file(file_path)
6509
6547
  """
6510
6548
  upload_path = Path(file_path) if isinstance(file_path, str) else file_path
6511
6549
  if not upload_path.exists():
@@ -6562,9 +6600,9 @@ class Index(_BaseIndex):
6562
6600
 
6563
6601
  Examples
6564
6602
  >>> from meilisearch_python_sdk import Client
6565
- >>> client = Client("http://localhost.com", "masterKey")
6566
- >>> index = client.index("movies")
6567
- >>> index.delete_document("1234")
6603
+ >>> with Client("http://localhost.com", "masterKey") as client:
6604
+ >>> index = client.index("movies")
6605
+ >>> index.delete_document("1234")
6568
6606
  """
6569
6607
  if self._pre_delete_document_plugins:
6570
6608
  Index._run_plugins(
@@ -6595,9 +6633,9 @@ class Index(_BaseIndex):
6595
6633
 
6596
6634
  Examples
6597
6635
  >>> from meilisearch_python_sdk import Client
6598
- >>> client = Client("http://localhost.com", "masterKey")
6599
- >>> index = client.index("movies")
6600
- >>> index.delete_documents(["1234", "5678"])
6636
+ >>> with Client("http://localhost.com", "masterKey") as client:
6637
+ >>> index = client.index("movies")
6638
+ >>> index.delete_documents(["1234", "5678"])
6601
6639
  """
6602
6640
  if self._pre_delete_documents_plugins:
6603
6641
  Index._run_plugins(self._pre_delete_documents_plugins, Event.PRE, ids=ids)
@@ -6628,9 +6666,9 @@ class Index(_BaseIndex):
6628
6666
 
6629
6667
  Examples
6630
6668
  >>> from meilisearch_python_sdk import Client
6631
- >>> client = Client("http://localhost.com", "masterKey")
6632
- >>> index = client.index("movies")
6633
- >>> index.delete_documents_by_filter("genre=horor"))
6669
+ >>> with Client("http://localhost.com", "masterKey") as client:
6670
+ >>> index = client.index("movies")
6671
+ >>> index.delete_documents_by_filter("genre=horor"))
6634
6672
  """
6635
6673
  if self._pre_delete_documents_by_filter_plugins:
6636
6674
  Index._run_plugins(
@@ -6667,14 +6705,14 @@ class Index(_BaseIndex):
6667
6705
 
6668
6706
  Examples
6669
6707
  >>> from meilisearch_python_sdk import Client
6670
- >>> client = Client("http://localhost.com", "masterKey")
6671
- >>> index = client.index("movies")
6672
- >>> index.delete_documents_in_batches_by_filter(
6673
- >>> [
6674
- >>> "genre=horor"),
6675
- >>> "release_date=1520035200"),
6676
- >>> ]
6677
- >>> )
6708
+ >>> with Client("http://localhost.com", "masterKey") as client:
6709
+ >>> index = client.index("movies")
6710
+ >>> index.delete_documents_in_batches_by_filter(
6711
+ >>> [
6712
+ >>> "genre=horor"),
6713
+ >>> "release_date=1520035200"),
6714
+ >>> ]
6715
+ >>> )
6678
6716
  """
6679
6717
  return [self.delete_documents_by_filter(filter) for filter in filters]
6680
6718
 
@@ -6690,9 +6728,9 @@ class Index(_BaseIndex):
6690
6728
 
6691
6729
  Examples
6692
6730
  >>> from meilisearch_python_sdk import Client
6693
- >>> client = Client("http://localhost.com", "masterKey")
6694
- >>> index = client.index("movies")
6695
- >>> index.delete_all_document()
6731
+ >>> with Client("http://localhost.com", "masterKey") as client:
6732
+ >>> index = client.index("movies")
6733
+ >>> index.delete_all_document()
6696
6734
  """
6697
6735
  if self._pre_delete_all_documents_plugins:
6698
6736
  Index._run_plugins(self._pre_delete_all_documents_plugins, Event.PRE)
@@ -6720,9 +6758,9 @@ class Index(_BaseIndex):
6720
6758
 
6721
6759
  Examples
6722
6760
  >>> from meilisearch_python_sdk import Client
6723
- >>> client = Client("http://localhost.com", "masterKey")
6724
- >>> index = client.index("movies")
6725
- >>> settings = index.get_settings()
6761
+ >>> with Client("http://localhost.com", "masterKey") as client:
6762
+ >>> index = client.index("movies")
6763
+ >>> settings = index.get_settings()
6726
6764
  """
6727
6765
  response = self._http_requests.get(self._settings_url)
6728
6766
  response_json = response.json()
@@ -6772,9 +6810,9 @@ class Index(_BaseIndex):
6772
6810
  >>> displayed_attributes=["title", "description", "genre", "release_date"],
6773
6811
  >>> sortable_attributes=["title", "release_date"],
6774
6812
  >>> )
6775
- >>> client = Client("http://localhost.com", "masterKey")
6776
- >>> index = client.index("movies")
6777
- >>> index.update_settings(new_settings)
6813
+ >>> with Client("http://localhost.com", "masterKey") as client:
6814
+ >>> index = client.index("movies")
6815
+ >>> index.update_settings(new_settings)
6778
6816
  """
6779
6817
  body_dict = {
6780
6818
  k: v
@@ -6797,9 +6835,9 @@ class Index(_BaseIndex):
6797
6835
 
6798
6836
  Examples
6799
6837
  >>> from meilisearch_python_sdk import Client
6800
- >>> client = Client("http://localhost.com", "masterKey")
6801
- >>> index = client.index("movies")
6802
- >>> index.reset_settings()
6838
+ >>> with Client("http://localhost.com", "masterKey") as client:
6839
+ >>> index = client.index("movies")
6840
+ >>> index.reset_settings()
6803
6841
  """
6804
6842
  response = self._http_requests.delete(self._settings_url)
6805
6843
 
@@ -6817,9 +6855,9 @@ class Index(_BaseIndex):
6817
6855
 
6818
6856
  Examples
6819
6857
  >>> from meilisearch_python_sdk import Client
6820
- >>> client = Client("http://localhost.com", "masterKey")
6821
- >>> index = client.index("movies")
6822
- >>> ranking_rules = index.get_ranking_rules()
6858
+ >>> with Client("http://localhost.com", "masterKey") as client:
6859
+ >>> index = client.index("movies")
6860
+ >>> ranking_rules = index.get_ranking_rules()
6823
6861
  """
6824
6862
  response = self._http_requests.get(f"{self._settings_url}/ranking-rules")
6825
6863
 
@@ -6851,9 +6889,9 @@ class Index(_BaseIndex):
6851
6889
  >>> "release_date:desc",
6852
6890
  >>> "rank:desc",
6853
6891
  >>> ],
6854
- >>> client = Client("http://localhost.com", "masterKey")
6855
- >>> index = client.index("movies")
6856
- >>> index.update_ranking_rules(ranking_rules)
6892
+ >>> with Client("http://localhost.com", "masterKey") as client:
6893
+ >>> index = client.index("movies")
6894
+ >>> index.update_ranking_rules(ranking_rules)
6857
6895
  """
6858
6896
  response = self._http_requests.put(
6859
6897
  f"{self._settings_url}/ranking-rules", ranking_rules, compress=compress
@@ -6873,9 +6911,9 @@ class Index(_BaseIndex):
6873
6911
 
6874
6912
  Examples
6875
6913
  >>> from meilisearch_python_sdk import Client
6876
- >>> client = Client("http://localhost.com", "masterKey")
6877
- >>> index = client.index("movies")
6878
- >>> index.reset_ranking_rules()
6914
+ >>> with Client("http://localhost.com", "masterKey") as client:
6915
+ >>> index = client.index("movies")
6916
+ >>> index.reset_ranking_rules()
6879
6917
  """
6880
6918
  response = self._http_requests.delete(f"{self._settings_url}/ranking-rules")
6881
6919
 
@@ -6894,9 +6932,9 @@ class Index(_BaseIndex):
6894
6932
 
6895
6933
  Examples
6896
6934
  >>> from meilisearch_python_sdk import Client
6897
- >>> client = Client("http://localhost.com", "masterKey")
6898
- >>> index = client.index("movies")
6899
- >>> distinct_attribute = index.get_distinct_attribute()
6935
+ >>> with Client("http://localhost.com", "masterKey") as client:
6936
+ >>> index = client.index("movies")
6937
+ >>> distinct_attribute = index.get_distinct_attribute()
6900
6938
  """
6901
6939
  response = self._http_requests.get(f"{self._settings_url}/distinct-attribute")
6902
6940
 
@@ -6921,9 +6959,9 @@ class Index(_BaseIndex):
6921
6959
 
6922
6960
  Examples
6923
6961
  >>> from meilisearch_python_sdk import Client
6924
- >>> client = Client("http://localhost.com", "masterKey")
6925
- >>> index = client.index("movies")
6926
- >>> index.update_distinct_attribute("url")
6962
+ >>> with Client("http://localhost.com", "masterKey") as client:
6963
+ >>> index = client.index("movies")
6964
+ >>> index.update_distinct_attribute("url")
6927
6965
  """
6928
6966
  response = self._http_requests.put(
6929
6967
  f"{self._settings_url}/distinct-attribute", body, compress=compress
@@ -6943,9 +6981,9 @@ class Index(_BaseIndex):
6943
6981
 
6944
6982
  Examples
6945
6983
  >>> from meilisearch_python_sdk import Client
6946
- >>> client = Client("http://localhost.com", "masterKey")
6947
- >>> index = client.index("movies")
6948
- >>> index.reset_distinct_attributes()
6984
+ >>> with Client("http://localhost.com", "masterKey") as client:
6985
+ >>> index = client.index("movies")
6986
+ >>> index.reset_distinct_attributes()
6949
6987
  """
6950
6988
  response = self._http_requests.delete(f"{self._settings_url}/distinct-attribute")
6951
6989
 
@@ -6963,9 +7001,9 @@ class Index(_BaseIndex):
6963
7001
 
6964
7002
  Examples
6965
7003
  >>> from meilisearch_python_sdk import Client
6966
- >>> client = Client("http://localhost.com", "masterKey")
6967
- >>> index = client.index("movies")
6968
- >>> searchable_attributes = index.get_searchable_attributes()
7004
+ >>> with Client("http://localhost.com", "masterKey") as client:
7005
+ >>> index = client.index("movies")
7006
+ >>> searchable_attributes = index.get_searchable_attributes()
6969
7007
  """
6970
7008
  response = self._http_requests.get(f"{self._settings_url}/searchable-attributes")
6971
7009
 
@@ -6987,9 +7025,9 @@ class Index(_BaseIndex):
6987
7025
 
6988
7026
  Examples
6989
7027
  >>> from meilisearch_python_sdk import Client
6990
- >>> client = Client("http://localhost.com", "masterKey")
6991
- >>> index = client.index("movies")
6992
- >>> index.update_searchable_attributes(["title", "description", "genre"])
7028
+ >>> with Client("http://localhost.com", "masterKey") as client:
7029
+ >>> index = client.index("movies")
7030
+ >>> index.update_searchable_attributes(["title", "description", "genre"])
6993
7031
  """
6994
7032
  response = self._http_requests.put(
6995
7033
  f"{self._settings_url}/searchable-attributes", body, compress=compress
@@ -7009,9 +7047,9 @@ class Index(_BaseIndex):
7009
7047
 
7010
7048
  Examples
7011
7049
  >>> from meilisearch_python_sdk import Client
7012
- >>> client = Client("http://localhost.com", "masterKey")
7013
- >>> index = client.index("movies")
7014
- >>> index.reset_searchable_attributes()
7050
+ >>> with Client("http://localhost.com", "masterKey") as client:
7051
+ >>> index = client.index("movies")
7052
+ >>> index.reset_searchable_attributes()
7015
7053
  """
7016
7054
  response = self._http_requests.delete(f"{self._settings_url}/searchable-attributes")
7017
7055
 
@@ -7029,9 +7067,9 @@ class Index(_BaseIndex):
7029
7067
 
7030
7068
  Examples
7031
7069
  >>> from meilisearch_python_sdk import Client
7032
- >>> client = Client("http://localhost.com", "masterKey")
7033
- >>> index = client.index("movies")
7034
- >>> displayed_attributes = index.get_displayed_attributes()
7070
+ >>> with Client("http://localhost.com", "masterKey") as client:
7071
+ >>> index = client.index("movies")
7072
+ >>> displayed_attributes = index.get_displayed_attributes()
7035
7073
  """
7036
7074
  response = self._http_requests.get(f"{self._settings_url}/displayed-attributes")
7037
7075
 
@@ -7053,11 +7091,11 @@ class Index(_BaseIndex):
7053
7091
 
7054
7092
  Examples
7055
7093
  >>> from meilisearch_python_sdk import Client
7056
- >>> client = Client("http://localhost.com", "masterKey")
7057
- >>> index = client.index("movies")
7058
- >>> index.update_displayed_attributes(
7059
- >>> ["title", "description", "genre", "release_date"]
7060
- >>> )
7094
+ >>> with Client("http://localhost.com", "masterKey") as client:
7095
+ >>> index = client.index("movies")
7096
+ >>> index.update_displayed_attributes(
7097
+ >>> ["title", "description", "genre", "release_date"]
7098
+ >>> )
7061
7099
  """
7062
7100
  response = self._http_requests.put(
7063
7101
  f"{self._settings_url}/displayed-attributes", body, compress=compress
@@ -7077,9 +7115,9 @@ class Index(_BaseIndex):
7077
7115
 
7078
7116
  Examples
7079
7117
  >>> from meilisearch_python_sdk import Client
7080
- >>> client = Client("http://localhost.com", "masterKey")
7081
- >>> index = client.index("movies")
7082
- >>> index.reset_displayed_attributes()
7118
+ >>> with Client("http://localhost.com", "masterKey") as client:
7119
+ >>> index = client.index("movies")
7120
+ >>> index.reset_displayed_attributes()
7083
7121
  """
7084
7122
  response = self._http_requests.delete(f"{self._settings_url}/displayed-attributes")
7085
7123
 
@@ -7097,9 +7135,9 @@ class Index(_BaseIndex):
7097
7135
 
7098
7136
  Examples
7099
7137
  >>> from meilisearch_python_sdk import Client
7100
- >>> client = Client("http://localhost.com", "masterKey")
7101
- >>> index = client.index("movies")
7102
- >>> stop_words = index.get_stop_words()
7138
+ >>> with Client("http://localhost.com", "masterKey") as client:
7139
+ >>> index = client.index("movies")
7140
+ >>> stop_words = index.get_stop_words()
7103
7141
  """
7104
7142
  response = self._http_requests.get(f"{self._settings_url}/stop-words")
7105
7143
 
@@ -7124,9 +7162,9 @@ class Index(_BaseIndex):
7124
7162
 
7125
7163
  Examples
7126
7164
  >>> from meilisearch_python_sdk import Client
7127
- >>> client = Client("http://localhost.com", "masterKey")
7128
- >>> index = client.index("movies")
7129
- >>> index.update_stop_words(["the", "a", "an"])
7165
+ >>> with Client("http://localhost.com", "masterKey") as client:
7166
+ >>> index = client.index("movies")
7167
+ >>> index.update_stop_words(["the", "a", "an"])
7130
7168
  """
7131
7169
  response = self._http_requests.put(
7132
7170
  f"{self._settings_url}/stop-words", body, compress=compress
@@ -7146,9 +7184,9 @@ class Index(_BaseIndex):
7146
7184
 
7147
7185
  Examples
7148
7186
  >>> from meilisearch_python_sdk import Client
7149
- >>> client = Client("http://localhost.com", "masterKey")
7150
- >>> index = client.index("movies")
7151
- >>> index.reset_stop_words()
7187
+ >>> with Client("http://localhost.com", "masterKey") as client:
7188
+ >>> index = client.index("movies")
7189
+ >>> index.reset_stop_words()
7152
7190
  """
7153
7191
  response = self._http_requests.delete(f"{self._settings_url}/stop-words")
7154
7192
 
@@ -7166,9 +7204,9 @@ class Index(_BaseIndex):
7166
7204
 
7167
7205
  Examples
7168
7206
  >>> from meilisearch_python_sdk import Client
7169
- >>> client = Client("http://localhost.com", "masterKey")
7170
- >>> index = client.index("movies")
7171
- >>> synonyms = index.get_synonyms()
7207
+ >>> with Client("http://localhost.com", "masterKey") as client:
7208
+ >>> index = client.index("movies")
7209
+ >>> synonyms = index.get_synonyms()
7172
7210
  """
7173
7211
  response = self._http_requests.get(f"{self._settings_url}/synonyms")
7174
7212
 
@@ -7192,11 +7230,11 @@ class Index(_BaseIndex):
7192
7230
 
7193
7231
  Examples
7194
7232
  >>> from meilisearch_python_sdk import Client
7195
- >>> client = Client("http://localhost.com", "masterKey") as client:
7196
- >>> index = client.index("movies")
7197
- >>> index.update_synonyms(
7198
- >>> {"wolverine": ["xmen", "logan"], "logan": ["wolverine"]}
7199
- >>> )
7233
+ >>> with Client("http://localhost.com", "masterKey") as client:
7234
+ >>> index = client.index("movies")
7235
+ >>> index.update_synonyms(
7236
+ >>> {"wolverine": ["xmen", "logan"], "logan": ["wolverine"]}
7237
+ >>> )
7200
7238
  """
7201
7239
  response = self._http_requests.put(
7202
7240
  f"{self._settings_url}/synonyms", body, compress=compress
@@ -7216,9 +7254,9 @@ class Index(_BaseIndex):
7216
7254
 
7217
7255
  Examples
7218
7256
  >>> from meilisearch_python_sdk import Client
7219
- >>> client = Client("http://localhost.com", "masterKey")
7220
- >>> index = client.index("movies")
7221
- >>> index.reset_synonyms()
7257
+ >>> with Client("http://localhost.com", "masterKey") as client:
7258
+ >>> index = client.index("movies")
7259
+ >>> index.reset_synonyms()
7222
7260
  """
7223
7261
  response = self._http_requests.delete(f"{self._settings_url}/synonyms")
7224
7262
 
@@ -7236,9 +7274,9 @@ class Index(_BaseIndex):
7236
7274
 
7237
7275
  Examples
7238
7276
  >>> from meilisearch_python_sdk import Client
7239
- >>> client = Client("http://localhost.com", "masterKey")
7240
- >>> index = client.index("movies")
7241
- >>> filterable_attributes = index.get_filterable_attributes()
7277
+ >>> with Client("http://localhost.com", "masterKey") as client:
7278
+ >>> index = client.index("movies")
7279
+ >>> filterable_attributes = index.get_filterable_attributes()
7242
7280
  """
7243
7281
  response = self._http_requests.get(f"{self._settings_url}/filterable-attributes")
7244
7282
 
@@ -7279,9 +7317,9 @@ class Index(_BaseIndex):
7279
7317
 
7280
7318
  Examples
7281
7319
  >>> from meilisearch_python_sdk import Client
7282
- >>> client = Client("http://localhost.com", "masterKey")
7283
- >>> index = client.index("movies")
7284
- >>> index.update_filterable_attributes(["genre", "director"])
7320
+ >>> with Client("http://localhost.com", "masterKey") as client:
7321
+ >>> index = client.index("movies")
7322
+ >>> index.update_filterable_attributes(["genre", "director"])
7285
7323
  """
7286
7324
  payload: list[str | JsonDict] = []
7287
7325
 
@@ -7309,9 +7347,9 @@ class Index(_BaseIndex):
7309
7347
 
7310
7348
  Examples
7311
7349
  >>> from meilisearch_python_sdk import Client
7312
- >>> client = Client("http://localhost.com", "masterKey")
7313
- >>> index = client.index("movies")
7314
- >>> index.reset_filterable_attributes()
7350
+ >>> with Client("http://localhost.com", "masterKey") as client:
7351
+ >>> index = client.index("movies")
7352
+ >>> index.reset_filterable_attributes()
7315
7353
  """
7316
7354
  response = self._http_requests.delete(f"{self._settings_url}/filterable-attributes")
7317
7355
 
@@ -7329,9 +7367,9 @@ class Index(_BaseIndex):
7329
7367
 
7330
7368
  Examples
7331
7369
  >>> from meilisearch_python_sdk import Client
7332
- >>> client = Client("http://localhost.com", "masterKey")
7333
- >>> index = client.index("movies")
7334
- >>> sortable_attributes = index.get_sortable_attributes()
7370
+ >>> with Client("http://localhost.com", "masterKey") as client:
7371
+ >>> index = client.index("movies")
7372
+ >>> sortable_attributes = index.get_sortable_attributes()
7335
7373
  """
7336
7374
  response = self._http_requests.get(f"{self._settings_url}/sortable-attributes")
7337
7375
 
@@ -7355,9 +7393,9 @@ class Index(_BaseIndex):
7355
7393
 
7356
7394
  Examples
7357
7395
  >>> from meilisearch_python_sdk import Client
7358
- >>> client = Client("http://localhost.com", "masterKey")
7359
- >>> index = client.index("movies")
7360
- >>> index.update_sortable_attributes(["title", "release_date"])
7396
+ >>> with Client("http://localhost.com", "masterKey") as client:
7397
+ >>> index = client.index("movies")
7398
+ >>> index.update_sortable_attributes(["title", "release_date"])
7361
7399
  """
7362
7400
  response = self._http_requests.put(
7363
7401
  f"{self._settings_url}/sortable-attributes", sortable_attributes, compress=compress
@@ -7377,9 +7415,9 @@ class Index(_BaseIndex):
7377
7415
 
7378
7416
  Examples
7379
7417
  >>> from meilisearch_python_sdk import Client
7380
- >>> client = Client("http://localhost.com", "masterKey")
7381
- >>> index = client.index("movies")
7382
- >>> index.reset_sortable_attributes()
7418
+ >>> with Client("http://localhost.com", "masterKey") as client:
7419
+ >>> index = client.index("movies")
7420
+ >>> index.reset_sortable_attributes()
7383
7421
  """
7384
7422
  response = self._http_requests.delete(f"{self._settings_url}/sortable-attributes")
7385
7423
 
@@ -7397,9 +7435,9 @@ class Index(_BaseIndex):
7397
7435
 
7398
7436
  Examples
7399
7437
  >>> from meilisearch_python_sdk import Client
7400
- >>> client = Client("http://localhost.com", "masterKey")
7401
- >>> index = client.index("movies")
7402
- >>> sortable_attributes = index.get_typo_tolerance()
7438
+ >>> with Client("http://localhost.com", "masterKey") as client:
7439
+ >>> index = client.index("movies")
7440
+ >>> sortable_attributes = index.get_typo_tolerance()
7403
7441
  """
7404
7442
  response = self._http_requests.get(f"{self._settings_url}/typo-tolerance")
7405
7443
 
@@ -7423,10 +7461,10 @@ class Index(_BaseIndex):
7423
7461
 
7424
7462
  Examples
7425
7463
  >>> from meilisearch_python_sdk import Client
7426
- >>> client = Client("http://localhost.com", "masterKey")
7427
- >>> index = client.index("movies")
7428
- >>> TypoTolerance(enabled=False)
7429
- >>> index.update_typo_tolerance()
7464
+ >>> with Client("http://localhost.com", "masterKey") as client:
7465
+ >>> index = client.index("movies")
7466
+ >>> TypoTolerance(enabled=False)
7467
+ >>> index.update_typo_tolerance()
7430
7468
  """
7431
7469
  response = self._http_requests.patch(
7432
7470
  f"{self._settings_url}/typo-tolerance",
@@ -7448,9 +7486,9 @@ class Index(_BaseIndex):
7448
7486
 
7449
7487
  Examples
7450
7488
  >>> from meilisearch_python_sdk import Client
7451
- >>> client = Client("http://localhost.com", "masterKey")
7452
- >>> index = client.index("movies")
7453
- >>> index.reset_typo_tolerance()
7489
+ >>> with Client("http://localhost.com", "masterKey") as client:
7490
+ >>> index = client.index("movies")
7491
+ >>> index.reset_typo_tolerance()
7454
7492
  """
7455
7493
  response = self._http_requests.delete(f"{self._settings_url}/typo-tolerance")
7456
7494
 
@@ -7468,9 +7506,9 @@ class Index(_BaseIndex):
7468
7506
 
7469
7507
  Examples
7470
7508
  >>> from meilisearch_python_sdk import Client
7471
- >>> client = Client("http://localhost.com", "masterKey")
7472
- >>> index = client.index("movies")
7473
- >>> faceting = index.get_faceting()
7509
+ >>> with Client("http://localhost.com", "masterKey") as client:
7510
+ >>> index = client.index("movies")
7511
+ >>> faceting = index.get_faceting()
7474
7512
  """
7475
7513
  response = self._http_requests.get(f"{self._settings_url}/faceting")
7476
7514
 
@@ -7492,9 +7530,9 @@ class Index(_BaseIndex):
7492
7530
 
7493
7531
  Examples
7494
7532
  >>> from meilisearch_python_sdk import Client
7495
- >>> client = Client("http://localhost.com", "masterKey")
7496
- >>> index = client.index("movies")
7497
- >>> index.update_faceting(faceting=Faceting(max_values_per_facet=100))
7533
+ >>> with Client("http://localhost.com", "masterKey") as client:
7534
+ >>> index = client.index("movies")
7535
+ >>> index.update_faceting(faceting=Faceting(max_values_per_facet=100))
7498
7536
  """
7499
7537
  response = self._http_requests.patch(
7500
7538
  f"{self._settings_url}/faceting",
@@ -7516,9 +7554,9 @@ class Index(_BaseIndex):
7516
7554
 
7517
7555
  Examples
7518
7556
  >>> from meilisearch_python_sdk import Client
7519
- >>> client = Client("http://localhost.com", "masterKey")
7520
- >>> index = client.index("movies")
7521
- >>> index.reset_faceting()
7557
+ >>> with Client("http://localhost.com", "masterKey") as client:
7558
+ >>> index = client.index("movies")
7559
+ >>> index.reset_faceting()
7522
7560
  """
7523
7561
  response = self._http_requests.delete(f"{self._settings_url}/faceting")
7524
7562
 
@@ -7536,9 +7574,9 @@ class Index(_BaseIndex):
7536
7574
 
7537
7575
  Examples
7538
7576
  >>> from meilisearch_async_client import Client
7539
- >>> client = Client("http://localhost.com", "masterKey")
7540
- >>> index = client.index("movies")
7541
- >>> pagination_settings = index.get_pagination()
7577
+ >>> with Client("http://localhost.com", "masterKey") as client:
7578
+ >>> index = client.index("movies")
7579
+ >>> pagination_settings = index.get_pagination()
7542
7580
  """
7543
7581
  response = self._http_requests.get(f"{self._settings_url}/pagination")
7544
7582
 
@@ -7561,9 +7599,9 @@ class Index(_BaseIndex):
7561
7599
  Examples
7562
7600
  >>> from meilisearch_python_sdk import Client
7563
7601
  >>> from meilisearch_python_sdk.models.settings import Pagination
7564
- >>> client = Client("http://localhost.com", "masterKey")
7565
- >>> index = client.index("movies")
7566
- >>> index.update_pagination(settings=Pagination(max_total_hits=123))
7602
+ >>> with Client("http://localhost.com", "masterKey") as client:
7603
+ >>> index = client.index("movies")
7604
+ >>> index.update_pagination(settings=Pagination(max_total_hits=123))
7567
7605
  """
7568
7606
  response = self._http_requests.patch(
7569
7607
  f"{self._settings_url}/pagination",
@@ -7585,9 +7623,9 @@ class Index(_BaseIndex):
7585
7623
 
7586
7624
  Examples
7587
7625
  >>> from meilisearch_async_client import Client
7588
- >>> client = Client("http://localhost.com", "masterKey")
7589
- >>> index = client.index("movies")
7590
- >>> index.reset_pagination()
7626
+ >>> with Client("http://localhost.com", "masterKey") as client:
7627
+ >>> index = client.index("movies")
7628
+ >>> index.reset_pagination()
7591
7629
  """
7592
7630
  response = self._http_requests.delete(f"{self._settings_url}/pagination")
7593
7631
 
@@ -7605,9 +7643,9 @@ class Index(_BaseIndex):
7605
7643
 
7606
7644
  Examples
7607
7645
  >>> from meilisearch_async_client import Client
7608
- >>> client = Client("http://localhost.com", "masterKey")
7609
- >>> index = client.index("movies")
7610
- >>> separator_token_settings = index.get_separator_tokens()
7646
+ >>> with Client("http://localhost.com", "masterKey") as client:
7647
+ >>> index = client.index("movies")
7648
+ >>> separator_token_settings = index.get_separator_tokens()
7611
7649
  """
7612
7650
  response = self._http_requests.get(f"{self._settings_url}/separator-tokens")
7613
7651
 
@@ -7631,9 +7669,9 @@ class Index(_BaseIndex):
7631
7669
 
7632
7670
  Examples
7633
7671
  >>> from meilisearch_python_sdk import Client
7634
- >>> client = Client("http://localhost.com", "masterKey")
7635
- >>> index = client.index("movies")
7636
- >>> index.update_separator_tokens(separator_tokenes=["|", "/")
7672
+ >>> with Client("http://localhost.com", "masterKey") as client:
7673
+ >>> index = client.index("movies")
7674
+ >>> index.update_separator_tokens(separator_tokenes=["|", "/")
7637
7675
  """
7638
7676
  response = self._http_requests.put(
7639
7677
  f"{self._settings_url}/separator-tokens", separator_tokens, compress=compress
@@ -7653,9 +7691,9 @@ class Index(_BaseIndex):
7653
7691
 
7654
7692
  Examples
7655
7693
  >>> from meilisearch_async_client import Client
7656
- >>> client = Client("http://localhost.com", "masterKey")
7657
- >>> index = client.index("movies")
7658
- >>> index.reset_separator_tokens()
7694
+ >>> with Client("http://localhost.com", "masterKey") as client:
7695
+ >>> index = client.index("movies")
7696
+ >>> index.reset_separator_tokens()
7659
7697
  """
7660
7698
  response = self._http_requests.delete(f"{self._settings_url}/separator-tokens")
7661
7699
 
@@ -7673,9 +7711,9 @@ class Index(_BaseIndex):
7673
7711
 
7674
7712
  Examples
7675
7713
  >>> from meilisearch_async_client import Client
7676
- >>> client = Client("http://localhost.com", "masterKey")
7677
- >>> index = client.index("movies")
7678
- >>> non_separator_token_settings = index.get_non_separator_tokens()
7714
+ >>> with Client("http://localhost.com", "masterKey") as client:
7715
+ >>> index = client.index("movies")
7716
+ >>> non_separator_token_settings = index.get_non_separator_tokens()
7679
7717
  """
7680
7718
  response = self._http_requests.get(f"{self._settings_url}/non-separator-tokens")
7681
7719
 
@@ -7699,9 +7737,9 @@ class Index(_BaseIndex):
7699
7737
 
7700
7738
  Examples
7701
7739
  >>> from meilisearch_python_sdk import Client
7702
- >>> client = Client("http://localhost.com", "masterKey")
7703
- >>> index = client.index("movies")
7704
- >>> index.update_non_separator_tokens(non_separator_tokens=["@", "#")
7740
+ >>> with Client("http://localhost.com", "masterKey") as client:
7741
+ >>> index = client.index("movies")
7742
+ >>> index.update_non_separator_tokens(non_separator_tokens=["@", "#")
7705
7743
  """
7706
7744
  response = self._http_requests.put(
7707
7745
  f"{self._settings_url}/non-separator-tokens", non_separator_tokens, compress=compress
@@ -7721,9 +7759,9 @@ class Index(_BaseIndex):
7721
7759
 
7722
7760
  Examples
7723
7761
  >>> from meilisearch_async_client import Client
7724
- >>> client = Client("http://localhost.com", "masterKey")
7725
- >>> index = client.index("movies")
7726
- >>> index.reset_non_separator_tokens()
7762
+ >>> with Client("http://localhost.com", "masterKey") as client:
7763
+ >>> index = client.index("movies")
7764
+ >>> index.reset_non_separator_tokens()
7727
7765
  """
7728
7766
  response = self._http_requests.delete(f"{self._settings_url}/non-separator-tokens")
7729
7767
 
@@ -7741,9 +7779,9 @@ class Index(_BaseIndex):
7741
7779
 
7742
7780
  Examples
7743
7781
  >>> from meilisearch_async_client import Client
7744
- >>> client = Client("http://localhost.com", "masterKey")
7745
- >>> index = client.index("movies")
7746
- >>> search_cutoff_ms_settings = index.get_search_cutoff_ms()
7782
+ >>> with Client("http://localhost.com", "masterKey") as client:
7783
+ >>> index = client.index("movies")
7784
+ >>> search_cutoff_ms_settings = index.get_search_cutoff_ms()
7747
7785
  """
7748
7786
  response = self._http_requests.get(f"{self._settings_url}/search-cutoff-ms")
7749
7787
 
@@ -7765,9 +7803,9 @@ class Index(_BaseIndex):
7765
7803
 
7766
7804
  Examples
7767
7805
  >>> from meilisearch_python_sdk import Client
7768
- >>> client = Client("http://localhost.com", "masterKey")
7769
- >>> index = client.index("movies")
7770
- >>> index.update_search_cutoff_ms(100)
7806
+ >>> with Client("http://localhost.com", "masterKey") as client:
7807
+ >>> index = client.index("movies")
7808
+ >>> index.update_search_cutoff_ms(100)
7771
7809
  """
7772
7810
  response = self._http_requests.put(
7773
7811
  f"{self._settings_url}/search-cutoff-ms", search_cutoff_ms, compress=compress
@@ -7787,9 +7825,9 @@ class Index(_BaseIndex):
7787
7825
 
7788
7826
  Examples
7789
7827
  >>> from meilisearch_async_client import Client
7790
- >>> client = Client("http://localhost.com", "masterKey")
7791
- >>> index = client.index("movies")
7792
- >>> index.reset_search_cutoff_ms()
7828
+ >>> with Client("http://localhost.com", "masterKey") as client:
7829
+ >>> index = client.index("movies")
7830
+ >>> index.reset_search_cutoff_ms()
7793
7831
  """
7794
7832
  response = self._http_requests.delete(f"{self._settings_url}/search-cutoff-ms")
7795
7833
 
@@ -7807,9 +7845,9 @@ class Index(_BaseIndex):
7807
7845
 
7808
7846
  Examples
7809
7847
  >>> from meilisearch_async_client import Client
7810
- >>> client = Client("http://localhost.com", "masterKey")
7811
- >>> index = client.index("movies")
7812
- >>> word_dictionary = index.get_word_dictionary()
7848
+ >>> with Client("http://localhost.com", "masterKey") as client:
7849
+ >>> index = client.index("movies")
7850
+ >>> word_dictionary = index.get_word_dictionary()
7813
7851
  """
7814
7852
  response = self._http_requests.get(f"{self._settings_url}/dictionary")
7815
7853
 
@@ -7831,9 +7869,9 @@ class Index(_BaseIndex):
7831
7869
 
7832
7870
  Examples
7833
7871
  >>> from meilisearch_python_sdk import Client
7834
- >>> client = Client("http://localhost.com", "masterKey")
7835
- >>> index = client.index("movies")
7836
- >>> index.update_word_dictionary(dictionary=["S.O.S", "S.O")
7872
+ >>> with Client("http://localhost.com", "masterKey") as client:
7873
+ >>> index = client.index("movies")
7874
+ >>> index.update_word_dictionary(dictionary=["S.O.S", "S.O")
7837
7875
  """
7838
7876
  response = self._http_requests.put(
7839
7877
  f"{self._settings_url}/dictionary", dictionary, compress=compress
@@ -7853,9 +7891,9 @@ class Index(_BaseIndex):
7853
7891
 
7854
7892
  Examples
7855
7893
  >>> from meilisearch_async_client import Client
7856
- >>> client = Client("http://localhost.com", "masterKey")
7857
- >>> index = client.index("movies")
7858
- >>> index.reset_word_dictionary()
7894
+ >>> with Client("http://localhost.com", "masterKey") as client:
7895
+ >>> index = client.index("movies")
7896
+ >>> index.reset_word_dictionary()
7859
7897
  """
7860
7898
  response = self._http_requests.delete(f"{self._settings_url}/dictionary")
7861
7899
 
@@ -7873,9 +7911,9 @@ class Index(_BaseIndex):
7873
7911
 
7874
7912
  Examples
7875
7913
  >>> from meilisearch_async_client import Client
7876
- >>> client = Client("http://localhost.com", "masterKey")
7877
- >>> index = client.index("movies")
7878
- >>> proximity_precision = index.get_proximity_precision()
7914
+ >>> with Client("http://localhost.com", "masterKey") as client:
7915
+ >>> index = client.index("movies")
7916
+ >>> proximity_precision = index.get_proximity_precision()
7879
7917
  """
7880
7918
  response = self._http_requests.get(f"{self._settings_url}/proximity-precision")
7881
7919
 
@@ -7900,9 +7938,9 @@ class Index(_BaseIndex):
7900
7938
  Examples
7901
7939
  >>> from meilisearch_python_sdk import Client
7902
7940
  >>> from meilisearch_python_sdk.models.settings import ProximityPrecision
7903
- >>> client = Client("http://localhost.com", "masterKey")
7904
- >>> index = client.index("movies")
7905
- >>> index.update_proximity_precision(ProximityPrecision.BY_ATTRIBUTE)
7941
+ >>> with Client("http://localhost.com", "masterKey") as client:
7942
+ >>> index = client.index("movies")
7943
+ >>> index.update_proximity_precision(ProximityPrecision.BY_ATTRIBUTE)
7906
7944
  """
7907
7945
  response = self._http_requests.put(
7908
7946
  f"{self._settings_url}/proximity-precision",
@@ -7924,9 +7962,9 @@ class Index(_BaseIndex):
7924
7962
 
7925
7963
  Examples
7926
7964
  >>> from meilisearch_async_client import Client
7927
- >>> client = Client("http://localhost.com", "masterKey")
7928
- >>> index = client.index("movies")
7929
- >>> index.reset_proximity_precision()
7965
+ >>> with Client("http://localhost.com", "masterKey") as client:
7966
+ >>> index = client.index("movies")
7967
+ >>> index.reset_proximity_precision()
7930
7968
  """
7931
7969
  response = self._http_requests.delete(f"{self._settings_url}/proximity-precision")
7932
7970
 
@@ -7944,9 +7982,9 @@ class Index(_BaseIndex):
7944
7982
 
7945
7983
  Examples
7946
7984
  >>> from meilisearch_async_client import Client
7947
- >>> client = Client("http://localhost.com", "masterKey")
7948
- >>> index = client.index("movies")
7949
- >>> embedders = await index.get_embedders()
7985
+ >>> with Client("http://localhost.com", "masterKey") as client:
7986
+ >>> index = client.index("movies")
7987
+ >>> embedders = await index.get_embedders()
7950
7988
  """
7951
7989
  response = self._http_requests.get(f"{self._settings_url}/embedders")
7952
7990
 
@@ -7969,11 +8007,11 @@ class Index(_BaseIndex):
7969
8007
  Examples
7970
8008
  >>> from meilisearch_python_sdk import Client
7971
8009
  >>> from meilisearch_python_sdk.models.settings import Embedders, UserProvidedEmbedder
7972
- >>> client = Client("http://localhost.com", "masterKey")
7973
- >>> index = client.index("movies")
7974
- >>> index.update_embedders(
7975
- >>> Embedders(embedders={dimensions=512)})
7976
- >>> )
8010
+ >>> with Client("http://localhost.com", "masterKey") as client:
8011
+ >>> index = client.index("movies")
8012
+ >>> index.update_embedders(
8013
+ >>> Embedders(embedders={dimensions=512)})
8014
+ >>> )
7977
8015
  """
7978
8016
  payload = {}
7979
8017
  for key, embedder in embedders.embedders.items():
@@ -8002,9 +8040,9 @@ class Index(_BaseIndex):
8002
8040
 
8003
8041
  Examples
8004
8042
  >>> from meilisearch_async_client import Client
8005
- >>> client = AsyncClient("http://localhost.com", "masterKey")
8006
- >>> index = client.index("movies")
8007
- >>> index.reset_embedders()
8043
+ >>> with Client("http://localhost.com", "masterKey") as client:
8044
+ >>> index = client.index("movies")
8045
+ >>> index.reset_embedders()
8008
8046
  """
8009
8047
  response = self._http_requests.delete(f"{self._settings_url}/embedders")
8010
8048
 
@@ -8022,9 +8060,9 @@ class Index(_BaseIndex):
8022
8060
 
8023
8061
  Examples
8024
8062
  >>> from meilisearch_async_client import AsyncClient
8025
- >>> client = Client("http://localhost.com", "masterKey")
8026
- >>> index = client.index("movies")
8027
- >>> localized_attributes = await index.get_localized_attributes()
8063
+ >>> with Client("http://localhost.com", "masterKey") as client:
8064
+ >>> index = client.index("movies")
8065
+ >>> localized_attributes = await index.get_localized_attributes()
8028
8066
  """
8029
8067
  response = self._http_requests.get(f"{self._settings_url}/localized-attributes")
8030
8068
 
@@ -8054,12 +8092,12 @@ class Index(_BaseIndex):
8054
8092
  >>> from meilisearch_python_sdk.models.settings import LocalizedAttributes
8055
8093
  >>>
8056
8094
  >>>
8057
- >>> client = Client("http://localhost.com", "masterKey")
8058
- >>> index = client.index("movies")
8059
- >>> index.update_localized_attributes([
8060
- >>> LocalizedAttributes(locales=["eng", "spa"], attribute_patterns=["*"]),
8061
- >>> LocalizedAttributes(locales=["ita"], attribute_patterns=["*_it"]),
8062
- >>> ])
8095
+ >>> with Client("http://localhost.com", "masterKey") as client:
8096
+ >>> index = client.index("movies")
8097
+ >>> index.update_localized_attributes([
8098
+ >>> LocalizedAttributes(locales=["eng", "spa"], attribute_patterns=["*"]),
8099
+ >>> LocalizedAttributes(locales=["ita"], attribute_patterns=["*_it"]),
8100
+ >>> ])
8063
8101
  """
8064
8102
  payload = [x.model_dump(by_alias=True) for x in localized_attributes]
8065
8103
  response = self._http_requests.put(
@@ -8100,9 +8138,9 @@ class Index(_BaseIndex):
8100
8138
 
8101
8139
  Examples
8102
8140
  >>> from meilisearch_async_client import Client
8103
- >>> client = Client("http://localhost.com", "masterKey")
8104
- >>> index = client.index("movies")
8105
- >>> facet_search = await index.get_facet_search()
8141
+ >>> with Client("http://localhost.com", "masterKey") as client:
8142
+ >>> index = client.index("movies")
8143
+ >>> facet_search = await index.get_facet_search()
8106
8144
  """
8107
8145
  response = self._http_requests.get(f"{self._settings_url}/facet-search")
8108
8146
 
@@ -8124,9 +8162,9 @@ class Index(_BaseIndex):
8124
8162
 
8125
8163
  Examples
8126
8164
  >>> from meilisearch_python_sdk import Client
8127
- >>> client = Client("http://localhost.com", "masterKey")
8128
- >>> index = client.index("movies")
8129
- >>> index.update_facet_search(True)
8165
+ >>> with Client("http://localhost.com", "masterKey") as client:
8166
+ >>> index = client.index("movies")
8167
+ >>> index.update_facet_search(True)
8130
8168
  """
8131
8169
  response = self._http_requests.put(
8132
8170
  f"{self._settings_url}/facet-search",
@@ -8148,9 +8186,9 @@ class Index(_BaseIndex):
8148
8186
 
8149
8187
  Examples
8150
8188
  >>> from meilisearch_async_client import Client
8151
- >>> client = Client("http://localhost.com", "masterKey")
8152
- >>> index = client.index("movies")
8153
- >>> await index.reset_facet_search()
8189
+ >>> with Client("http://localhost.com", "masterKey") as client:
8190
+ >>> index = client.index("movies")
8191
+ >>> await index.reset_facet_search()
8154
8192
  """
8155
8193
  response = self._http_requests.delete(f"{self._settings_url}/facet-search")
8156
8194
 
@@ -8168,9 +8206,9 @@ class Index(_BaseIndex):
8168
8206
 
8169
8207
  Examples
8170
8208
  >>> from meilisearch_async_client import Client
8171
- >>> client = Client("http://localhost.com", "masterKey")
8172
- >>> index = client.index("movies")
8173
- >>> prefix_search = index.get_prefix_search()
8209
+ >>> with Client("http://localhost.com", "masterKey") as client:
8210
+ >>> index = client.index("movies")
8211
+ >>> prefix_search = index.get_prefix_search()
8174
8212
  """
8175
8213
  response = self._http_requests.get(f"{self._settings_url}/prefix-search")
8176
8214
 
@@ -8197,9 +8235,9 @@ class Index(_BaseIndex):
8197
8235
 
8198
8236
  Examples
8199
8237
  >>> from meilisearch_python_sdk import Client
8200
- >>> client = Client("http://localhost.com", "masterKey")
8201
- >>> index = client.index("movies")
8202
- >>> index.update_prefix_search("disabled")
8238
+ >>> with Client("http://localhost.com", "masterKey") as client:
8239
+ >>> index = client.index("movies")
8240
+ >>> index.update_prefix_search("disabled")
8203
8241
  """
8204
8242
  response = self._http_requests.put(
8205
8243
  f"{self._settings_url}/prefix-search",
@@ -8221,9 +8259,9 @@ class Index(_BaseIndex):
8221
8259
 
8222
8260
  Examples
8223
8261
  >>> from meilisearch_async_client import Client
8224
- >>> client = Client("http://localhost.com", "masterKey")
8225
- >>> index = client.index("movies")
8226
- >>> index.reset_prefix_search()
8262
+ >>> with Client("http://localhost.com", "masterKey") as client:
8263
+ >>> index = client.index("movies")
8264
+ >>> index.reset_prefix_search()
8227
8265
  """
8228
8266
  response = self._http_requests.delete(f"{self._settings_url}/prefix-search")
8229
8267