meilisearch-python-sdk 2.0.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 (22) hide show
  1. meilisearch_python_sdk-2.0.0/LICENSE +21 -0
  2. meilisearch_python_sdk-2.0.0/PKG-INFO +253 -0
  3. meilisearch_python_sdk-2.0.0/README.md +222 -0
  4. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/__init__.py +8 -0
  5. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/_client.py +1762 -0
  6. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/_http_requests.py +138 -0
  7. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/_index.py +5620 -0
  8. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/_task.py +358 -0
  9. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/_utils.py +50 -0
  10. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/_version.py +1 -0
  11. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/errors.py +71 -0
  12. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/models/__init__.py +0 -0
  13. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/models/client.py +159 -0
  14. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/models/documents.py +10 -0
  15. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/models/health.py +5 -0
  16. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/models/index.py +67 -0
  17. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/models/search.py +59 -0
  18. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/models/settings.py +72 -0
  19. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/models/task.py +109 -0
  20. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/models/version.py +10 -0
  21. meilisearch_python_sdk-2.0.0/meilisearch_python_sdk/py.typed +0 -0
  22. meilisearch_python_sdk-2.0.0/pyproject.toml +100 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Paul Sanders
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,253 @@
1
+ Metadata-Version: 2.1
2
+ Name: meilisearch-python-sdk
3
+ Version: 2.0.0
4
+ Summary: A Python async client for the Meilisearch API
5
+ Home-page: https://github.com/sanders41/meilisearch-python-sdk
6
+ License: MIT
7
+ Keywords: meilisearch,async,python,client,sdk
8
+ Author: Paul Sanders
9
+ Author-email: psanders1@gmail.com
10
+ Requires-Python: >=3.8,<4.0
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Typing :: Typed
22
+ Requires-Dist: PyJWT (>=2.3.0)
23
+ Requires-Dist: aiofiles (>=0.7)
24
+ Requires-Dist: camel-converter (>=1.0.0)
25
+ Requires-Dist: httpx (>=0.17)
26
+ Requires-Dist: pydantic (>=1.8)
27
+ Project-URL: Documentation, https://meilisearch-python-sdk.paulsanders.dev
28
+ Project-URL: Repository, https://github.com/sanders41/meilisearch-python-sdk
29
+ Description-Content-Type: text/markdown
30
+
31
+ # Meilisearch Python SDK
32
+
33
+ [![Tests Status](https://github.com/sanders41/meilisearch-python-sdk/workflows/Testing/badge.svg?branch=main&event=push)](https://github.com/sanders41/meilisearch-python-sdk/actions?query=workflow%3ATesting+branch%3Amain+event%3Apush)
34
+ [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/sanders41/meilisearch-python-sdk/main.svg)](https://results.pre-commit.ci/latest/github/sanders41/meilisearch-python-sdk/main)
35
+ [![Coverage](https://codecov.io/github/sanders41/meilisearch-python-sdk/coverage.svg?branch=main)](https://codecov.io/gh/sanders41/meilisearch-python-sdk)
36
+ [![PyPI version](https://badge.fury.io/py/meilisearch-python-sdk.svg)](https://badge.fury.io/py/meilisearch-python-sdk)
37
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/meilisearch-python-sdk?color=5cc141)](https://github.com/sanders41/meilisearch-python-sdk)
38
+
39
+ :warning: This project was previously named `meilisearch-python-async`. Development on that project
40
+ continues here under the new name.
41
+
42
+ Meilisearch Python SDK provides both an async and sync client for the
43
+ [Meilisearch](https://github.com/meilisearch/meilisearch) API.
44
+
45
+ Which client to use depends on your use case. If the code base you are working with uses asyncio,
46
+ for example if you are using [FastAPI](https://fastapi.tiangolo.com/), chose the `AsyncClint`
47
+ otherwise chose the `Client`. The functionality of the two clients is the same, the difference
48
+ being the `AsyncClient` provides async methods and uses the `AsyncIndex`, which also provides async
49
+ methods, while the `Client` provides blocking methods and uses the `Index`, which also provides
50
+ blocking methods.
51
+
52
+ ## Installation
53
+
54
+ Using a virtual environmnet is recommended for installing this package. Once the virtual
55
+ environment is created and activated install the package with:
56
+
57
+ ```sh
58
+ pip install meilisearch-python-sdk
59
+ ```
60
+
61
+ ## Run Meilisearch
62
+
63
+ There are several ways to
64
+ [run Meilisearch](https://docs.meilisearch.com/reference/features/installation.html#download-and-launch).
65
+ Pick the one that works best for your use case and then start the server.
66
+
67
+ As as example to use Docker:
68
+
69
+ ```sh
70
+ docker pull getmeili/meilisearch:latest
71
+ docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey
72
+ ```
73
+
74
+ ## Useage
75
+
76
+ ### Add Documents
77
+
78
+
79
+ #### AsyncClient
80
+
81
+ - Note: `client.index("books") creates an instance of an AsyncIndex object but does not make a
82
+ network call to send the data yet so it does not need to be awaited.
83
+
84
+ ```py
85
+ from meilisearch_python_sdk import AsyncClient
86
+
87
+ async with AsyncClient('http://127.0.0.1:7700', 'masterKey') as client:
88
+ index = client.index("books")
89
+
90
+ documents = [
91
+ {"id": 1, "title": "Ready Player One"},
92
+ {"id": 42, "title": "The Hitchhiker's Guide to the Galaxy"},
93
+ ]
94
+
95
+ await index.add_documents(documents)
96
+ ```
97
+
98
+ #### Client
99
+
100
+ ```py
101
+ from meilisearch_python_sdk import Client
102
+
103
+ client = Client('http://127.0.0.1:7700', 'masterKey')
104
+ index = client.index("books")
105
+
106
+ documents = [
107
+ {"id": 1, "title": "Ready Player One"},
108
+ {"id": 42, "title": "The Hitchhiker's Guide to the Galaxy"},
109
+ ]
110
+
111
+ index.add_documents(documents)
112
+ ```
113
+
114
+ The server will return an update id that can be used to
115
+ [get the status](https://docs.meilisearch.com/reference/api/updates.html#get-an-update-status)
116
+ of the updates. To do this you would save the result response from adding the documets to a
117
+ variable, this will be a UpdateId object, and use it to check the status of the updates.
118
+
119
+ #### AsyncClient
120
+
121
+ ```py
122
+ update = await index.add_documents(documents)
123
+ status = await client.index('books').get_update_status(update.update_id)
124
+ ```
125
+
126
+ #### Client
127
+
128
+ ```py
129
+ update = index.add_documents(documents)
130
+ status = client.index('books').get_update_status(update.update_id)
131
+ ```
132
+
133
+ ### Basic Searching
134
+
135
+ #### AsyncClient
136
+
137
+ ```py
138
+ search_result = await index.search("ready player")
139
+ ```
140
+
141
+ #### Client
142
+
143
+ ```py
144
+ search_result = index.search("ready player")
145
+ ```
146
+
147
+ ### Base Search Results: SearchResults object with values
148
+
149
+ ```py
150
+ SearchResults(
151
+ hits = [
152
+ {
153
+ "id": 1,
154
+ "title": "Ready Player One",
155
+ },
156
+ ],
157
+ offset = 0,
158
+ limit = 20,
159
+ nb_hits = 1,
160
+ exhaustive_nb_hits = bool,
161
+ facets_distributionn = None,
162
+ processing_time_ms = 1,
163
+ query = "ready player",
164
+ )
165
+ ```
166
+
167
+ ### Custom Search
168
+
169
+ Information about the parameters can be found in the
170
+ [search parameters](https://docs.meilisearch.com/reference/features/search_parameters.html) section
171
+ of the documentation.
172
+
173
+ #### AsyncClient
174
+
175
+ ```py
176
+ await index.search(
177
+ "guide",
178
+ attributes_to_highlight=["title"],
179
+ filters="book_id > 10"
180
+ )
181
+ ```
182
+
183
+ #### Client
184
+
185
+ ```py
186
+ index.search(
187
+ "guide",
188
+ attributes_to_highlight=["title"],
189
+ filters="book_id > 10"
190
+ )
191
+ ```
192
+
193
+ ### Custom Search Results: SearchResults object with values
194
+
195
+ ```py
196
+ SearchResults(
197
+ hits = [
198
+ {
199
+ "id": 42,
200
+ "title": "The Hitchhiker's Guide to the Galaxy",
201
+ "_formatted": {
202
+ "id": 42,
203
+ "title": "The Hitchhiker's Guide to the <em>Galaxy</em>"
204
+ }
205
+ },
206
+ ],
207
+ offset = 0,
208
+ limit = 20,
209
+ nb_hits = 1,
210
+ exhaustive_nb_hits = bool,
211
+ facets_distributionn = None,
212
+ processing_time_ms = 5,
213
+ query = "galaxy",
214
+ )
215
+ ```
216
+
217
+ ## Benchmark
218
+
219
+ The following benchmarks compare this library to the official
220
+ [Meilisearch Python](https://github.com/meilisearch/meilisearch-python) library. Note that all
221
+ of the performance gains seen with the `AsyncClient` are achieved by taking advantage of asyncio.
222
+ This means that if your code is not taking advantage of asyncio or blocking the event loop the
223
+ gains here will not be seen and the performance between the clients will be very close to the same.
224
+
225
+ ### Add Documents in Batches
226
+
227
+ This test compares how long it takes to send 1 million documents in batches of 1 thousand to the
228
+ Meilisearch server for indexing (lower is better). The time does not take into account how long
229
+ Meilisearch takes to index the documents since that is outside of the library functionality.
230
+
231
+ ![Add Documents in Batches](https://raw.githubusercontent.com/sanders41/meilisearch-python-sdk/main/assets/add_in_batches.png)
232
+
233
+ ### Muiltiple Searches
234
+
235
+ This test compares how long it takes to complete 1000 searches (lower is better)
236
+
237
+ ![Multiple Searches](https://raw.githubusercontent.com/sanders41/meilisearch-python-sdk/main/assets/searches.png)
238
+
239
+ ### Independent testing
240
+
241
+ [Prashanth Rao](https://github.com/prrao87) did some independent testing and found this async client
242
+ to be ~30% faster than the sync client for data ingestion. You can find a good write-up of the
243
+ results how he tested them in his [blog post](https://thedataquarry.com/posts/meilisearch-async/).
244
+
245
+ ## Documentation
246
+
247
+ See our [docs](https://meilisearch-python-sdk.paulsanders.dev) for the full documentation.
248
+
249
+ ## Contributing
250
+
251
+ Contributions to this project are welcome. If you are interested in contributing please see our
252
+ [contributing guide](CONTRIBUTING.md)
253
+
@@ -0,0 +1,222 @@
1
+ # Meilisearch Python SDK
2
+
3
+ [![Tests Status](https://github.com/sanders41/meilisearch-python-sdk/workflows/Testing/badge.svg?branch=main&event=push)](https://github.com/sanders41/meilisearch-python-sdk/actions?query=workflow%3ATesting+branch%3Amain+event%3Apush)
4
+ [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/sanders41/meilisearch-python-sdk/main.svg)](https://results.pre-commit.ci/latest/github/sanders41/meilisearch-python-sdk/main)
5
+ [![Coverage](https://codecov.io/github/sanders41/meilisearch-python-sdk/coverage.svg?branch=main)](https://codecov.io/gh/sanders41/meilisearch-python-sdk)
6
+ [![PyPI version](https://badge.fury.io/py/meilisearch-python-sdk.svg)](https://badge.fury.io/py/meilisearch-python-sdk)
7
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/meilisearch-python-sdk?color=5cc141)](https://github.com/sanders41/meilisearch-python-sdk)
8
+
9
+ :warning: This project was previously named `meilisearch-python-async`. Development on that project
10
+ continues here under the new name.
11
+
12
+ Meilisearch Python SDK provides both an async and sync client for the
13
+ [Meilisearch](https://github.com/meilisearch/meilisearch) API.
14
+
15
+ Which client to use depends on your use case. If the code base you are working with uses asyncio,
16
+ for example if you are using [FastAPI](https://fastapi.tiangolo.com/), chose the `AsyncClint`
17
+ otherwise chose the `Client`. The functionality of the two clients is the same, the difference
18
+ being the `AsyncClient` provides async methods and uses the `AsyncIndex`, which also provides async
19
+ methods, while the `Client` provides blocking methods and uses the `Index`, which also provides
20
+ blocking methods.
21
+
22
+ ## Installation
23
+
24
+ Using a virtual environmnet is recommended for installing this package. Once the virtual
25
+ environment is created and activated install the package with:
26
+
27
+ ```sh
28
+ pip install meilisearch-python-sdk
29
+ ```
30
+
31
+ ## Run Meilisearch
32
+
33
+ There are several ways to
34
+ [run Meilisearch](https://docs.meilisearch.com/reference/features/installation.html#download-and-launch).
35
+ Pick the one that works best for your use case and then start the server.
36
+
37
+ As as example to use Docker:
38
+
39
+ ```sh
40
+ docker pull getmeili/meilisearch:latest
41
+ docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey
42
+ ```
43
+
44
+ ## Useage
45
+
46
+ ### Add Documents
47
+
48
+
49
+ #### AsyncClient
50
+
51
+ - Note: `client.index("books") creates an instance of an AsyncIndex object but does not make a
52
+ network call to send the data yet so it does not need to be awaited.
53
+
54
+ ```py
55
+ from meilisearch_python_sdk import AsyncClient
56
+
57
+ async with AsyncClient('http://127.0.0.1:7700', 'masterKey') as client:
58
+ index = client.index("books")
59
+
60
+ documents = [
61
+ {"id": 1, "title": "Ready Player One"},
62
+ {"id": 42, "title": "The Hitchhiker's Guide to the Galaxy"},
63
+ ]
64
+
65
+ await index.add_documents(documents)
66
+ ```
67
+
68
+ #### Client
69
+
70
+ ```py
71
+ from meilisearch_python_sdk import Client
72
+
73
+ client = Client('http://127.0.0.1:7700', 'masterKey')
74
+ index = client.index("books")
75
+
76
+ documents = [
77
+ {"id": 1, "title": "Ready Player One"},
78
+ {"id": 42, "title": "The Hitchhiker's Guide to the Galaxy"},
79
+ ]
80
+
81
+ index.add_documents(documents)
82
+ ```
83
+
84
+ The server will return an update id that can be used to
85
+ [get the status](https://docs.meilisearch.com/reference/api/updates.html#get-an-update-status)
86
+ of the updates. To do this you would save the result response from adding the documets to a
87
+ variable, this will be a UpdateId object, and use it to check the status of the updates.
88
+
89
+ #### AsyncClient
90
+
91
+ ```py
92
+ update = await index.add_documents(documents)
93
+ status = await client.index('books').get_update_status(update.update_id)
94
+ ```
95
+
96
+ #### Client
97
+
98
+ ```py
99
+ update = index.add_documents(documents)
100
+ status = client.index('books').get_update_status(update.update_id)
101
+ ```
102
+
103
+ ### Basic Searching
104
+
105
+ #### AsyncClient
106
+
107
+ ```py
108
+ search_result = await index.search("ready player")
109
+ ```
110
+
111
+ #### Client
112
+
113
+ ```py
114
+ search_result = index.search("ready player")
115
+ ```
116
+
117
+ ### Base Search Results: SearchResults object with values
118
+
119
+ ```py
120
+ SearchResults(
121
+ hits = [
122
+ {
123
+ "id": 1,
124
+ "title": "Ready Player One",
125
+ },
126
+ ],
127
+ offset = 0,
128
+ limit = 20,
129
+ nb_hits = 1,
130
+ exhaustive_nb_hits = bool,
131
+ facets_distributionn = None,
132
+ processing_time_ms = 1,
133
+ query = "ready player",
134
+ )
135
+ ```
136
+
137
+ ### Custom Search
138
+
139
+ Information about the parameters can be found in the
140
+ [search parameters](https://docs.meilisearch.com/reference/features/search_parameters.html) section
141
+ of the documentation.
142
+
143
+ #### AsyncClient
144
+
145
+ ```py
146
+ await index.search(
147
+ "guide",
148
+ attributes_to_highlight=["title"],
149
+ filters="book_id > 10"
150
+ )
151
+ ```
152
+
153
+ #### Client
154
+
155
+ ```py
156
+ index.search(
157
+ "guide",
158
+ attributes_to_highlight=["title"],
159
+ filters="book_id > 10"
160
+ )
161
+ ```
162
+
163
+ ### Custom Search Results: SearchResults object with values
164
+
165
+ ```py
166
+ SearchResults(
167
+ hits = [
168
+ {
169
+ "id": 42,
170
+ "title": "The Hitchhiker's Guide to the Galaxy",
171
+ "_formatted": {
172
+ "id": 42,
173
+ "title": "The Hitchhiker's Guide to the <em>Galaxy</em>"
174
+ }
175
+ },
176
+ ],
177
+ offset = 0,
178
+ limit = 20,
179
+ nb_hits = 1,
180
+ exhaustive_nb_hits = bool,
181
+ facets_distributionn = None,
182
+ processing_time_ms = 5,
183
+ query = "galaxy",
184
+ )
185
+ ```
186
+
187
+ ## Benchmark
188
+
189
+ The following benchmarks compare this library to the official
190
+ [Meilisearch Python](https://github.com/meilisearch/meilisearch-python) library. Note that all
191
+ of the performance gains seen with the `AsyncClient` are achieved by taking advantage of asyncio.
192
+ This means that if your code is not taking advantage of asyncio or blocking the event loop the
193
+ gains here will not be seen and the performance between the clients will be very close to the same.
194
+
195
+ ### Add Documents in Batches
196
+
197
+ This test compares how long it takes to send 1 million documents in batches of 1 thousand to the
198
+ Meilisearch server for indexing (lower is better). The time does not take into account how long
199
+ Meilisearch takes to index the documents since that is outside of the library functionality.
200
+
201
+ ![Add Documents in Batches](https://raw.githubusercontent.com/sanders41/meilisearch-python-sdk/main/assets/add_in_batches.png)
202
+
203
+ ### Muiltiple Searches
204
+
205
+ This test compares how long it takes to complete 1000 searches (lower is better)
206
+
207
+ ![Multiple Searches](https://raw.githubusercontent.com/sanders41/meilisearch-python-sdk/main/assets/searches.png)
208
+
209
+ ### Independent testing
210
+
211
+ [Prashanth Rao](https://github.com/prrao87) did some independent testing and found this async client
212
+ to be ~30% faster than the sync client for data ingestion. You can find a good write-up of the
213
+ results how he tested them in his [blog post](https://thedataquarry.com/posts/meilisearch-async/).
214
+
215
+ ## Documentation
216
+
217
+ See our [docs](https://meilisearch-python-sdk.paulsanders.dev) for the full documentation.
218
+
219
+ ## Contributing
220
+
221
+ Contributions to this project are welcome. If you are interested in contributing please see our
222
+ [contributing guide](CONTRIBUTING.md)
@@ -0,0 +1,8 @@
1
+ from meilisearch_python_sdk._client import AsyncClient, Client
2
+ from meilisearch_python_sdk._index import AsyncIndex, Index
3
+ from meilisearch_python_sdk._version import VERSION
4
+
5
+ __version__ = VERSION
6
+
7
+
8
+ __all__ = ["AsyncClient", "AsyncIndex", "Client", "Index"]