meilisearch-python-sdk 3.0.1__py3-none-any.whl → 3.1.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.
- meilisearch_python_sdk/_client.py +45 -10
- meilisearch_python_sdk/_version.py +1 -1
- meilisearch_python_sdk/index.py +42 -9
- meilisearch_python_sdk/models/search.py +11 -9
- {meilisearch_python_sdk-3.0.1.dist-info → meilisearch_python_sdk-3.1.0.dist-info}/METADATA +1 -1
- {meilisearch_python_sdk-3.0.1.dist-info → meilisearch_python_sdk-3.1.0.dist-info}/RECORD +8 -8
- {meilisearch_python_sdk-3.0.1.dist-info → meilisearch_python_sdk-3.1.0.dist-info}/LICENSE +0 -0
- {meilisearch_python_sdk-3.0.1.dist-info → meilisearch_python_sdk-3.1.0.dist-info}/WHEEL +0 -0
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from datetime import datetime, timezone
|
|
4
4
|
from ssl import SSLContext
|
|
5
|
-
from typing import TYPE_CHECKING
|
|
5
|
+
from typing import TYPE_CHECKING, Any
|
|
6
6
|
|
|
7
7
|
import jwt
|
|
8
8
|
from httpx import AsyncClient as HttpxAsyncClient
|
|
@@ -27,12 +27,13 @@ from meilisearch_python_sdk.models.settings import MeilisearchSettings
|
|
|
27
27
|
from meilisearch_python_sdk.models.task import TaskInfo, TaskResult, TaskStatus
|
|
28
28
|
from meilisearch_python_sdk.models.version import Version
|
|
29
29
|
from meilisearch_python_sdk.plugins import AsyncIndexPlugins, IndexPlugins
|
|
30
|
+
from meilisearch_python_sdk.types import JsonDict
|
|
30
31
|
|
|
31
32
|
if TYPE_CHECKING: # pragma: no cover
|
|
32
33
|
import sys
|
|
33
34
|
from types import TracebackType
|
|
34
35
|
|
|
35
|
-
from meilisearch_python_sdk.types import
|
|
36
|
+
from meilisearch_python_sdk.types import JsonMapping
|
|
36
37
|
|
|
37
38
|
if sys.version_info >= (3, 11):
|
|
38
39
|
from typing import Self
|
|
@@ -219,6 +220,7 @@ class AsyncClient(BaseClient):
|
|
|
219
220
|
wait: bool = True,
|
|
220
221
|
timeout_in_ms: int | None = None,
|
|
221
222
|
plugins: AsyncIndexPlugins | None = None,
|
|
223
|
+
hits_type: Any = JsonDict,
|
|
222
224
|
) -> AsyncIndex:
|
|
223
225
|
"""Creates a new index.
|
|
224
226
|
|
|
@@ -238,6 +240,8 @@ class AsyncClient(BaseClient):
|
|
|
238
240
|
MeilisearchTimeoutError. `None` can also be passed to wait indefinitely. Be aware that
|
|
239
241
|
if the `None` option is used the wait time could be very long. Defaults to None.
|
|
240
242
|
plugins: Optional plugins can be provided to extend functionality.
|
|
243
|
+
hits_type: Allows for a custom type to be passed to use for hits. Defaults to
|
|
244
|
+
JsonDict
|
|
241
245
|
|
|
242
246
|
Returns:
|
|
243
247
|
|
|
@@ -263,6 +267,7 @@ class AsyncClient(BaseClient):
|
|
|
263
267
|
timeout_in_ms=timeout_in_ms,
|
|
264
268
|
plugins=plugins,
|
|
265
269
|
json_handler=self.json_handler,
|
|
270
|
+
hits_type=hits_type,
|
|
266
271
|
)
|
|
267
272
|
|
|
268
273
|
async def create_snapshot(self) -> TaskInfo:
|
|
@@ -436,7 +441,12 @@ class AsyncClient(BaseClient):
|
|
|
436
441
|
return ClientStats(**response.json())
|
|
437
442
|
|
|
438
443
|
async def get_or_create_index(
|
|
439
|
-
self,
|
|
444
|
+
self,
|
|
445
|
+
uid: str,
|
|
446
|
+
primary_key: str | None = None,
|
|
447
|
+
*,
|
|
448
|
+
plugins: AsyncIndexPlugins | None = None,
|
|
449
|
+
hits_type: Any = JsonDict,
|
|
440
450
|
) -> AsyncIndex:
|
|
441
451
|
"""Get an index, or create it if it doesn't exist.
|
|
442
452
|
|
|
@@ -445,6 +455,8 @@ class AsyncClient(BaseClient):
|
|
|
445
455
|
uid: The index's unique identifier.
|
|
446
456
|
primary_key: The primary key of the documents. Defaults to None.
|
|
447
457
|
plugins: Optional plugins can be provided to extend functionality.
|
|
458
|
+
hits_type: Allows for a custom type to be passed to use for hits. Defaults to
|
|
459
|
+
JsonDict
|
|
448
460
|
|
|
449
461
|
Returns:
|
|
450
462
|
|
|
@@ -467,7 +479,9 @@ class AsyncClient(BaseClient):
|
|
|
467
479
|
except MeilisearchApiError as err:
|
|
468
480
|
if "index_not_found" not in err.code:
|
|
469
481
|
raise
|
|
470
|
-
index_instance = await self.create_index(
|
|
482
|
+
index_instance = await self.create_index(
|
|
483
|
+
uid, primary_key, plugins=plugins, hits_type=hits_type
|
|
484
|
+
)
|
|
471
485
|
return index_instance
|
|
472
486
|
|
|
473
487
|
async def create_key(self, key: KeyCreate) -> Key:
|
|
@@ -618,12 +632,16 @@ class AsyncClient(BaseClient):
|
|
|
618
632
|
|
|
619
633
|
return Key(**response.json())
|
|
620
634
|
|
|
621
|
-
async def multi_search(
|
|
635
|
+
async def multi_search(
|
|
636
|
+
self, queries: list[SearchParams], *, hits_type: Any = JsonDict
|
|
637
|
+
) -> list[SearchResultsWithUID]:
|
|
622
638
|
"""Multi-index search.
|
|
623
639
|
|
|
624
640
|
Args:
|
|
625
641
|
|
|
626
642
|
queries: List of SearchParameters
|
|
643
|
+
hits_type: Allows for a custom type to be passed to use for hits. Defaults to
|
|
644
|
+
JsonDict
|
|
627
645
|
|
|
628
646
|
Returns:
|
|
629
647
|
|
|
@@ -651,7 +669,7 @@ class AsyncClient(BaseClient):
|
|
|
651
669
|
body={"queries": [x.model_dump(by_alias=True) for x in queries]}, # type: ignore[attr-defined]
|
|
652
670
|
)
|
|
653
671
|
|
|
654
|
-
return [SearchResultsWithUID(**x) for x in response.json()["results"]]
|
|
672
|
+
return [SearchResultsWithUID[hits_type](**x) for x in response.json()["results"]]
|
|
655
673
|
|
|
656
674
|
async def get_raw_index(self, uid: str) -> IndexInfo | None:
|
|
657
675
|
"""Gets the index and returns all the index information rather than an AsyncIndex instance.
|
|
@@ -1083,6 +1101,7 @@ class Client(BaseClient):
|
|
|
1083
1101
|
wait: bool = True,
|
|
1084
1102
|
timeout_in_ms: int | None = None,
|
|
1085
1103
|
plugins: IndexPlugins | None = None,
|
|
1104
|
+
hits_type: Any = JsonDict,
|
|
1086
1105
|
) -> Index:
|
|
1087
1106
|
"""Creates a new index.
|
|
1088
1107
|
|
|
@@ -1102,6 +1121,8 @@ class Client(BaseClient):
|
|
|
1102
1121
|
MeilisearchTimeoutError. `None` can also be passed to wait indefinitely. Be aware that
|
|
1103
1122
|
if the `None` option is used the wait time could be very long. Defaults to None.
|
|
1104
1123
|
plugins: Optional plugins can be provided to extend functionality.
|
|
1124
|
+
hits_type: Allows for a custom type to be passed to use for hits. Defaults to
|
|
1125
|
+
JsonDict
|
|
1105
1126
|
|
|
1106
1127
|
Returns:
|
|
1107
1128
|
|
|
@@ -1127,6 +1148,7 @@ class Client(BaseClient):
|
|
|
1127
1148
|
timeout_in_ms=timeout_in_ms,
|
|
1128
1149
|
plugins=plugins,
|
|
1129
1150
|
json_handler=self.json_handler,
|
|
1151
|
+
hits_type=hits_type,
|
|
1130
1152
|
)
|
|
1131
1153
|
|
|
1132
1154
|
def create_snapshot(self) -> TaskInfo:
|
|
@@ -1296,7 +1318,12 @@ class Client(BaseClient):
|
|
|
1296
1318
|
return ClientStats(**response.json())
|
|
1297
1319
|
|
|
1298
1320
|
def get_or_create_index(
|
|
1299
|
-
self,
|
|
1321
|
+
self,
|
|
1322
|
+
uid: str,
|
|
1323
|
+
primary_key: str | None = None,
|
|
1324
|
+
*,
|
|
1325
|
+
plugins: IndexPlugins | None = None,
|
|
1326
|
+
hits_type: Any = JsonDict,
|
|
1300
1327
|
) -> Index:
|
|
1301
1328
|
"""Get an index, or create it if it doesn't exist.
|
|
1302
1329
|
|
|
@@ -1305,6 +1332,8 @@ class Client(BaseClient):
|
|
|
1305
1332
|
uid: The index's unique identifier.
|
|
1306
1333
|
primary_key: The primary key of the documents. Defaults to None.
|
|
1307
1334
|
plugins: Optional plugins can be provided to extend functionality.
|
|
1335
|
+
hits_type: Allows for a custom type to be passed to use for hits. Defaults to
|
|
1336
|
+
JsonDict
|
|
1308
1337
|
|
|
1309
1338
|
Returns:
|
|
1310
1339
|
|
|
@@ -1327,7 +1356,9 @@ class Client(BaseClient):
|
|
|
1327
1356
|
except MeilisearchApiError as err:
|
|
1328
1357
|
if "index_not_found" not in err.code:
|
|
1329
1358
|
raise
|
|
1330
|
-
index_instance = self.create_index(
|
|
1359
|
+
index_instance = self.create_index(
|
|
1360
|
+
uid, primary_key, plugins=plugins, hits_type=hits_type
|
|
1361
|
+
)
|
|
1331
1362
|
return index_instance
|
|
1332
1363
|
|
|
1333
1364
|
def create_key(self, key: KeyCreate) -> Key:
|
|
@@ -1478,12 +1509,16 @@ class Client(BaseClient):
|
|
|
1478
1509
|
|
|
1479
1510
|
return Key(**response.json())
|
|
1480
1511
|
|
|
1481
|
-
def multi_search(
|
|
1512
|
+
def multi_search(
|
|
1513
|
+
self, queries: list[SearchParams], *, hits_type: Any = JsonDict
|
|
1514
|
+
) -> list[SearchResultsWithUID]:
|
|
1482
1515
|
"""Multi-index search.
|
|
1483
1516
|
|
|
1484
1517
|
Args:
|
|
1485
1518
|
|
|
1486
1519
|
queries: List of SearchParameters
|
|
1520
|
+
hits_type: Allows for a custom type to be passed to use for hits. Defaults to
|
|
1521
|
+
JsonDict
|
|
1487
1522
|
|
|
1488
1523
|
Returns:
|
|
1489
1524
|
|
|
@@ -1511,7 +1546,7 @@ class Client(BaseClient):
|
|
|
1511
1546
|
body={"queries": [x.model_dump(by_alias=True) for x in queries]}, # type: ignore[attr-defined]
|
|
1512
1547
|
)
|
|
1513
1548
|
|
|
1514
|
-
return [SearchResultsWithUID(**x) for x in response.json()["results"]]
|
|
1549
|
+
return [SearchResultsWithUID[hits_type](**x) for x in response.json()["results"]]
|
|
1515
1550
|
|
|
1516
1551
|
def get_raw_index(self, uid: str) -> IndexInfo | None:
|
|
1517
1552
|
"""Gets the index and returns all the index information rather than an Index instance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = "3.0
|
|
1
|
+
VERSION = "3.1.0"
|
meilisearch_python_sdk/index.py
CHANGED
|
@@ -52,11 +52,12 @@ from meilisearch_python_sdk.plugins import (
|
|
|
52
52
|
Plugin,
|
|
53
53
|
PostSearchPlugin,
|
|
54
54
|
)
|
|
55
|
+
from meilisearch_python_sdk.types import JsonDict
|
|
55
56
|
|
|
56
57
|
if TYPE_CHECKING: # pragma: no cover
|
|
57
58
|
import sys
|
|
58
59
|
|
|
59
|
-
from meilisearch_python_sdk.types import Filter,
|
|
60
|
+
from meilisearch_python_sdk.types import Filter, JsonMapping
|
|
60
61
|
|
|
61
62
|
if sys.version_info >= (3, 11):
|
|
62
63
|
from typing import Self
|
|
@@ -72,11 +73,13 @@ class _BaseIndex:
|
|
|
72
73
|
created_at: str | datetime | None = None,
|
|
73
74
|
updated_at: str | datetime | None = None,
|
|
74
75
|
json_handler: BuiltinHandler | OrjsonHandler | UjsonHandler | None = None,
|
|
76
|
+
hits_type: Any = JsonDict,
|
|
75
77
|
):
|
|
76
78
|
self.uid = uid
|
|
77
79
|
self.primary_key = primary_key
|
|
78
80
|
self.created_at: datetime | None = iso_to_date_time(created_at)
|
|
79
81
|
self.updated_at: datetime | None = iso_to_date_time(updated_at)
|
|
82
|
+
self.hits_type = hits_type
|
|
80
83
|
self._base_url = "indexes/"
|
|
81
84
|
self._base_url_with_uid = f"{self._base_url}{self.uid}"
|
|
82
85
|
self._documents_url = f"{self._base_url_with_uid}/documents"
|
|
@@ -113,6 +116,8 @@ class AsyncIndex(_BaseIndex):
|
|
|
113
116
|
updated_at: str | datetime | None = None,
|
|
114
117
|
plugins: AsyncIndexPlugins | None = None,
|
|
115
118
|
json_handler: BuiltinHandler | OrjsonHandler | UjsonHandler | None = None,
|
|
119
|
+
*,
|
|
120
|
+
hits_type: Any = JsonDict,
|
|
116
121
|
):
|
|
117
122
|
"""Class initializer.
|
|
118
123
|
|
|
@@ -129,8 +134,17 @@ class AsyncIndex(_BaseIndex):
|
|
|
129
134
|
(uses the json module from the standard library), OrjsonHandler (uses orjson), or
|
|
130
135
|
UjsonHandler (uses ujson). Note that in order use orjson or ujson the corresponding
|
|
131
136
|
extra needs to be included. Default: BuiltinHandler.
|
|
137
|
+
hits_type: Allows for a custom type to be passed to use for hits. Defaults to
|
|
138
|
+
JsonDict
|
|
132
139
|
"""
|
|
133
|
-
super().__init__(
|
|
140
|
+
super().__init__(
|
|
141
|
+
uid=uid,
|
|
142
|
+
primary_key=primary_key,
|
|
143
|
+
created_at=created_at,
|
|
144
|
+
updated_at=updated_at,
|
|
145
|
+
json_handler=json_handler,
|
|
146
|
+
hits_type=hits_type,
|
|
147
|
+
)
|
|
134
148
|
self.http_client = http_client
|
|
135
149
|
self._http_requests = AsyncHttpRequests(http_client, json_handler=self._json_handler)
|
|
136
150
|
self.plugins = plugins
|
|
@@ -639,6 +653,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
639
653
|
timeout_in_ms: int | None = None,
|
|
640
654
|
plugins: AsyncIndexPlugins | None = None,
|
|
641
655
|
json_handler: BuiltinHandler | OrjsonHandler | UjsonHandler | None = None,
|
|
656
|
+
hits_type: Any = JsonDict,
|
|
642
657
|
) -> Self:
|
|
643
658
|
"""Creates a new index.
|
|
644
659
|
|
|
@@ -667,6 +682,8 @@ class AsyncIndex(_BaseIndex):
|
|
|
667
682
|
(uses the json module from the standard library), OrjsonHandler (uses orjson), or
|
|
668
683
|
UjsonHandler (uses ujson). Note that in order use orjson or ujson the corresponding
|
|
669
684
|
extra needs to be included. Default: BuiltinHandler.
|
|
685
|
+
hits_type: Allows for a custom type to be passed to use for hits. Defaults to
|
|
686
|
+
JsonDict
|
|
670
687
|
|
|
671
688
|
Returns:
|
|
672
689
|
|
|
@@ -708,6 +725,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
708
725
|
updated_at=index_dict["updatedAt"],
|
|
709
726
|
plugins=plugins,
|
|
710
727
|
json_handler=json_handler,
|
|
728
|
+
hits_type=hits_type,
|
|
711
729
|
)
|
|
712
730
|
|
|
713
731
|
if settings:
|
|
@@ -934,7 +952,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
934
952
|
concurrent_tasks.append(self._http_requests.post(search_url, body=body))
|
|
935
953
|
|
|
936
954
|
responses = await asyncio.gather(*concurrent_tasks)
|
|
937
|
-
result = SearchResults(**responses[-1].json())
|
|
955
|
+
result = SearchResults[self.hits_type](**responses[-1].json()) # type: ignore[name-defined]
|
|
938
956
|
if self._post_search_plugins:
|
|
939
957
|
post = await AsyncIndex._run_plugins(
|
|
940
958
|
self._post_search_plugins, AsyncEvent.POST, search_results=result
|
|
@@ -977,7 +995,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
977
995
|
response_coroutine = tg.create_task(self._http_requests.post(search_url, body=body))
|
|
978
996
|
|
|
979
997
|
response = await response_coroutine
|
|
980
|
-
result = SearchResults(**response.json())
|
|
998
|
+
result = SearchResults[self.hits_type](**response.json()) # type: ignore[name-defined]
|
|
981
999
|
if self._post_search_plugins:
|
|
982
1000
|
post = await AsyncIndex._run_plugins(
|
|
983
1001
|
self._post_search_plugins, AsyncEvent.POST, search_results=result
|
|
@@ -988,7 +1006,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
988
1006
|
return result
|
|
989
1007
|
|
|
990
1008
|
response = await self._http_requests.post(search_url, body=body)
|
|
991
|
-
result = SearchResults(**response.json())
|
|
1009
|
+
result = SearchResults[self.hits_type](**response.json()) # type: ignore[name-defined]
|
|
992
1010
|
|
|
993
1011
|
if self._post_search_plugins:
|
|
994
1012
|
post = await AsyncIndex._run_plugins(
|
|
@@ -1324,7 +1342,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
1324
1342
|
f"{self._base_url_with_uid}/similar", body=payload
|
|
1325
1343
|
)
|
|
1326
1344
|
|
|
1327
|
-
return SimilarSearchResults(**response.json())
|
|
1345
|
+
return SimilarSearchResults[self.hits_type](**response.json()) # type: ignore[name-defined]
|
|
1328
1346
|
|
|
1329
1347
|
async def get_document(self, document_id: str) -> JsonDict:
|
|
1330
1348
|
"""Get one document with given document identifier.
|
|
@@ -4516,6 +4534,8 @@ class Index(_BaseIndex):
|
|
|
4516
4534
|
updated_at: str | datetime | None = None,
|
|
4517
4535
|
plugins: IndexPlugins | None = None,
|
|
4518
4536
|
json_handler: BuiltinHandler | OrjsonHandler | UjsonHandler | None = None,
|
|
4537
|
+
*,
|
|
4538
|
+
hits_type: Any = JsonDict,
|
|
4519
4539
|
):
|
|
4520
4540
|
"""Class initializer.
|
|
4521
4541
|
|
|
@@ -4532,8 +4552,17 @@ class Index(_BaseIndex):
|
|
|
4532
4552
|
(uses the json module from the standard library), OrjsonHandler (uses orjson), or
|
|
4533
4553
|
UjsonHandler (uses ujson). Note that in order use orjson or ujson the corresponding
|
|
4534
4554
|
extra needs to be included. Default: BuiltinHandler.
|
|
4555
|
+
hits_type: Allows for a custom type to be passed to use for hits. Defaults to
|
|
4556
|
+
JsonDict
|
|
4535
4557
|
"""
|
|
4536
|
-
super().__init__(
|
|
4558
|
+
super().__init__(
|
|
4559
|
+
uid=uid,
|
|
4560
|
+
primary_key=primary_key,
|
|
4561
|
+
created_at=created_at,
|
|
4562
|
+
updated_at=updated_at,
|
|
4563
|
+
json_handler=json_handler,
|
|
4564
|
+
hits_type=hits_type,
|
|
4565
|
+
)
|
|
4537
4566
|
self.http_client = http_client
|
|
4538
4567
|
self._http_requests = HttpRequests(http_client, json_handler=self._json_handler)
|
|
4539
4568
|
self.plugins = plugins
|
|
@@ -4916,6 +4945,7 @@ class Index(_BaseIndex):
|
|
|
4916
4945
|
timeout_in_ms: int | None = None,
|
|
4917
4946
|
plugins: IndexPlugins | None = None,
|
|
4918
4947
|
json_handler: BuiltinHandler | OrjsonHandler | UjsonHandler | None = None,
|
|
4948
|
+
hits_type: Any = JsonDict,
|
|
4919
4949
|
) -> Self:
|
|
4920
4950
|
"""Creates a new index.
|
|
4921
4951
|
|
|
@@ -4944,6 +4974,8 @@ class Index(_BaseIndex):
|
|
|
4944
4974
|
(uses the json module from the standard library), OrjsonHandler (uses orjson), or
|
|
4945
4975
|
UjsonHandler (uses ujson). Note that in order use orjson or ujson the corresponding
|
|
4946
4976
|
extra needs to be included. Default: BuiltinHandler.
|
|
4977
|
+
hits_type: Allows for a custom type to be passed to use for hits. Defaults to
|
|
4978
|
+
JsonDict
|
|
4947
4979
|
|
|
4948
4980
|
Returns:
|
|
4949
4981
|
|
|
@@ -4980,6 +5012,7 @@ class Index(_BaseIndex):
|
|
|
4980
5012
|
updated_at=index_dict["updatedAt"],
|
|
4981
5013
|
plugins=plugins,
|
|
4982
5014
|
json_handler=json_handler,
|
|
5015
|
+
hits_type=hits_type,
|
|
4983
5016
|
)
|
|
4984
5017
|
|
|
4985
5018
|
if settings:
|
|
@@ -5169,7 +5202,7 @@ class Index(_BaseIndex):
|
|
|
5169
5202
|
)
|
|
5170
5203
|
|
|
5171
5204
|
response = self._http_requests.post(f"{self._base_url_with_uid}/search", body=body)
|
|
5172
|
-
result = SearchResults(**response.json())
|
|
5205
|
+
result = SearchResults[self.hits_type](**response.json()) # type: ignore[name-defined]
|
|
5173
5206
|
if self._post_search_plugins:
|
|
5174
5207
|
post = Index._run_plugins(self._post_search_plugins, Event.POST, search_results=result)
|
|
5175
5208
|
if post.get("search_result"):
|
|
@@ -5408,7 +5441,7 @@ class Index(_BaseIndex):
|
|
|
5408
5441
|
|
|
5409
5442
|
response = self._http_requests.post(f"{self._base_url_with_uid}/similar", body=payload)
|
|
5410
5443
|
|
|
5411
|
-
return SimilarSearchResults(**response.json())
|
|
5444
|
+
return SimilarSearchResults[self.hits_type](**response.json()) # type: ignore[name-defined]
|
|
5412
5445
|
|
|
5413
5446
|
def get_document(self, document_id: str) -> JsonDict:
|
|
5414
5447
|
"""Get one document with given document identifier.
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import Literal
|
|
3
|
+
from typing import Generic, Literal, TypeVar
|
|
4
4
|
|
|
5
|
-
import pydantic
|
|
6
5
|
from camel_converter.pydantic_base import CamelBase
|
|
6
|
+
from pydantic import Field, field_validator
|
|
7
7
|
|
|
8
8
|
from meilisearch_python_sdk.errors import MeilisearchError
|
|
9
9
|
from meilisearch_python_sdk.types import Filter, JsonDict
|
|
10
10
|
|
|
11
|
+
T = TypeVar("T")
|
|
12
|
+
|
|
11
13
|
|
|
12
14
|
class FacetHits(CamelBase):
|
|
13
15
|
value: str
|
|
@@ -27,7 +29,7 @@ class Hybrid(CamelBase):
|
|
|
27
29
|
|
|
28
30
|
class SearchParams(CamelBase):
|
|
29
31
|
index_uid: str
|
|
30
|
-
query: str | None =
|
|
32
|
+
query: str | None = Field(None, alias="q")
|
|
31
33
|
offset: int = 0
|
|
32
34
|
limit: int = 20
|
|
33
35
|
filter: Filter | None = None
|
|
@@ -51,7 +53,7 @@ class SearchParams(CamelBase):
|
|
|
51
53
|
vector: list[float] | None = None
|
|
52
54
|
hybrid: Hybrid | None = None
|
|
53
55
|
|
|
54
|
-
@
|
|
56
|
+
@field_validator("ranking_score_threshold", mode="before") # type: ignore[attr-defined]
|
|
55
57
|
@classmethod
|
|
56
58
|
def validate_ranking_score_threshold(cls, v: float | None) -> float | None:
|
|
57
59
|
if v and not 0.0 <= v <= 1.0:
|
|
@@ -60,8 +62,8 @@ class SearchParams(CamelBase):
|
|
|
60
62
|
return v
|
|
61
63
|
|
|
62
64
|
|
|
63
|
-
class SearchResults(CamelBase):
|
|
64
|
-
hits: list[
|
|
65
|
+
class SearchResults(CamelBase, Generic[T]):
|
|
66
|
+
hits: list[T]
|
|
65
67
|
offset: int | None = None
|
|
66
68
|
limit: int | None = None
|
|
67
69
|
estimated_total_hits: int | None = None
|
|
@@ -75,12 +77,12 @@ class SearchResults(CamelBase):
|
|
|
75
77
|
semantic_hit_count: int | None = None
|
|
76
78
|
|
|
77
79
|
|
|
78
|
-
class SearchResultsWithUID(SearchResults):
|
|
80
|
+
class SearchResultsWithUID(SearchResults, Generic[T]):
|
|
79
81
|
index_uid: str
|
|
80
82
|
|
|
81
83
|
|
|
82
|
-
class SimilarSearchResults(CamelBase):
|
|
83
|
-
hits: list[
|
|
84
|
+
class SimilarSearchResults(CamelBase, Generic[T]):
|
|
85
|
+
hits: list[T]
|
|
84
86
|
id: str
|
|
85
87
|
processing_time_ms: int
|
|
86
88
|
limit: int | None = None
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
meilisearch_python_sdk/__init__.py,sha256=SB0Jlm6FwT13J9xasZKseZzTWBk0hkfe1CWyWmIIZnE,258
|
|
2
|
-
meilisearch_python_sdk/_client.py,sha256=
|
|
2
|
+
meilisearch_python_sdk/_client.py,sha256=I4HVtgzuwlQ-BmyUlVXQTZ3dJR7YIhyfs0qQTXEYBfM,68170
|
|
3
3
|
meilisearch_python_sdk/_http_requests.py,sha256=TwpqsOvfgaJ1lQXwam1q1_UC6NvRWy4m9W3c5KNe0RI,6741
|
|
4
4
|
meilisearch_python_sdk/_task.py,sha256=dB0cpX1u7HDM1OW_TC8gSiGJe985bNCz7hPMZW_qogY,12352
|
|
5
5
|
meilisearch_python_sdk/_utils.py,sha256=k6SYMJSiVjfF-vlhQRMaE1ziJsVf5FrL94mFwrMfdLY,957
|
|
6
|
-
meilisearch_python_sdk/_version.py,sha256=
|
|
6
|
+
meilisearch_python_sdk/_version.py,sha256=3vf_fJuJ1GKgsLolRXa0KsZlsevgoI4iyhPFl5-KJnM,18
|
|
7
7
|
meilisearch_python_sdk/decorators.py,sha256=KpS5gAgks28BtPMZJumRaXfgXK4A3QNVPR8Z4BpZC0g,8346
|
|
8
8
|
meilisearch_python_sdk/errors.py,sha256=0sAKYt47-zFpKsEU6W8Qnvf4uHBynKtlGPpPl-5laSA,2085
|
|
9
|
-
meilisearch_python_sdk/index.py,sha256=
|
|
9
|
+
meilisearch_python_sdk/index.py,sha256=uW9m5gnLwHdQKiDf4DV0k4ksr252HzmkJQT3KCicg8g,314470
|
|
10
10
|
meilisearch_python_sdk/json_handler.py,sha256=q_87zSnJfDNuVEI9cEvuOQOGBC7AGWJMEqCh2kGAAqA,2107
|
|
11
11
|
meilisearch_python_sdk/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
meilisearch_python_sdk/models/client.py,sha256=wBZzO1n6DDQq7F9Acf1rCWYEYRY19g04uFiEf9JCMjc,2423
|
|
13
13
|
meilisearch_python_sdk/models/documents.py,sha256=eT3FHrPND-g2IzNRyOHQApTTJ1WbFcGlqgxZ6aKrRgI,247
|
|
14
14
|
meilisearch_python_sdk/models/health.py,sha256=hvruti7ylsk7bAh8RPOhTPcRrjx6MPgdkDFX9vZ5Qks,95
|
|
15
15
|
meilisearch_python_sdk/models/index.py,sha256=GGwuhx5Wsn5iyj1ov3f4eWjfw6ttM8WzvyrnSsC4vRg,1132
|
|
16
|
-
meilisearch_python_sdk/models/search.py,sha256=
|
|
16
|
+
meilisearch_python_sdk/models/search.py,sha256=roaP0ElXMfa-NQF_bS3wuAEHHxTRJpT-qSnTsls5qjw,2586
|
|
17
17
|
meilisearch_python_sdk/models/settings.py,sha256=FugCLAMESWQknHoViD84XfghlEWXcYIlnufb05Qq6IQ,3852
|
|
18
18
|
meilisearch_python_sdk/models/task.py,sha256=P3NLaZhrY8H02Q9lDEkoq-3Z6_qGESglOxs4dNRyMWg,2100
|
|
19
19
|
meilisearch_python_sdk/models/version.py,sha256=YDu-aj5H-d6nSaWRTXzlwWghmZAoiknaw250UyEd48I,215
|
|
20
20
|
meilisearch_python_sdk/plugins.py,sha256=YySzTuVr4IrogTgrP8q-gZPsew8TwedopjWnTj5eV48,3607
|
|
21
21
|
meilisearch_python_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
22
|
meilisearch_python_sdk/types.py,sha256=VBzt-JF6w1f5V_aTAM3NetDQxs9fscnRy8t-Y1HWZXM,404
|
|
23
|
-
meilisearch_python_sdk-3.0.
|
|
24
|
-
meilisearch_python_sdk-3.0.
|
|
25
|
-
meilisearch_python_sdk-3.0.
|
|
26
|
-
meilisearch_python_sdk-3.0.
|
|
23
|
+
meilisearch_python_sdk-3.1.0.dist-info/LICENSE,sha256=xVzevI1TrlKfM0plmJ7vfK1Muu0V9n-dGE8RnDrOFlM,1069
|
|
24
|
+
meilisearch_python_sdk-3.1.0.dist-info/METADATA,sha256=Nf5ywGBA550PlIm1bvQy3_WE0BjXa6n0QDDlkSgWt6Y,8491
|
|
25
|
+
meilisearch_python_sdk-3.1.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
26
|
+
meilisearch_python_sdk-3.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|