meilisearch-python-sdk 5.1.0__tar.gz → 5.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 (104) hide show
  1. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/.pre-commit-config.yaml +1 -1
  2. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/CONTRIBUTING.md +2 -2
  3. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/PKG-INFO +9 -9
  4. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/README.md +8 -8
  5. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/docs/async_index_api.md +1 -1
  6. meilisearch_python_sdk-5.3.0/docs/client_api.md +53 -0
  7. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/docs/json_handler.md +10 -10
  8. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/docs/plugins.md +42 -42
  9. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/docs/pydantic.md +1 -1
  10. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/add_documents_decorator.py +5 -5
  11. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/add_documents_in_batches.py +4 -4
  12. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/documents_and_search_results.py +11 -11
  13. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/orjson_example.py +3 -3
  14. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/search_tracker.py +7 -7
  15. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/ujson_example.py +3 -3
  16. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/update_settings.py +5 -5
  17. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/_client.py +111 -93
  18. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/_task.py +4 -4
  19. meilisearch_python_sdk-5.3.0/meilisearch_python_sdk/_version.py +1 -0
  20. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/decorators.py +6 -6
  21. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/index.py +336 -326
  22. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/pyproject.toml +2 -2
  23. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/conftest.py +2 -1
  24. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/test_async_documents.py +12 -0
  25. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/test_async_search.py +4 -4
  26. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/test_documents.py +12 -0
  27. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/test_search.py +4 -4
  28. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/uv.lock +399 -370
  29. meilisearch_python_sdk-5.1.0/docs/client_api.md +0 -35
  30. meilisearch_python_sdk-5.1.0/meilisearch_python_sdk/_version.py +0 -1
  31. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/.github/FUNDING.yml +0 -0
  32. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/.github/release-draft-template.yaml +0 -0
  33. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/.github/renovate.json5 +0 -0
  34. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/.github/workflows/docs_publish.yml +0 -0
  35. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/.github/workflows/nightly_testing.yml +0 -0
  36. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/.github/workflows/pypi_publish.yml +0 -0
  37. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/.github/workflows/release-drafter.yml +0 -0
  38. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/.github/workflows/testing.yml +0 -0
  39. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/.gitignore +0 -0
  40. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/LICENSE +0 -0
  41. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/assets/add_in_batches.png +0 -0
  42. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/assets/searches.png +0 -0
  43. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/codecov.yml +0 -0
  44. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/datasets/small_movies.json +0 -0
  45. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/docker-compose.https.yml +0 -0
  46. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/docker-compose.yml +0 -0
  47. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/docs/.nojekyll +0 -0
  48. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/docs/CNAME +0 -0
  49. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/docs/async_client_api.md +0 -0
  50. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/docs/css/custom.css +0 -0
  51. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/docs/decorators_api.md +0 -0
  52. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/docs/index.md +0 -0
  53. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/docs/index_api.md +0 -0
  54. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/docs/js/umami.js +0 -0
  55. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/docs/overrides/partials/footer.html +0 -0
  56. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/.gitignore +0 -0
  57. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/README.md +0 -0
  58. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/__init__.py +0 -0
  59. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/async_add_documents_decorator.py +0 -0
  60. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/async_add_documents_in_batches.py +0 -0
  61. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/async_documents_and_search_results.py +0 -0
  62. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/async_search_tracker.py +0 -0
  63. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/async_update_settings.py +0 -0
  64. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/fastapi_example.py +0 -0
  65. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/pyproject.toml +0 -0
  66. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/requirements.txt +0 -0
  67. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/tests/__init__.py +0 -0
  68. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/tests/conftest.py +0 -0
  69. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/tests/test_async_examples.py +0 -0
  70. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/examples/tests/test_examples.py +0 -0
  71. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/justfile +0 -0
  72. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/__init__.py +0 -0
  73. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/_batch.py +0 -0
  74. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/_http_requests.py +0 -0
  75. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/_utils.py +0 -0
  76. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/errors.py +0 -0
  77. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/json_handler.py +0 -0
  78. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/models/__init__.py +0 -0
  79. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/models/batch.py +0 -0
  80. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/models/client.py +0 -0
  81. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/models/documents.py +0 -0
  82. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/models/health.py +0 -0
  83. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/models/index.py +0 -0
  84. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/models/search.py +0 -0
  85. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/models/settings.py +0 -0
  86. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/models/task.py +0 -0
  87. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/models/version.py +0 -0
  88. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/models/webhook.py +0 -0
  89. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/plugins.py +0 -0
  90. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/py.typed +0 -0
  91. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/meilisearch_python_sdk/types.py +0 -0
  92. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/mkdocs.yaml +0 -0
  93. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/__init__.py +0 -0
  94. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/test_async_client.py +0 -0
  95. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/test_async_index.py +0 -0
  96. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/test_async_index_plugins.py +0 -0
  97. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/test_client.py +0 -0
  98. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/test_decorators.py +0 -0
  99. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/test_errors.py +0 -0
  100. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/test_index.py +0 -0
  101. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/test_index_plugins.py +0 -0
  102. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/test_settings_models.py +0 -0
  103. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/test_utils.py +0 -0
  104. {meilisearch_python_sdk-5.1.0 → meilisearch_python_sdk-5.3.0}/tests/test_version.py +0 -0
@@ -14,7 +14,7 @@ repos:
14
14
  - id: mypy
15
15
  additional_dependencies: [pydantic, orjson, types-aiofiles, types-ujson]
16
16
  - repo: https://github.com/astral-sh/ruff-pre-commit
17
- rev: v0.14.0
17
+ rev: v0.14.2
18
18
  hooks:
19
19
  - id: ruff-check
20
20
  args: [--fix, --exit-non-zero-on-fix]
@@ -164,7 +164,7 @@ Now with the container running, run the test suite
164
164
  uv run pytest
165
165
  ```
166
166
 
167
- In additon to mainting the coverage percentage please ensure that all
167
+ In addition to mainting the coverage percentage please ensure that all
168
168
  tests are passing before submitting a pull request.
169
169
 
170
170
  #### just
@@ -288,7 +288,7 @@ git fetch upstream
288
288
  git rebase upstream/main
289
289
  ```
290
290
 
291
- There may be some merge conficts that need to be resolved. After the feature branch has been update
291
+ There may be some merge conflicts that need to be resolved. After the feature branch has been update
292
292
  locally, you can now update your pull request by pushing to the branch on GitHub:
293
293
 
294
294
  ```sh
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meilisearch-python-sdk
3
- Version: 5.1.0
3
+ Version: 5.3.0
4
4
  Summary: A Python client providing both async and sync support for the Meilisearch API
5
5
  Project-URL: repository, https://github.com/sanders41/meilisearch-python-sdk
6
6
  Project-URL: homepage, https://github.com/sanders41/meilisearch-python-sdk
@@ -122,15 +122,15 @@ async with AsyncClient('http://127.0.0.1:7700', 'masterKey') as client:
122
122
  ```py
123
123
  from meilisearch_python_sdk import Client
124
124
 
125
- client = Client('http://127.0.0.1:7700', 'masterKey')
126
- index = client.index("books")
125
+ with Client('http://127.0.0.1:7700', 'masterKey') as client:
126
+ index = client.index("books")
127
127
 
128
- documents = [
129
- {"id": 1, "title": "Ready Player One"},
130
- {"id": 42, "title": "The Hitchhiker's Guide to the Galaxy"},
131
- ]
128
+ documents = [
129
+ {"id": 1, "title": "Ready Player One"},
130
+ {"id": 42, "title": "The Hitchhiker's Guide to the Galaxy"},
131
+ ]
132
132
 
133
- index.add_documents(documents)
133
+ index.add_documents(documents)
134
134
  ```
135
135
 
136
136
  The server will return an update id that can be used to
@@ -252,7 +252,7 @@ Meilisearch takes to index the documents since that is outside of the library fu
252
252
 
253
253
  ![Add Documents in Batches](https://raw.githubusercontent.com/sanders41/meilisearch-python-sdk/main/assets/add_in_batches.png)
254
254
 
255
- ### Muiltiple Searches
255
+ ### Multiple Searches
256
256
 
257
257
  This test compares how long it takes to complete 1000 searches (lower is better)
258
258
 
@@ -66,15 +66,15 @@ async with AsyncClient('http://127.0.0.1:7700', 'masterKey') as client:
66
66
  ```py
67
67
  from meilisearch_python_sdk import Client
68
68
 
69
- client = Client('http://127.0.0.1:7700', 'masterKey')
70
- index = client.index("books")
69
+ with Client('http://127.0.0.1:7700', 'masterKey') as client:
70
+ index = client.index("books")
71
71
 
72
- documents = [
73
- {"id": 1, "title": "Ready Player One"},
74
- {"id": 42, "title": "The Hitchhiker's Guide to the Galaxy"},
75
- ]
72
+ documents = [
73
+ {"id": 1, "title": "Ready Player One"},
74
+ {"id": 42, "title": "The Hitchhiker's Guide to the Galaxy"},
75
+ ]
76
76
 
77
- index.add_documents(documents)
77
+ index.add_documents(documents)
78
78
  ```
79
79
 
80
80
  The server will return an update id that can be used to
@@ -196,7 +196,7 @@ Meilisearch takes to index the documents since that is outside of the library fu
196
196
 
197
197
  ![Add Documents in Batches](https://raw.githubusercontent.com/sanders41/meilisearch-python-sdk/main/assets/add_in_batches.png)
198
198
 
199
- ### Muiltiple Searches
199
+ ### Multiple Searches
200
200
 
201
201
  This test compares how long it takes to complete 1000 searches (lower is better)
202
202
 
@@ -1,6 +1,6 @@
1
1
  ## `AsyncIndex` Usage
2
2
 
3
- The `AsyncIndex` is the the same as the `Index`, but gives asyncronous methods to work with, and
3
+ The `AsyncIndex` is the the same as the `Index`, but gives asynchronous methods to work with, and
4
4
  and should be used when using the `AsyncClient`. When you create a new index with the `AsyncClient`
5
5
  it will create an `AsyncIndex` instance.
6
6
 
@@ -0,0 +1,53 @@
1
+ ## `client` Usage
2
+
3
+ ### Create a client with a context manager
4
+
5
+ This client runs in a context manager which ensures that everything is cleaned up after the use of
6
+ the client is done. To create a client:
7
+
8
+ ```py
9
+ from meilisearch-python-sdk import Client
10
+
11
+
12
+ with Client("http://localhost:7700", "masterKey") as client:
13
+ index = client.index("movies")
14
+ ...
15
+ ```
16
+
17
+ ### Custom headers
18
+
19
+ Custom headers can be added to the client by adding them to `custom_headers` when creating the
20
+ client.
21
+
22
+ ```py
23
+ from meilisearch_python_sdk import Client
24
+
25
+ with Client(
26
+ "http://127.0.0.1:7700",
27
+ "masterKey",
28
+ custom_headers={"header_key_1": "header_value_1", "header_key_2": "header_value_2"}
29
+ ) as client:
30
+ index = client.index("movies")
31
+ ...
32
+ ```
33
+
34
+ ### Create a client without a context manager
35
+
36
+ It is also possible to call the client without using a context manager, but in doing so you will
37
+ need to make sure to do the cleanup yourself:
38
+
39
+ ```py
40
+ from meilisearch-python-sdk import Client
41
+
42
+
43
+ try:
44
+ client = Client("http://localhost:7700", "masterKey")
45
+ ...
46
+ finally:
47
+ await client.close()
48
+
49
+ ```
50
+
51
+ ## `Client` API
52
+
53
+ ::: meilisearch_python_sdk.Client
@@ -1,6 +1,6 @@
1
1
  # JSON Handler
2
2
 
3
- For json loads and dumps you have the option to use the `json` module from the standard libary,
3
+ For json loads and dumps you have the option to use the `json` module from the standard library,
4
4
  orjson, or ujson. This done by setting the `json_handler` when creating the `AsyncClient` or
5
5
  `Client`. By default the standard library `json` module will be used. The examples below use
6
6
  `Client`, and the same options are available for `AsyncClient`.
@@ -37,9 +37,9 @@ documents = [
37
37
  {"id": uuid4(), "title": "test 1", "when": datetime.now()},
38
38
  {"id": uuid4(), "title": "Test 2", "when": datetime.now()},
39
39
  ]
40
- client = Client("http://127.0.0.1:7700", json_handler=BuiltinHandler(serializer=CustomEncoder))
41
- index = client.index("movies", primary_key="id")
42
- index.add_documents(documents)
40
+ with Client("http://127.0.0.1:7700", json_handler=BuiltinHandler(serializer=CustomEncoder)) as client:
41
+ index = client.index("movies", primary_key="id")
42
+ index.add_documents(documents)
43
43
  ```
44
44
 
45
45
  ## orjson
@@ -57,9 +57,9 @@ documents = [
57
57
  {"id": uuid4(), "title": "test 1"},
58
58
  {"id": uuid4(), "title": "Test 2"},
59
59
  ]
60
- client = Client("http://127.0.0.1:7700", json_handler=OrjsonHandler())
61
- index = client.index("movies", primary_key="id")
62
- index.add_documents(documents)
60
+ with Client("http://127.0.0.1:7700", json_handler=OrjsonHandler()) as client:
61
+ index = client.index("movies", primary_key="id")
62
+ index.add_documents(documents)
63
63
  ```
64
64
 
65
65
  ## ujson
@@ -77,7 +77,7 @@ documents = [
77
77
  {"id": uuid4(), "title": "test 1"},
78
78
  {"id": uuid4(), "title": "Test 2"},
79
79
  ]
80
- client = Client("http://127.0.0.1:7700", json_handler=UjsonHandler())
81
- index = client.index("movies", primary_key="id")
82
- index.add_documents(documents)
80
+ with Client("http://127.0.0.1:7700", json_handler=UjsonHandler()) as client:
81
+ index = client.index("movies", primary_key="id")
82
+ index.add_documents(documents)
83
83
  ```
@@ -15,7 +15,7 @@ is done through a named tuple that specifies where the plugin should run. The op
15
15
  - update_documents_plugins: Run on the `update_document` method.
16
16
 
17
17
  When creating your plugin you specify if you want it to run before or after the default
18
- functionality. Additionaly plugins for async indexes can be run concurrently with the default
18
+ functionality. Additionally plugins for async indexes can be run concurrently with the default
19
19
  functionality.
20
20
 
21
21
  ## Examples:
@@ -27,9 +27,9 @@ way to track this out of the box. A search plugin could be used to implement thi
27
27
  yourself.
28
28
 
29
29
  Note that in these examples the protocol is satisfied by providing the `CONNECURRENT_EVENT`,
30
- `POST_EVENT`, and `PRE_EVENT` vairables and the
30
+ `POST_EVENT`, and `PRE_EVENT` variables and the
31
31
  `async def run_plugin(self, event: AsyncEvent, **kwargs: Any) -> None:` method for an async index,
32
- or the `POST_EVENT` and `PRE_EVENT` vairables , and
32
+ or the `POST_EVENT` and `PRE_EVENT` variables , and
33
33
  `def run_plugin(self, event: Event, **kwargs: Any) -> None:` method for a non-async index. You
34
34
  class can contain any additional methods/variables needed as long as the protocol requirements
35
35
  have been satisfied.
@@ -84,13 +84,13 @@ async def main() -> int:
84
84
  with open("datasets/small_movies.json") as f:
85
85
  documents = json.load(f)
86
86
 
87
- client = AsyncClient("http://127.0.0.1:7700", "masterKey")
88
- plugins = AsyncIndexPlugins(search_plugins=(SearchTrackerPlugin(),))
89
- index = await client.create_index("movies", primary_key="id", plugins=plugins)
90
- task = await index.add_documents(documents)
91
- await client.wait_for_task(task.task_uid)
92
- result = await index.search("Cars")
93
- print(result) # noqa: T201
87
+ async with AsyncClient("http://127.0.0.1:7700", "masterKey") as client:
88
+ plugins = AsyncIndexPlugins(search_plugins=(SearchTrackerPlugin(),))
89
+ index = await client.create_index("movies", primary_key="id", plugins=plugins)
90
+ task = await index.add_documents(documents)
91
+ await client.wait_for_task(task.task_uid)
92
+ result = await index.search("Cars")
93
+ print(result) # noqa: T201
94
94
 
95
95
  return 0
96
96
 
@@ -142,13 +142,13 @@ def main() -> int:
142
142
  with open("datasets/small_movies.json") as f:
143
143
  documents = json.load(f)
144
144
 
145
- client = Client("http://127.0.0.1:7700", "masterKey")
146
- plugins = IndexPlugins(search_plugins=(SearchTrackerPlugin(),))
147
- index = client.create_index("movies", primary_key="id", plugins=plugins)
148
- task = index.add_documents(documents)
149
- client.wait_for_task(task.task_uid)
150
- result = index.search("Cars")
151
- print(result) # noqa: T201
145
+ with Client("http://127.0.0.1:7700", "masterKey") as client:
146
+ plugins = IndexPlugins(search_plugins=(SearchTrackerPlugin(),))
147
+ index = client.create_index("movies", primary_key="id", plugins=plugins)
148
+ task = index.add_documents(documents)
149
+ client.wait_for_task(task.task_uid)
150
+ result = index.search("Cars")
151
+ print(result) # noqa: T201
152
152
 
153
153
  return 0
154
154
 
@@ -160,12 +160,12 @@ if __name__ == "__main__":
160
160
  ### Modify documents and search results
161
161
 
162
162
  A pre event plugin can be used to modify the documents before sending for indexing. In this example
163
- a new `access` field will be added to the doocuments before they are added or updated. The example
163
+ a new `access` field will be added to the documents before they are added or updated. The example
164
164
  will set every other record to `admin` access with the other records being set to `read`. This will
165
- illustrate the idea of modifing documents even it if doesn't make real world sense.
165
+ illustrate the idea of modifying documents even it if doesn't make real world sense.
166
166
 
167
167
  A post search plugin, this type of search plugin can only be used post search because it requires
168
- the result of the search, will be used to remove records marked as `admin` before returing the result.
168
+ the result of the search, will be used to remove records marked as `admin` before returning the result.
169
169
  In the real world this filtering would probably be done with a filterable field in Meilisearch,but
170
170
  again, this is just used here to illustrate the idea.
171
171
 
@@ -224,17 +224,17 @@ async def main() -> int:
224
224
  with open("datasets/small_movies.json") as f:
225
225
  documents = json.load(f)
226
226
 
227
- client = AsyncClient("http://127.0.0.1:7700", "masterKey")
228
- plugins = AsyncIndexPlugins(
229
- add_documents_plugins=(ModifyDocumentPlugin(),),
230
- update_documents_plugins=(ModifyDocumentPlugin(),),
231
- search_plugins=(FilterSearchResultsPlugin(),),
232
- )
233
- index = await client.create_index("movies", primary_key="id", plugins=plugins)
234
- task = await index.add_documents(documents)
235
- await client.wait_for_task(task.task_uid)
236
- result = await index.search("cars")
237
- print(result) # noqa: T201
227
+ async with AsyncClient("http://127.0.0.1:7700", "masterKey") as client:
228
+ plugins = AsyncIndexPlugins(
229
+ add_documents_plugins=(ModifyDocumentPlugin(),),
230
+ update_documents_plugins=(ModifyDocumentPlugin(),),
231
+ search_plugins=(FilterSearchResultsPlugin(),),
232
+ )
233
+ index = await client.create_index("movies", primary_key="id", plugins=plugins)
234
+ task = await index.add_documents(documents)
235
+ await client.wait_for_task(task.task_uid)
236
+ result = await index.search("cars")
237
+ print(result) # noqa: T201
238
238
 
239
239
  return 0
240
240
 
@@ -295,17 +295,17 @@ def main() -> int:
295
295
  with open("datasets/small_movies.json") as f:
296
296
  documents = json.load(f)
297
297
 
298
- client = Client("http://127.0.0.1:7700", "masterKey")
299
- plugins = IndexPlugins(
300
- add_documents_plugins=(ModifyDocumentPlugin(),),
301
- update_documents_plugins=(ModifyDocumentPlugin(),),
302
- search_plugins=(FilterSearchResultsPlugin(),),
303
- )
304
- index = client.create_index("movies", primary_key="id", plugins=plugins)
305
- task = index.add_documents(documents)
306
- client.wait_for_task(task.task_uid)
307
- result = index.search("cars")
308
- print(result) # noqa: T201
298
+ with Client("http://127.0.0.1:7700", "masterKey") as client:
299
+ plugins = IndexPlugins(
300
+ add_documents_plugins=(ModifyDocumentPlugin(),),
301
+ update_documents_plugins=(ModifyDocumentPlugin(),),
302
+ search_plugins=(FilterSearchResultsPlugin(),),
303
+ )
304
+ index = client.create_index("movies", primary_key="id", plugins=plugins)
305
+ task = index.add_documents(documents)
306
+ client.wait_for_task(task.task_uid)
307
+ result = index.search("cars")
308
+ print(result) # noqa: T201
309
309
 
310
310
  return 0
311
311
 
@@ -55,7 +55,7 @@ Movie(
55
55
  ```
56
56
 
57
57
  By inheriting from CamelBase, or any of the other [provided models](https://github.com/sanders41/meilisearch-python-sdk/tree/main/meilisearch_python_sdk/models)
58
- you will be inheriting Pydantic models and therefore have access to the funcitonality Pydantic provides
58
+ you will be inheriting Pydantic models and therefore have access to the functionality Pydantic provides
59
59
  such as [validators](https://pydantic-docs.helpmanual.io/usage/validators/) and [Fields](https://pydantic-docs.helpmanual.io/usage/model_config/#alias-precedence).
60
60
  Pydantic will also automatically deserialized the data into the correct data type based on the type
61
61
  hint provided.
@@ -19,12 +19,12 @@ def load_documents() -> list[dict[str, Any]]:
19
19
 
20
20
 
21
21
  def main() -> int:
22
- client = Client("http://127.0.0.1:7700", "masterKey")
23
- index = client.create_index("movies", "id")
24
- load_documents()
25
- documents = index.get_documents()
22
+ with Client("http://127.0.0.1:7700", "masterKey") as client:
23
+ index = client.create_index("movies", "id")
24
+ load_documents()
25
+ documents = index.get_documents()
26
26
 
27
- print(documents) # noqa: T201
27
+ print(documents) # noqa: T201
28
28
 
29
29
  return 0
30
30
 
@@ -9,11 +9,11 @@ def main() -> int:
9
9
  with open("../datasets/small_movies.json") as f:
10
10
  documents = json.load(f)
11
11
 
12
- client = Client("http://127.0.0.1:7700", "masterKey")
13
- index = client.index("movies")
12
+ with Client("http://127.0.0.1:7700", "masterKey") as client:
13
+ index = client.index("movies")
14
14
 
15
- # Meilisearch prefers larger batch sizes so set this as large as you can.
16
- index.add_documents_in_batches(documents, primary_key="id", batch_size=1000)
15
+ # Meilisearch prefers larger batch sizes so set this as large as you can.
16
+ index.add_documents_in_batches(documents, primary_key="id", batch_size=1000)
17
17
 
18
18
  return 0
19
19
 
@@ -50,17 +50,17 @@ def main() -> int:
50
50
  with open("../datasets/small_movies.json") as f:
51
51
  documents = json.load(f)
52
52
 
53
- client = Client("http://127.0.0.1:7700", "masterKey")
54
- plugins = IndexPlugins(
55
- add_documents_plugins=(ModifyDocumentPlugin(),),
56
- update_documents_plugins=(ModifyDocumentPlugin(),),
57
- search_plugins=(FilterSearchResultsPlugin(),),
58
- )
59
- index = client.create_index("movies", primary_key="id", plugins=plugins)
60
- task = index.add_documents(documents)
61
- client.wait_for_task(task.task_uid)
62
- result = index.search("cars")
63
- print(result) # noqa: T201
53
+ with Client("http://127.0.0.1:7700", "masterKey") as client:
54
+ plugins = IndexPlugins(
55
+ add_documents_plugins=(ModifyDocumentPlugin(),),
56
+ update_documents_plugins=(ModifyDocumentPlugin(),),
57
+ search_plugins=(FilterSearchResultsPlugin(),),
58
+ )
59
+ index = client.create_index("movies", primary_key="id", plugins=plugins)
60
+ task = index.add_documents(documents)
61
+ client.wait_for_task(task.task_uid)
62
+ result = index.search("cars")
63
+ print(result) # noqa: T201
64
64
 
65
65
  return 0
66
66
 
@@ -8,9 +8,9 @@ from meilisearch_python_sdk.models.task import TaskInfo
8
8
 
9
9
 
10
10
  def add_documents(file_path: Path | str = "../datasets/small_movies.json") -> TaskInfo:
11
- client = Client("http://127.0.0.1:7700", "masterKey", json_handler=OrjsonHandler())
12
- index = client.create_index("movies", primary_key="id")
13
- return index.add_documents_from_file(file_path)
11
+ with Client("http://127.0.0.1:7700", "masterKey", json_handler=OrjsonHandler()) as client:
12
+ index = client.create_index("movies", primary_key="id")
13
+ return index.add_documents_from_file(file_path)
14
14
 
15
15
 
16
16
  def main() -> int:
@@ -53,13 +53,13 @@ def search(index: Index, query: str) -> SearchResults[JsonDict]:
53
53
 
54
54
 
55
55
  def main() -> int:
56
- client = Client("http://127.0.0.1:7700", "masterKey")
57
- plugins = IndexPlugins(search_plugins=(SearchTrackerPlugin(),))
58
- index = client.create_index("movies", primary_key="id", plugins=plugins)
59
- task = add_documents(index)
60
- client.wait_for_task(task.task_uid)
61
- result = search(index, "Cars")
62
- print(result) # noqa: T201
56
+ with Client("http://127.0.0.1:7700", "masterKey") as client:
57
+ plugins = IndexPlugins(search_plugins=(SearchTrackerPlugin(),))
58
+ index = client.create_index("movies", primary_key="id", plugins=plugins)
59
+ task = add_documents(index)
60
+ client.wait_for_task(task.task_uid)
61
+ result = search(index, "Cars")
62
+ print(result) # noqa: T201
63
63
 
64
64
  return 0
65
65
 
@@ -8,9 +8,9 @@ from meilisearch_python_sdk.models.task import TaskInfo
8
8
 
9
9
 
10
10
  def add_documents(file_path: Path | str = "../datasets/small_movies.json") -> TaskInfo:
11
- client = Client("http://127.0.0.1:7700", "masterKey", json_handler=UjsonHandler())
12
- index = client.create_index("movies", primary_key="id")
13
- return index.add_documents_from_file(file_path)
11
+ with Client("http://127.0.0.1:7700", "masterKey", json_handler=UjsonHandler()) as client:
12
+ index = client.create_index("movies", primary_key="id")
13
+ return index.add_documents_from_file(file_path)
14
14
 
15
15
 
16
16
  def main() -> int:
@@ -25,11 +25,11 @@ def update_settings(index: Index) -> TaskInfo:
25
25
 
26
26
 
27
27
  def main() -> int:
28
- client = Client("http://127.0.0.1:7700", "masterKey")
29
- index = client.create_index("movies", primary_key="id")
30
- task = update_settings(index)
31
- client.wait_for_task(task.task_uid)
32
- add_documents(index)
28
+ with Client("http://127.0.0.1:7700", "masterKey") as client:
29
+ index = client.create_index("movies", primary_key="id")
30
+ task = update_settings(index)
31
+ client.wait_for_task(task.task_uid)
32
+ add_documents(index)
33
33
 
34
34
  return 0
35
35