meilisearch-python-sdk 2.2.3__tar.gz → 2.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of meilisearch-python-sdk might be problematic. Click here for more details.

Files changed (25) hide show
  1. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/PKG-INFO +1 -1
  2. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/_client.py +27 -4
  3. meilisearch_python_sdk-2.3.0/meilisearch_python_sdk/_version.py +1 -0
  4. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/index.py +41 -6
  5. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/pyproject.toml +1 -1
  6. meilisearch_python_sdk-2.2.3/meilisearch_python_sdk/_version.py +0 -1
  7. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/LICENSE +0 -0
  8. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/README.md +0 -0
  9. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/__init__.py +0 -0
  10. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/_http_requests.py +0 -0
  11. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/_task.py +0 -0
  12. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/_utils.py +0 -0
  13. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/decorators.py +0 -0
  14. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/errors.py +0 -0
  15. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/models/__init__.py +0 -0
  16. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/models/client.py +0 -0
  17. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/models/documents.py +0 -0
  18. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/models/health.py +0 -0
  19. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/models/index.py +0 -0
  20. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/models/search.py +0 -0
  21. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/models/settings.py +0 -0
  22. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/models/task.py +0 -0
  23. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/models/version.py +0 -0
  24. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/py.typed +0 -0
  25. {meilisearch_python_sdk-2.2.3 → meilisearch_python_sdk-2.3.0}/meilisearch_python_sdk/types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: meilisearch-python-sdk
3
- Version: 2.2.3
3
+ Version: 2.3.0
4
4
  Summary: A Python async client for the Meilisearch API
5
5
  Home-page: https://github.com/sanders41/meilisearch-python-sdk
6
6
  License: MIT
@@ -25,6 +25,7 @@ from meilisearch_python_sdk.models.client import (
25
25
  from meilisearch_python_sdk.models.health import Health
26
26
  from meilisearch_python_sdk.models.index import IndexInfo
27
27
  from meilisearch_python_sdk.models.search import SearchParams, SearchResultsWithUID
28
+ from meilisearch_python_sdk.models.settings import MeilisearchSettings
28
29
  from meilisearch_python_sdk.models.task import TaskInfo, TaskResult, TaskStatus
29
30
  from meilisearch_python_sdk.models.version import Version
30
31
  from meilisearch_python_sdk.types import JsonDict, JsonMapping
@@ -185,13 +186,24 @@ class AsyncClient(BaseClient):
185
186
 
186
187
  return TaskInfo(**response.json())
187
188
 
188
- async def create_index(self, uid: str, primary_key: str | None = None) -> AsyncIndex:
189
+ async def create_index(
190
+ self,
191
+ uid: str,
192
+ primary_key: str | None = None,
193
+ *,
194
+ settings: MeilisearchSettings | None = None,
195
+ ) -> AsyncIndex:
189
196
  """Creates a new index.
190
197
 
191
198
  Args:
192
199
 
193
200
  uid: The index's unique identifier.
194
201
  primary_key: The primary key of the documents. Defaults to None.
202
+ settings: Settings for the index. The settings can also be updated independently of
203
+ creating the index. The advantage to updating them here is updating the settings after
204
+ adding documents will cause the documents to be re-indexed. Because of this it will be
205
+ faster to update them before adding documents. Defaults to None (i.e. default
206
+ Meilisearch index settings).
195
207
 
196
208
  Returns:
197
209
 
@@ -208,7 +220,7 @@ class AsyncClient(BaseClient):
208
220
  >>> async with AsyncClient("http://localhost.com", "masterKey") as client:
209
221
  >>> index = await client.create_index("movies")
210
222
  """
211
- return await AsyncIndex.create(self.http_client, uid, primary_key)
223
+ return await AsyncIndex.create(self.http_client, uid, primary_key, settings=settings)
212
224
 
213
225
  async def create_snapshot(self) -> TaskInfo:
214
226
  """Trigger the creation of a Meilisearch snapshot.
@@ -1021,13 +1033,24 @@ class Client(BaseClient):
1021
1033
 
1022
1034
  return TaskInfo(**response.json())
1023
1035
 
1024
- def create_index(self, uid: str, primary_key: str | None = None) -> Index:
1036
+ def create_index(
1037
+ self,
1038
+ uid: str,
1039
+ primary_key: str | None = None,
1040
+ *,
1041
+ settings: MeilisearchSettings | None = None,
1042
+ ) -> Index:
1025
1043
  """Creates a new index.
1026
1044
 
1027
1045
  Args:
1028
1046
 
1029
1047
  uid: The index's unique identifier.
1030
1048
  primary_key: The primary key of the documents. Defaults to None.
1049
+ settings: Settings for the index. The settings can also be updated independently of
1050
+ creating the index. The advantage to updating them here is updating the settings after
1051
+ adding documents will cause the documents to be re-indexed. Because of this it will be
1052
+ faster to update them before adding documents. Defaults to None (i.e. default
1053
+ Meilisearch index settings).
1031
1054
 
1032
1055
  Returns:
1033
1056
 
@@ -1044,7 +1067,7 @@ class Client(BaseClient):
1044
1067
  >>> client = Client("http://localhost.com", "masterKey")
1045
1068
  >>> index = client.create_index("movies")
1046
1069
  """
1047
- return Index.create(self.http_client, uid, primary_key)
1070
+ return Index.create(self.http_client, uid, primary_key, settings=settings)
1048
1071
 
1049
1072
  def create_snapshot(self) -> TaskInfo:
1050
1073
  """Trigger the creation of a Meilisearch snapshot.
@@ -0,0 +1 @@
1
+ VERSION = "2.3.0"
@@ -223,7 +223,12 @@ class AsyncIndex(BaseIndex):
223
223
 
224
224
  @classmethod
225
225
  async def create(
226
- cls, http_client: AsyncClient, uid: str, primary_key: str | None = None
226
+ cls,
227
+ http_client: AsyncClient,
228
+ uid: str,
229
+ primary_key: str | None = None,
230
+ *,
231
+ settings: MeilisearchSettings | None = None,
227
232
  ) -> AsyncIndex:
228
233
  """Creates a new index.
229
234
 
@@ -233,9 +238,14 @@ class AsyncIndex(BaseIndex):
233
238
  Args:
234
239
 
235
240
  http_client: An instance of the AsyncClient. This automatically gets passed by the
236
- Client when creating and AsyncIndex instance.
241
+ Client when creating an AsyncIndex instance.
237
242
  uid: The index's unique identifier.
238
243
  primary_key: The primary key of the documents. Defaults to None.
244
+ settings: Settings for the index. The settings can also be updated independently of
245
+ creating the index. The advantage to updating them here is updating the settings after
246
+ adding documents will cause the documents to be re-indexed. Because of this it will be
247
+ faster to update them before adding documents. Defaults to None (i.e. default
248
+ Meilisearch index settings).
239
249
 
240
250
  Returns:
241
251
 
@@ -261,9 +271,10 @@ class AsyncIndex(BaseIndex):
261
271
  http_request = AsyncHttpRequests(http_client)
262
272
  response = await http_request.post(url, payload)
263
273
  await async_wait_for_task(http_client, response.json()["taskUid"], timeout_in_ms=100000)
274
+
264
275
  index_response = await http_request.get(f"{url}/{uid}")
265
276
  index_dict = index_response.json()
266
- return cls(
277
+ index = cls(
267
278
  http_client=http_client,
268
279
  uid=index_dict["uid"],
269
280
  primary_key=index_dict["primaryKey"],
@@ -271,6 +282,12 @@ class AsyncIndex(BaseIndex):
271
282
  updated_at=index_dict["updatedAt"],
272
283
  )
273
284
 
285
+ if settings:
286
+ settings_task = await index.update_settings(settings)
287
+ await async_wait_for_task(http_client, settings_task.task_uid, timeout_in_ms=100000)
288
+
289
+ return index
290
+
274
291
  async def get_stats(self) -> IndexStats:
275
292
  """Get stats of the index.
276
293
 
@@ -3015,7 +3032,14 @@ class Index(BaseIndex):
3015
3032
  return info.primary_key
3016
3033
 
3017
3034
  @classmethod
3018
- def create(cls, http_client: Client, uid: str, primary_key: str | None = None) -> Index:
3035
+ def create(
3036
+ cls,
3037
+ http_client: Client,
3038
+ uid: str,
3039
+ primary_key: str | None = None,
3040
+ *,
3041
+ settings: MeilisearchSettings | None = None,
3042
+ ) -> Index:
3019
3043
  """Creates a new index.
3020
3044
 
3021
3045
  In general this method should not be used directly and instead the index should be created
@@ -3024,9 +3048,14 @@ class Index(BaseIndex):
3024
3048
  Args:
3025
3049
 
3026
3050
  http_client: An instance of the Client. This automatically gets passed by the Client
3027
- when creating and Index instance.
3051
+ when creating an Index instance.
3028
3052
  uid: The index's unique identifier.
3029
3053
  primary_key: The primary key of the documents. Defaults to None.
3054
+ settings: Settings for the index. The settings can also be updated independently of
3055
+ creating the index. The advantage to updating them here is updating the settings after
3056
+ adding documents will cause the documents to be re-indexed. Because of this it will be
3057
+ faster to update them before adding documents. Defaults to None (i.e. default
3058
+ Meilisearch index settings).
3030
3059
 
3031
3060
  Returns:
3032
3061
 
@@ -3054,7 +3083,7 @@ class Index(BaseIndex):
3054
3083
  wait_for_task(http_client, response.json()["taskUid"], timeout_in_ms=100000)
3055
3084
  index_response = http_request.get(f"{url}/{uid}")
3056
3085
  index_dict = index_response.json()
3057
- return cls(
3086
+ index = cls(
3058
3087
  http_client=http_client,
3059
3088
  uid=index_dict["uid"],
3060
3089
  primary_key=index_dict["primaryKey"],
@@ -3062,6 +3091,12 @@ class Index(BaseIndex):
3062
3091
  updated_at=index_dict["updatedAt"],
3063
3092
  )
3064
3093
 
3094
+ if settings:
3095
+ settings_task = index.update_settings(settings)
3096
+ wait_for_task(http_client, settings_task.task_uid, timeout_in_ms=10000)
3097
+
3098
+ return index
3099
+
3065
3100
  def get_stats(self) -> IndexStats:
3066
3101
  """Get stats of the index.
3067
3102
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "meilisearch-python-sdk"
3
- version = "2.2.3"
3
+ version = "2.3.0"
4
4
  description = "A Python async client for the Meilisearch API"
5
5
  authors = ["Paul Sanders <psanders1@gmail.com>"]
6
6
  license = "MIT"
@@ -1 +0,0 @@
1
- VERSION = "2.2.3"