meilisearch-python-sdk 2.9.0__tar.gz → 2.10.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.
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/PKG-INFO +1 -1
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/_http_requests.py +30 -8
- meilisearch_python_sdk-2.10.0/meilisearch_python_sdk/_version.py +1 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/index.py +238 -45
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/pyproject.toml +1 -1
- meilisearch_python_sdk-2.9.0/meilisearch_python_sdk/_version.py +0 -1
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/LICENSE +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/README.md +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/__init__.py +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/_client.py +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/_task.py +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/_utils.py +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/decorators.py +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/errors.py +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/models/__init__.py +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/models/client.py +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/models/documents.py +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/models/health.py +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/models/index.py +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/models/search.py +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/models/settings.py +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/models/task.py +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/models/version.py +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/plugins.py +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/py.typed +0 -0
- {meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/types.py +0 -0
|
@@ -34,6 +34,8 @@ class AsyncHttpRequests:
|
|
|
34
34
|
body: Any | None = None,
|
|
35
35
|
content_type: str = "application/json",
|
|
36
36
|
compress: bool = False,
|
|
37
|
+
*,
|
|
38
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
37
39
|
) -> Response:
|
|
38
40
|
headers = build_headers(content_type, compress)
|
|
39
41
|
|
|
@@ -41,11 +43,13 @@ class AsyncHttpRequests:
|
|
|
41
43
|
if body is None:
|
|
42
44
|
response = await http_method(path)
|
|
43
45
|
elif content_type == "application/json" and not compress:
|
|
44
|
-
response = await http_method(
|
|
46
|
+
response = await http_method(
|
|
47
|
+
path, data=json.dumps(body, cls=serializer), headers=headers
|
|
48
|
+
)
|
|
45
49
|
else:
|
|
46
50
|
if body and compress:
|
|
47
51
|
if content_type == "application/json":
|
|
48
|
-
body = gzip.compress(json.dumps(body).encode("utf-8"))
|
|
52
|
+
body = gzip.compress(json.dumps(body, cls=serializer).encode("utf-8"))
|
|
49
53
|
else:
|
|
50
54
|
body = gzip.compress((body).encode("utf-8"))
|
|
51
55
|
response = await http_method(path, content=body, headers=headers)
|
|
@@ -80,8 +84,12 @@ class AsyncHttpRequests:
|
|
|
80
84
|
body: Any | None = None,
|
|
81
85
|
content_type: str = "application/json",
|
|
82
86
|
compress: bool = False,
|
|
87
|
+
*,
|
|
88
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
83
89
|
) -> Response:
|
|
84
|
-
return await self._send_request(
|
|
90
|
+
return await self._send_request(
|
|
91
|
+
self.http_client.post, path, body, content_type, compress, serializer=serializer
|
|
92
|
+
)
|
|
85
93
|
|
|
86
94
|
async def put(
|
|
87
95
|
self,
|
|
@@ -89,8 +97,12 @@ class AsyncHttpRequests:
|
|
|
89
97
|
body: Any | None = None,
|
|
90
98
|
content_type: str = "application/json",
|
|
91
99
|
compress: bool = False,
|
|
100
|
+
*,
|
|
101
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
92
102
|
) -> Response:
|
|
93
|
-
return await self._send_request(
|
|
103
|
+
return await self._send_request(
|
|
104
|
+
self.http_client.put, path, body, content_type, compress, serializer=serializer
|
|
105
|
+
)
|
|
94
106
|
|
|
95
107
|
async def delete(self, path: str, body: dict | None = None) -> Response:
|
|
96
108
|
return await self._send_request(self.http_client.delete, path, body)
|
|
@@ -107,17 +119,19 @@ class HttpRequests:
|
|
|
107
119
|
body: Any | None = None,
|
|
108
120
|
content_type: str = "applicaton/json",
|
|
109
121
|
compress: bool = False,
|
|
122
|
+
*,
|
|
123
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
110
124
|
) -> Response:
|
|
111
125
|
headers = build_headers(content_type, compress)
|
|
112
126
|
try:
|
|
113
127
|
if not body:
|
|
114
128
|
response = http_method(path)
|
|
115
129
|
elif content_type == "application/json" and not compress:
|
|
116
|
-
response = http_method(path, json
|
|
130
|
+
response = http_method(path, data=json.dumps(body, cls=serializer), headers=headers)
|
|
117
131
|
else:
|
|
118
132
|
if body and compress:
|
|
119
133
|
if content_type == "application/json":
|
|
120
|
-
body = gzip.compress(json.dumps(body).encode("utf-8"))
|
|
134
|
+
body = gzip.compress(json.dumps(body, cls=serializer).encode("utf-8"))
|
|
121
135
|
else:
|
|
122
136
|
body = gzip.compress((body).encode("utf-8"))
|
|
123
137
|
response = http_method(path, content=body, headers=headers)
|
|
@@ -152,8 +166,12 @@ class HttpRequests:
|
|
|
152
166
|
body: Any | None = None,
|
|
153
167
|
content_type: str = "application/json",
|
|
154
168
|
compress: bool = False,
|
|
169
|
+
*,
|
|
170
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
155
171
|
) -> Response:
|
|
156
|
-
return self._send_request(
|
|
172
|
+
return self._send_request(
|
|
173
|
+
self.http_client.post, path, body, content_type, compress, serializer=serializer
|
|
174
|
+
)
|
|
157
175
|
|
|
158
176
|
def put(
|
|
159
177
|
self,
|
|
@@ -161,8 +179,12 @@ class HttpRequests:
|
|
|
161
179
|
body: Any | None = None,
|
|
162
180
|
content_type: str = "application/json",
|
|
163
181
|
compress: bool = False,
|
|
182
|
+
*,
|
|
183
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
164
184
|
) -> Response:
|
|
165
|
-
return self._send_request(
|
|
185
|
+
return self._send_request(
|
|
186
|
+
self.http_client.put, path, body, content_type, compress, serializer=serializer
|
|
187
|
+
)
|
|
166
188
|
|
|
167
189
|
def delete(self, path: str, body: dict | None = None) -> Response:
|
|
168
190
|
return self._send_request(self.http_client.delete, path, body)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = "2.10.0"
|
{meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/index.py
RENAMED
|
@@ -1300,6 +1300,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
1300
1300
|
primary_key: str | None = None,
|
|
1301
1301
|
*,
|
|
1302
1302
|
compress: bool = False,
|
|
1303
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
1303
1304
|
) -> TaskInfo:
|
|
1304
1305
|
"""Add documents to the index.
|
|
1305
1306
|
|
|
@@ -1309,6 +1310,8 @@ class AsyncIndex(_BaseIndex):
|
|
|
1309
1310
|
primary_key: The primary key of the documents. This will be ignored if already set.
|
|
1310
1311
|
Defaults to None.
|
|
1311
1312
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
1313
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
1314
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
1312
1315
|
|
|
1313
1316
|
Returns:
|
|
1314
1317
|
|
|
@@ -1366,7 +1369,11 @@ class AsyncIndex(_BaseIndex):
|
|
|
1366
1369
|
)
|
|
1367
1370
|
)
|
|
1368
1371
|
|
|
1369
|
-
tasks.append(
|
|
1372
|
+
tasks.append(
|
|
1373
|
+
self._http_requests.post(
|
|
1374
|
+
url, documents, compress=compress, serializer=serializer
|
|
1375
|
+
)
|
|
1376
|
+
)
|
|
1370
1377
|
|
|
1371
1378
|
responses = await asyncio.gather(*tasks)
|
|
1372
1379
|
result = TaskInfo(**responses[-1].json())
|
|
@@ -1402,7 +1409,9 @@ class AsyncIndex(_BaseIndex):
|
|
|
1402
1409
|
)
|
|
1403
1410
|
|
|
1404
1411
|
response_coroutine = tg.create_task(
|
|
1405
|
-
self._http_requests.post(
|
|
1412
|
+
self._http_requests.post(
|
|
1413
|
+
url, documents, compress=compress, serializer=serializer
|
|
1414
|
+
)
|
|
1406
1415
|
)
|
|
1407
1416
|
|
|
1408
1417
|
response = await response_coroutine
|
|
@@ -1420,7 +1429,9 @@ class AsyncIndex(_BaseIndex):
|
|
|
1420
1429
|
|
|
1421
1430
|
return result
|
|
1422
1431
|
|
|
1423
|
-
response = await self._http_requests.post(
|
|
1432
|
+
response = await self._http_requests.post(
|
|
1433
|
+
url, documents, compress=compress, serializer=serializer
|
|
1434
|
+
)
|
|
1424
1435
|
|
|
1425
1436
|
result = TaskInfo(**response.json())
|
|
1426
1437
|
if self._post_add_documents_plugins:
|
|
@@ -1443,6 +1454,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
1443
1454
|
batch_size: int = 1000,
|
|
1444
1455
|
primary_key: str | None = None,
|
|
1445
1456
|
compress: bool = False,
|
|
1457
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
1446
1458
|
) -> list[TaskInfo]:
|
|
1447
1459
|
"""Adds documents in batches to reduce RAM usage with indexing.
|
|
1448
1460
|
|
|
@@ -1454,6 +1466,8 @@ class AsyncIndex(_BaseIndex):
|
|
|
1454
1466
|
primary_key: The primary key of the documents. This will be ignored if already set.
|
|
1455
1467
|
Defaults to None.
|
|
1456
1468
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
1469
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
1470
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
1457
1471
|
|
|
1458
1472
|
Returns:
|
|
1459
1473
|
|
|
@@ -1477,14 +1491,16 @@ class AsyncIndex(_BaseIndex):
|
|
|
1477
1491
|
"""
|
|
1478
1492
|
if not use_task_groups():
|
|
1479
1493
|
batches = [
|
|
1480
|
-
self.add_documents(x, primary_key, compress=compress)
|
|
1494
|
+
self.add_documents(x, primary_key, compress=compress, serializer=serializer)
|
|
1481
1495
|
for x in _batch(documents, batch_size)
|
|
1482
1496
|
]
|
|
1483
1497
|
return await asyncio.gather(*batches)
|
|
1484
1498
|
|
|
1485
1499
|
async with asyncio.TaskGroup() as tg: # type: ignore[attr-defined]
|
|
1486
1500
|
tasks = [
|
|
1487
|
-
tg.create_task(
|
|
1501
|
+
tg.create_task(
|
|
1502
|
+
self.add_documents(x, primary_key, compress=compress, serializer=serializer)
|
|
1503
|
+
)
|
|
1488
1504
|
for x in _batch(documents, batch_size)
|
|
1489
1505
|
]
|
|
1490
1506
|
|
|
@@ -1499,6 +1515,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
1499
1515
|
csv_delimiter: str | None = None,
|
|
1500
1516
|
combine_documents: bool = True,
|
|
1501
1517
|
compress: bool = False,
|
|
1518
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
1502
1519
|
) -> list[TaskInfo]:
|
|
1503
1520
|
"""Load all json files from a directory and add the documents to the index.
|
|
1504
1521
|
|
|
@@ -1515,6 +1532,8 @@ class AsyncIndex(_BaseIndex):
|
|
|
1515
1532
|
combine_documents: If set to True this will combine the documents from all the files
|
|
1516
1533
|
before indexing them. Defaults to True.
|
|
1517
1534
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
1535
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
1536
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
1518
1537
|
|
|
1519
1538
|
Returns:
|
|
1520
1539
|
|
|
@@ -1550,7 +1569,9 @@ class AsyncIndex(_BaseIndex):
|
|
|
1550
1569
|
loop = asyncio.get_running_loop()
|
|
1551
1570
|
combined = await loop.run_in_executor(None, partial(_combine_documents, all_documents))
|
|
1552
1571
|
|
|
1553
|
-
response = await self.add_documents(
|
|
1572
|
+
response = await self.add_documents(
|
|
1573
|
+
combined, primary_key, compress=compress, serializer=serializer
|
|
1574
|
+
)
|
|
1554
1575
|
|
|
1555
1576
|
return [response]
|
|
1556
1577
|
|
|
@@ -1560,7 +1581,9 @@ class AsyncIndex(_BaseIndex):
|
|
|
1560
1581
|
if path.suffix == f".{document_type}":
|
|
1561
1582
|
documents = await _async_load_documents_from_file(path, csv_delimiter)
|
|
1562
1583
|
add_documents.append(
|
|
1563
|
-
self.add_documents(
|
|
1584
|
+
self.add_documents(
|
|
1585
|
+
documents, primary_key, compress=compress, serializer=serializer
|
|
1586
|
+
)
|
|
1564
1587
|
)
|
|
1565
1588
|
|
|
1566
1589
|
_raise_on_no_documents(add_documents, document_type, directory_path)
|
|
@@ -1584,11 +1607,17 @@ class AsyncIndex(_BaseIndex):
|
|
|
1584
1607
|
if path.suffix == f".{document_type}":
|
|
1585
1608
|
documents = await _async_load_documents_from_file(path, csv_delimiter)
|
|
1586
1609
|
if i == 0:
|
|
1587
|
-
all_results = [
|
|
1610
|
+
all_results = [
|
|
1611
|
+
await self.add_documents(
|
|
1612
|
+
documents, compress=compress, serializer=serializer
|
|
1613
|
+
)
|
|
1614
|
+
]
|
|
1588
1615
|
else:
|
|
1589
1616
|
tasks.append(
|
|
1590
1617
|
tg.create_task(
|
|
1591
|
-
self.add_documents(
|
|
1618
|
+
self.add_documents(
|
|
1619
|
+
documents, primary_key, compress=compress, serializer=serializer
|
|
1620
|
+
)
|
|
1592
1621
|
)
|
|
1593
1622
|
)
|
|
1594
1623
|
|
|
@@ -1607,6 +1636,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
1607
1636
|
csv_delimiter: str | None = None,
|
|
1608
1637
|
combine_documents: bool = True,
|
|
1609
1638
|
compress: bool = False,
|
|
1639
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
1610
1640
|
) -> list[TaskInfo]:
|
|
1611
1641
|
"""Load all json files from a directory and add the documents to the index in batches.
|
|
1612
1642
|
|
|
@@ -1625,6 +1655,8 @@ class AsyncIndex(_BaseIndex):
|
|
|
1625
1655
|
combine_documents: If set to True this will combine the documents from all the files
|
|
1626
1656
|
before indexing them. Defaults to True.
|
|
1627
1657
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
1658
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
1659
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
1628
1660
|
|
|
1629
1661
|
Returns:
|
|
1630
1662
|
|
|
@@ -1663,7 +1695,11 @@ class AsyncIndex(_BaseIndex):
|
|
|
1663
1695
|
combined = await loop.run_in_executor(None, partial(_combine_documents, all_documents))
|
|
1664
1696
|
|
|
1665
1697
|
return await self.add_documents_in_batches(
|
|
1666
|
-
combined,
|
|
1698
|
+
combined,
|
|
1699
|
+
batch_size=batch_size,
|
|
1700
|
+
primary_key=primary_key,
|
|
1701
|
+
compress=compress,
|
|
1702
|
+
serializer=serializer,
|
|
1667
1703
|
)
|
|
1668
1704
|
|
|
1669
1705
|
responses: list[TaskInfo] = []
|
|
@@ -1674,7 +1710,11 @@ class AsyncIndex(_BaseIndex):
|
|
|
1674
1710
|
documents = await _async_load_documents_from_file(path, csv_delimiter)
|
|
1675
1711
|
add_documents.append(
|
|
1676
1712
|
self.add_documents_in_batches(
|
|
1677
|
-
documents,
|
|
1713
|
+
documents,
|
|
1714
|
+
batch_size=batch_size,
|
|
1715
|
+
primary_key=primary_key,
|
|
1716
|
+
compress=compress,
|
|
1717
|
+
serializer=serializer,
|
|
1678
1718
|
)
|
|
1679
1719
|
)
|
|
1680
1720
|
|
|
@@ -1692,7 +1732,12 @@ class AsyncIndex(_BaseIndex):
|
|
|
1692
1732
|
return responses
|
|
1693
1733
|
|
|
1694
1734
|
async def add_documents_from_file(
|
|
1695
|
-
self,
|
|
1735
|
+
self,
|
|
1736
|
+
file_path: Path | str,
|
|
1737
|
+
primary_key: str | None = None,
|
|
1738
|
+
*,
|
|
1739
|
+
compress: bool = False,
|
|
1740
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
1696
1741
|
) -> TaskInfo:
|
|
1697
1742
|
"""Add documents to the index from a json file.
|
|
1698
1743
|
|
|
@@ -1702,6 +1747,8 @@ class AsyncIndex(_BaseIndex):
|
|
|
1702
1747
|
primary_key: The primary key of the documents. This will be ignored if already set.
|
|
1703
1748
|
Defaults to None.
|
|
1704
1749
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
1750
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
1751
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
1705
1752
|
|
|
1706
1753
|
Returns:
|
|
1707
1754
|
|
|
@@ -1725,7 +1772,9 @@ class AsyncIndex(_BaseIndex):
|
|
|
1725
1772
|
"""
|
|
1726
1773
|
documents = await _async_load_documents_from_file(file_path)
|
|
1727
1774
|
|
|
1728
|
-
return await self.add_documents(
|
|
1775
|
+
return await self.add_documents(
|
|
1776
|
+
documents, primary_key=primary_key, compress=compress, serializer=serializer
|
|
1777
|
+
)
|
|
1729
1778
|
|
|
1730
1779
|
async def add_documents_from_file_in_batches(
|
|
1731
1780
|
self,
|
|
@@ -1735,6 +1784,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
1735
1784
|
primary_key: str | None = None,
|
|
1736
1785
|
csv_delimiter: str | None = None,
|
|
1737
1786
|
compress: bool = False,
|
|
1787
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
1738
1788
|
) -> list[TaskInfo]:
|
|
1739
1789
|
"""Adds documents form a json file in batches to reduce RAM usage with indexing.
|
|
1740
1790
|
|
|
@@ -1748,6 +1798,8 @@ class AsyncIndex(_BaseIndex):
|
|
|
1748
1798
|
csv_delimiter: A single ASCII character to specify the delimiter for csv files. This
|
|
1749
1799
|
can only be used if the file is a csv file. Defaults to comma.
|
|
1750
1800
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
1801
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
1802
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
1751
1803
|
|
|
1752
1804
|
Returns:
|
|
1753
1805
|
|
|
@@ -1772,7 +1824,11 @@ class AsyncIndex(_BaseIndex):
|
|
|
1772
1824
|
documents = await _async_load_documents_from_file(file_path, csv_delimiter)
|
|
1773
1825
|
|
|
1774
1826
|
return await self.add_documents_in_batches(
|
|
1775
|
-
documents,
|
|
1827
|
+
documents,
|
|
1828
|
+
batch_size=batch_size,
|
|
1829
|
+
primary_key=primary_key,
|
|
1830
|
+
compress=compress,
|
|
1831
|
+
serializer=serializer,
|
|
1776
1832
|
)
|
|
1777
1833
|
|
|
1778
1834
|
async def add_documents_from_raw_file(
|
|
@@ -1782,6 +1838,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
1782
1838
|
*,
|
|
1783
1839
|
csv_delimiter: str | None = None,
|
|
1784
1840
|
compress: bool = False,
|
|
1841
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
1785
1842
|
) -> TaskInfo:
|
|
1786
1843
|
"""Directly send csv or ndjson files to Meilisearch without pre-processing.
|
|
1787
1844
|
|
|
@@ -1797,6 +1854,8 @@ class AsyncIndex(_BaseIndex):
|
|
|
1797
1854
|
csv_delimiter: A single ASCII character to specify the delimiter for csv files. This
|
|
1798
1855
|
can only be used if the file is a csv file. Defaults to comma.
|
|
1799
1856
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
1857
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
1858
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
1800
1859
|
|
|
1801
1860
|
Returns:
|
|
1802
1861
|
|
|
@@ -1854,7 +1913,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
1854
1913
|
data = await f.read()
|
|
1855
1914
|
|
|
1856
1915
|
response = await self._http_requests.post(
|
|
1857
|
-
url, body=data, content_type=content_type, compress=compress
|
|
1916
|
+
url, body=data, content_type=content_type, compress=compress, serializer=serializer
|
|
1858
1917
|
)
|
|
1859
1918
|
|
|
1860
1919
|
return TaskInfo(**response.json())
|
|
@@ -1865,6 +1924,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
1865
1924
|
primary_key: str | None = None,
|
|
1866
1925
|
*,
|
|
1867
1926
|
compress: bool = False,
|
|
1927
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
1868
1928
|
) -> TaskInfo:
|
|
1869
1929
|
"""Update documents in the index.
|
|
1870
1930
|
|
|
@@ -1874,6 +1934,8 @@ class AsyncIndex(_BaseIndex):
|
|
|
1874
1934
|
primary_key: The primary key of the documents. This will be ignored if already set.
|
|
1875
1935
|
Defaults to None.
|
|
1876
1936
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
1937
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
1938
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
1877
1939
|
|
|
1878
1940
|
Returns:
|
|
1879
1941
|
|
|
@@ -1968,7 +2030,9 @@ class AsyncIndex(_BaseIndex):
|
|
|
1968
2030
|
)
|
|
1969
2031
|
|
|
1970
2032
|
response_coroutine = tg.create_task(
|
|
1971
|
-
self._http_requests.put(
|
|
2033
|
+
self._http_requests.put(
|
|
2034
|
+
url, documents, compress=compress, serializer=serializer
|
|
2035
|
+
)
|
|
1972
2036
|
)
|
|
1973
2037
|
|
|
1974
2038
|
response = await response_coroutine
|
|
@@ -1987,7 +2051,9 @@ class AsyncIndex(_BaseIndex):
|
|
|
1987
2051
|
|
|
1988
2052
|
return result
|
|
1989
2053
|
|
|
1990
|
-
response = await self._http_requests.put(
|
|
2054
|
+
response = await self._http_requests.put(
|
|
2055
|
+
url, documents, compress=compress, serializer=serializer
|
|
2056
|
+
)
|
|
1991
2057
|
result = TaskInfo(**response.json())
|
|
1992
2058
|
if self._post_update_documents_plugins:
|
|
1993
2059
|
post = await AsyncIndex._run_plugins(
|
|
@@ -2009,6 +2075,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
2009
2075
|
batch_size: int = 1000,
|
|
2010
2076
|
primary_key: str | None = None,
|
|
2011
2077
|
compress: bool = False,
|
|
2078
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
2012
2079
|
) -> list[TaskInfo]:
|
|
2013
2080
|
"""Update documents in batches to reduce RAM usage with indexing.
|
|
2014
2081
|
|
|
@@ -2022,6 +2089,8 @@ class AsyncIndex(_BaseIndex):
|
|
|
2022
2089
|
primary_key: The primary key of the documents. This will be ignored if already set.
|
|
2023
2090
|
Defaults to None.
|
|
2024
2091
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
2092
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
2093
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
2025
2094
|
|
|
2026
2095
|
Returns:
|
|
2027
2096
|
|
|
@@ -2045,7 +2114,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
2045
2114
|
"""
|
|
2046
2115
|
if not use_task_groups():
|
|
2047
2116
|
batches = [
|
|
2048
|
-
self.update_documents(x, primary_key, compress=compress)
|
|
2117
|
+
self.update_documents(x, primary_key, compress=compress, serializer=serializer)
|
|
2049
2118
|
for x in _batch(documents, batch_size)
|
|
2050
2119
|
]
|
|
2051
2120
|
return await asyncio.gather(*batches)
|
|
@@ -2066,6 +2135,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
2066
2135
|
csv_delimiter: str | None = None,
|
|
2067
2136
|
combine_documents: bool = True,
|
|
2068
2137
|
compress: bool = False,
|
|
2138
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
2069
2139
|
) -> list[TaskInfo]:
|
|
2070
2140
|
"""Load all json files from a directory and update the documents.
|
|
2071
2141
|
|
|
@@ -2082,6 +2152,8 @@ class AsyncIndex(_BaseIndex):
|
|
|
2082
2152
|
combine_documents: If set to True this will combine the documents from all the files
|
|
2083
2153
|
before indexing them. Defaults to True.
|
|
2084
2154
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
2155
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
2156
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
2085
2157
|
|
|
2086
2158
|
Returns:
|
|
2087
2159
|
|
|
@@ -2117,7 +2189,9 @@ class AsyncIndex(_BaseIndex):
|
|
|
2117
2189
|
loop = asyncio.get_running_loop()
|
|
2118
2190
|
combined = await loop.run_in_executor(None, partial(_combine_documents, all_documents))
|
|
2119
2191
|
|
|
2120
|
-
response = await self.update_documents(
|
|
2192
|
+
response = await self.update_documents(
|
|
2193
|
+
combined, primary_key, compress=compress, serializer=serializer
|
|
2194
|
+
)
|
|
2121
2195
|
return [response]
|
|
2122
2196
|
|
|
2123
2197
|
if not use_task_groups():
|
|
@@ -2126,7 +2200,9 @@ class AsyncIndex(_BaseIndex):
|
|
|
2126
2200
|
if path.suffix == f".{document_type}":
|
|
2127
2201
|
documents = await _async_load_documents_from_file(path, csv_delimiter)
|
|
2128
2202
|
update_documents.append(
|
|
2129
|
-
self.update_documents(
|
|
2203
|
+
self.update_documents(
|
|
2204
|
+
documents, primary_key, compress=compress, serializer=serializer
|
|
2205
|
+
)
|
|
2130
2206
|
)
|
|
2131
2207
|
|
|
2132
2208
|
_raise_on_no_documents(update_documents, document_type, directory_path)
|
|
@@ -2150,12 +2226,16 @@ class AsyncIndex(_BaseIndex):
|
|
|
2150
2226
|
documents = await _async_load_documents_from_file(path, csv_delimiter)
|
|
2151
2227
|
if i == 0:
|
|
2152
2228
|
results = [
|
|
2153
|
-
await self.update_documents(
|
|
2229
|
+
await self.update_documents(
|
|
2230
|
+
documents, primary_key, compress=compress, serializer=serializer
|
|
2231
|
+
)
|
|
2154
2232
|
]
|
|
2155
2233
|
else:
|
|
2156
2234
|
tasks.append(
|
|
2157
2235
|
tg.create_task(
|
|
2158
|
-
self.update_documents(
|
|
2236
|
+
self.update_documents(
|
|
2237
|
+
documents, primary_key, compress=compress, serializer=serializer
|
|
2238
|
+
)
|
|
2159
2239
|
)
|
|
2160
2240
|
)
|
|
2161
2241
|
|
|
@@ -2173,6 +2253,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
2173
2253
|
csv_delimiter: str | None = None,
|
|
2174
2254
|
combine_documents: bool = True,
|
|
2175
2255
|
compress: bool = False,
|
|
2256
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
2176
2257
|
) -> list[TaskInfo]:
|
|
2177
2258
|
"""Load all json files from a directory and update the documents.
|
|
2178
2259
|
|
|
@@ -2191,6 +2272,8 @@ class AsyncIndex(_BaseIndex):
|
|
|
2191
2272
|
combine_documents: If set to True this will combine the documents from all the files
|
|
2192
2273
|
before indexing them. Defaults to True.
|
|
2193
2274
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
2275
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
2276
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
2194
2277
|
|
|
2195
2278
|
Returns:
|
|
2196
2279
|
|
|
@@ -2227,7 +2310,11 @@ class AsyncIndex(_BaseIndex):
|
|
|
2227
2310
|
combined = await loop.run_in_executor(None, partial(_combine_documents, all_documents))
|
|
2228
2311
|
|
|
2229
2312
|
return await self.update_documents_in_batches(
|
|
2230
|
-
combined,
|
|
2313
|
+
combined,
|
|
2314
|
+
batch_size=batch_size,
|
|
2315
|
+
primary_key=primary_key,
|
|
2316
|
+
compress=compress,
|
|
2317
|
+
serializer=serializer,
|
|
2231
2318
|
)
|
|
2232
2319
|
|
|
2233
2320
|
if not use_task_groups():
|
|
@@ -2243,6 +2330,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
2243
2330
|
batch_size=batch_size,
|
|
2244
2331
|
primary_key=primary_key,
|
|
2245
2332
|
compress=compress,
|
|
2333
|
+
serializer=serializer,
|
|
2246
2334
|
)
|
|
2247
2335
|
)
|
|
2248
2336
|
|
|
@@ -2271,6 +2359,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
2271
2359
|
batch_size=batch_size,
|
|
2272
2360
|
primary_key=primary_key,
|
|
2273
2361
|
compress=compress,
|
|
2362
|
+
serializer=serializer,
|
|
2274
2363
|
)
|
|
2275
2364
|
else:
|
|
2276
2365
|
tasks.append(
|
|
@@ -2280,6 +2369,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
2280
2369
|
batch_size=batch_size,
|
|
2281
2370
|
primary_key=primary_key,
|
|
2282
2371
|
compress=compress,
|
|
2372
|
+
serializer=serializer,
|
|
2283
2373
|
)
|
|
2284
2374
|
)
|
|
2285
2375
|
)
|
|
@@ -2295,6 +2385,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
2295
2385
|
csv_delimiter: str | None = None,
|
|
2296
2386
|
*,
|
|
2297
2387
|
compress: bool = False,
|
|
2388
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
2298
2389
|
) -> TaskInfo:
|
|
2299
2390
|
"""Add documents in the index from a json file.
|
|
2300
2391
|
|
|
@@ -2306,6 +2397,8 @@ class AsyncIndex(_BaseIndex):
|
|
|
2306
2397
|
csv_delimiter: A single ASCII character to specify the delimiter for csv files. This
|
|
2307
2398
|
can only be used if the file is a csv file. Defaults to comma.
|
|
2308
2399
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
2400
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
2401
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
2309
2402
|
|
|
2310
2403
|
Returns:
|
|
2311
2404
|
|
|
@@ -2327,7 +2420,9 @@ class AsyncIndex(_BaseIndex):
|
|
|
2327
2420
|
"""
|
|
2328
2421
|
documents = await _async_load_documents_from_file(file_path, csv_delimiter)
|
|
2329
2422
|
|
|
2330
|
-
return await self.update_documents(
|
|
2423
|
+
return await self.update_documents(
|
|
2424
|
+
documents, primary_key=primary_key, compress=compress, serializer=serializer
|
|
2425
|
+
)
|
|
2331
2426
|
|
|
2332
2427
|
async def update_documents_from_file_in_batches(
|
|
2333
2428
|
self,
|
|
@@ -2336,6 +2431,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
2336
2431
|
batch_size: int = 1000,
|
|
2337
2432
|
primary_key: str | None = None,
|
|
2338
2433
|
compress: bool = False,
|
|
2434
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
2339
2435
|
) -> list[TaskInfo]:
|
|
2340
2436
|
"""Updates documents form a json file in batches to reduce RAM usage with indexing.
|
|
2341
2437
|
|
|
@@ -2347,6 +2443,8 @@ class AsyncIndex(_BaseIndex):
|
|
|
2347
2443
|
primary_key: The primary key of the documents. This will be ignored if already set.
|
|
2348
2444
|
Defaults to None.
|
|
2349
2445
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
2446
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
2447
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
2350
2448
|
|
|
2351
2449
|
Returns:
|
|
2352
2450
|
|
|
@@ -2369,7 +2467,11 @@ class AsyncIndex(_BaseIndex):
|
|
|
2369
2467
|
documents = await _async_load_documents_from_file(file_path)
|
|
2370
2468
|
|
|
2371
2469
|
return await self.update_documents_in_batches(
|
|
2372
|
-
documents,
|
|
2470
|
+
documents,
|
|
2471
|
+
batch_size=batch_size,
|
|
2472
|
+
primary_key=primary_key,
|
|
2473
|
+
compress=compress,
|
|
2474
|
+
serializer=serializer,
|
|
2373
2475
|
)
|
|
2374
2476
|
|
|
2375
2477
|
async def update_documents_from_raw_file(
|
|
@@ -2379,6 +2481,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
2379
2481
|
csv_delimiter: str | None = None,
|
|
2380
2482
|
*,
|
|
2381
2483
|
compress: bool = False,
|
|
2484
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
2382
2485
|
) -> TaskInfo:
|
|
2383
2486
|
"""Directly send csv or ndjson files to Meilisearch without pre-processing.
|
|
2384
2487
|
|
|
@@ -2394,6 +2497,8 @@ class AsyncIndex(_BaseIndex):
|
|
|
2394
2497
|
csv_delimiter: A single ASCII character to specify the delimiter for csv files. This
|
|
2395
2498
|
can only be used if the file is a csv file. Defaults to comma.
|
|
2396
2499
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
2500
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
2501
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
2397
2502
|
|
|
2398
2503
|
Returns:
|
|
2399
2504
|
|
|
@@ -2451,7 +2556,7 @@ class AsyncIndex(_BaseIndex):
|
|
|
2451
2556
|
data = await f.read()
|
|
2452
2557
|
|
|
2453
2558
|
response = await self._http_requests.put(
|
|
2454
|
-
url, body=data, content_type=content_type, compress=compress
|
|
2559
|
+
url, body=data, content_type=content_type, compress=compress, serializer=serializer
|
|
2455
2560
|
)
|
|
2456
2561
|
|
|
2457
2562
|
return TaskInfo(**response.json())
|
|
@@ -5289,6 +5394,7 @@ class Index(_BaseIndex):
|
|
|
5289
5394
|
primary_key: str | None = None,
|
|
5290
5395
|
*,
|
|
5291
5396
|
compress: bool = False,
|
|
5397
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
5292
5398
|
) -> TaskInfo:
|
|
5293
5399
|
"""Add documents to the index.
|
|
5294
5400
|
|
|
@@ -5298,6 +5404,8 @@ class Index(_BaseIndex):
|
|
|
5298
5404
|
primary_key: The primary key of the documents. This will be ignored if already set.
|
|
5299
5405
|
Defaults to None.
|
|
5300
5406
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
5407
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
5408
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
5301
5409
|
|
|
5302
5410
|
Returns:
|
|
5303
5411
|
|
|
@@ -5334,7 +5442,9 @@ class Index(_BaseIndex):
|
|
|
5334
5442
|
if pre.get("document_result"):
|
|
5335
5443
|
documents = pre["document_result"]
|
|
5336
5444
|
|
|
5337
|
-
response = self._http_requests.post(
|
|
5445
|
+
response = self._http_requests.post(
|
|
5446
|
+
url, documents, compress=compress, serializer=serializer
|
|
5447
|
+
)
|
|
5338
5448
|
result = TaskInfo(**response.json())
|
|
5339
5449
|
if self._post_add_documents_plugins:
|
|
5340
5450
|
post = Index._run_plugins(self._post_add_documents_plugins, Event.POST, result=result)
|
|
@@ -5350,6 +5460,7 @@ class Index(_BaseIndex):
|
|
|
5350
5460
|
batch_size: int = 1000,
|
|
5351
5461
|
primary_key: str | None = None,
|
|
5352
5462
|
compress: bool = False,
|
|
5463
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
5353
5464
|
) -> list[TaskInfo]:
|
|
5354
5465
|
"""Adds documents in batches to reduce RAM usage with indexing.
|
|
5355
5466
|
|
|
@@ -5361,6 +5472,8 @@ class Index(_BaseIndex):
|
|
|
5361
5472
|
primary_key: The primary key of the documents. This will be ignored if already set.
|
|
5362
5473
|
Defaults to None.
|
|
5363
5474
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
5475
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
5476
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
5364
5477
|
|
|
5365
5478
|
Returns:
|
|
5366
5479
|
|
|
@@ -5383,7 +5496,7 @@ class Index(_BaseIndex):
|
|
|
5383
5496
|
>>> index.add_documents_in_batches(documents)
|
|
5384
5497
|
"""
|
|
5385
5498
|
return [
|
|
5386
|
-
self.add_documents(x, primary_key, compress=compress)
|
|
5499
|
+
self.add_documents(x, primary_key, compress=compress, serializer=serializer)
|
|
5387
5500
|
for x in _batch(documents, batch_size)
|
|
5388
5501
|
]
|
|
5389
5502
|
|
|
@@ -5396,6 +5509,7 @@ class Index(_BaseIndex):
|
|
|
5396
5509
|
csv_delimiter: str | None = None,
|
|
5397
5510
|
combine_documents: bool = True,
|
|
5398
5511
|
compress: bool = False,
|
|
5512
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
5399
5513
|
) -> list[TaskInfo]:
|
|
5400
5514
|
"""Load all json files from a directory and add the documents to the index.
|
|
5401
5515
|
|
|
@@ -5412,6 +5526,8 @@ class Index(_BaseIndex):
|
|
|
5412
5526
|
combine_documents: If set to True this will combine the documents from all the files
|
|
5413
5527
|
before indexing them. Defaults to True.
|
|
5414
5528
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
5529
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
5530
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
5415
5531
|
|
|
5416
5532
|
Returns:
|
|
5417
5533
|
|
|
@@ -5446,7 +5562,9 @@ class Index(_BaseIndex):
|
|
|
5446
5562
|
|
|
5447
5563
|
combined = _combine_documents(all_documents)
|
|
5448
5564
|
|
|
5449
|
-
response = self.add_documents(
|
|
5565
|
+
response = self.add_documents(
|
|
5566
|
+
combined, primary_key, compress=compress, serializer=serializer
|
|
5567
|
+
)
|
|
5450
5568
|
|
|
5451
5569
|
return [response]
|
|
5452
5570
|
|
|
@@ -5454,7 +5572,11 @@ class Index(_BaseIndex):
|
|
|
5454
5572
|
for path in directory.iterdir():
|
|
5455
5573
|
if path.suffix == f".{document_type}":
|
|
5456
5574
|
documents = _load_documents_from_file(path, csv_delimiter)
|
|
5457
|
-
responses.append(
|
|
5575
|
+
responses.append(
|
|
5576
|
+
self.add_documents(
|
|
5577
|
+
documents, primary_key, compress=compress, serializer=serializer
|
|
5578
|
+
)
|
|
5579
|
+
)
|
|
5458
5580
|
|
|
5459
5581
|
_raise_on_no_documents(responses, document_type, directory_path)
|
|
5460
5582
|
|
|
@@ -5470,6 +5592,7 @@ class Index(_BaseIndex):
|
|
|
5470
5592
|
csv_delimiter: str | None = None,
|
|
5471
5593
|
combine_documents: bool = True,
|
|
5472
5594
|
compress: bool = False,
|
|
5595
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
5473
5596
|
) -> list[TaskInfo]:
|
|
5474
5597
|
"""Load all json files from a directory and add the documents to the index in batches.
|
|
5475
5598
|
|
|
@@ -5488,6 +5611,8 @@ class Index(_BaseIndex):
|
|
|
5488
5611
|
combine_documents: If set to True this will combine the documents from all the files
|
|
5489
5612
|
before indexing them. Defaults to True.
|
|
5490
5613
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
5614
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
5615
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
5491
5616
|
|
|
5492
5617
|
Returns:
|
|
5493
5618
|
|
|
@@ -5523,7 +5648,11 @@ class Index(_BaseIndex):
|
|
|
5523
5648
|
combined = _combine_documents(all_documents)
|
|
5524
5649
|
|
|
5525
5650
|
return self.add_documents_in_batches(
|
|
5526
|
-
combined,
|
|
5651
|
+
combined,
|
|
5652
|
+
batch_size=batch_size,
|
|
5653
|
+
primary_key=primary_key,
|
|
5654
|
+
compress=compress,
|
|
5655
|
+
serializer=serializer,
|
|
5527
5656
|
)
|
|
5528
5657
|
|
|
5529
5658
|
responses: list[TaskInfo] = []
|
|
@@ -5532,7 +5661,11 @@ class Index(_BaseIndex):
|
|
|
5532
5661
|
documents = _load_documents_from_file(path, csv_delimiter)
|
|
5533
5662
|
responses.extend(
|
|
5534
5663
|
self.add_documents_in_batches(
|
|
5535
|
-
documents,
|
|
5664
|
+
documents,
|
|
5665
|
+
batch_size=batch_size,
|
|
5666
|
+
primary_key=primary_key,
|
|
5667
|
+
compress=compress,
|
|
5668
|
+
serializer=serializer,
|
|
5536
5669
|
)
|
|
5537
5670
|
)
|
|
5538
5671
|
|
|
@@ -5541,7 +5674,12 @@ class Index(_BaseIndex):
|
|
|
5541
5674
|
return responses
|
|
5542
5675
|
|
|
5543
5676
|
def add_documents_from_file(
|
|
5544
|
-
self,
|
|
5677
|
+
self,
|
|
5678
|
+
file_path: Path | str,
|
|
5679
|
+
primary_key: str | None = None,
|
|
5680
|
+
*,
|
|
5681
|
+
compress: bool = False,
|
|
5682
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
5545
5683
|
) -> TaskInfo:
|
|
5546
5684
|
"""Add documents to the index from a json file.
|
|
5547
5685
|
|
|
@@ -5551,6 +5689,8 @@ class Index(_BaseIndex):
|
|
|
5551
5689
|
primary_key: The primary key of the documents. This will be ignored if already set.
|
|
5552
5690
|
Defaults to None.
|
|
5553
5691
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
5692
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
5693
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
5554
5694
|
|
|
5555
5695
|
Returns:
|
|
5556
5696
|
|
|
@@ -5574,7 +5714,9 @@ class Index(_BaseIndex):
|
|
|
5574
5714
|
"""
|
|
5575
5715
|
documents = _load_documents_from_file(file_path)
|
|
5576
5716
|
|
|
5577
|
-
return self.add_documents(
|
|
5717
|
+
return self.add_documents(
|
|
5718
|
+
documents, primary_key=primary_key, compress=compress, serializer=serializer
|
|
5719
|
+
)
|
|
5578
5720
|
|
|
5579
5721
|
def add_documents_from_file_in_batches(
|
|
5580
5722
|
self,
|
|
@@ -5584,6 +5726,7 @@ class Index(_BaseIndex):
|
|
|
5584
5726
|
primary_key: str | None = None,
|
|
5585
5727
|
csv_delimiter: str | None = None,
|
|
5586
5728
|
compress: bool = False,
|
|
5729
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
5587
5730
|
) -> list[TaskInfo]:
|
|
5588
5731
|
"""Adds documents form a json file in batches to reduce RAM usage with indexing.
|
|
5589
5732
|
|
|
@@ -5597,6 +5740,8 @@ class Index(_BaseIndex):
|
|
|
5597
5740
|
csv_delimiter: A single ASCII character to specify the delimiter for csv files. This
|
|
5598
5741
|
can only be used if the file is a csv file. Defaults to comma.
|
|
5599
5742
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
5743
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
5744
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
5600
5745
|
|
|
5601
5746
|
Returns:
|
|
5602
5747
|
|
|
@@ -5621,7 +5766,11 @@ class Index(_BaseIndex):
|
|
|
5621
5766
|
documents = _load_documents_from_file(file_path, csv_delimiter)
|
|
5622
5767
|
|
|
5623
5768
|
return self.add_documents_in_batches(
|
|
5624
|
-
documents,
|
|
5769
|
+
documents,
|
|
5770
|
+
batch_size=batch_size,
|
|
5771
|
+
primary_key=primary_key,
|
|
5772
|
+
compress=compress,
|
|
5773
|
+
serializer=serializer,
|
|
5625
5774
|
)
|
|
5626
5775
|
|
|
5627
5776
|
def add_documents_from_raw_file(
|
|
@@ -5631,6 +5780,7 @@ class Index(_BaseIndex):
|
|
|
5631
5780
|
*,
|
|
5632
5781
|
csv_delimiter: str | None = None,
|
|
5633
5782
|
compress: bool = False,
|
|
5783
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
5634
5784
|
) -> TaskInfo:
|
|
5635
5785
|
"""Directly send csv or ndjson files to Meilisearch without pre-processing.
|
|
5636
5786
|
|
|
@@ -5646,6 +5796,8 @@ class Index(_BaseIndex):
|
|
|
5646
5796
|
csv_delimiter: A single ASCII character to specify the delimiter for csv files. This
|
|
5647
5797
|
can only be used if the file is a csv file. Defaults to comma.
|
|
5648
5798
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
5799
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
5800
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
5649
5801
|
|
|
5650
5802
|
Returns:
|
|
5651
5803
|
|
|
@@ -5703,7 +5855,7 @@ class Index(_BaseIndex):
|
|
|
5703
5855
|
data = f.read()
|
|
5704
5856
|
|
|
5705
5857
|
response = self._http_requests.post(
|
|
5706
|
-
url, body=data, content_type=content_type, compress=compress
|
|
5858
|
+
url, body=data, content_type=content_type, compress=compress, serializer=serializer
|
|
5707
5859
|
)
|
|
5708
5860
|
|
|
5709
5861
|
return TaskInfo(**response.json())
|
|
@@ -5714,6 +5866,7 @@ class Index(_BaseIndex):
|
|
|
5714
5866
|
primary_key: str | None = None,
|
|
5715
5867
|
*,
|
|
5716
5868
|
compress: bool = False,
|
|
5869
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
5717
5870
|
) -> TaskInfo:
|
|
5718
5871
|
"""Update documents in the index.
|
|
5719
5872
|
|
|
@@ -5723,6 +5876,8 @@ class Index(_BaseIndex):
|
|
|
5723
5876
|
primary_key: The primary key of the documents. This will be ignored if already set.
|
|
5724
5877
|
Defaults to None.
|
|
5725
5878
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
5879
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
5880
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
5726
5881
|
|
|
5727
5882
|
Returns:
|
|
5728
5883
|
|
|
@@ -5759,7 +5914,7 @@ class Index(_BaseIndex):
|
|
|
5759
5914
|
if pre.get("document_result"):
|
|
5760
5915
|
documents = pre["document_result"]
|
|
5761
5916
|
|
|
5762
|
-
response = self._http_requests.put(url, documents, compress=compress)
|
|
5917
|
+
response = self._http_requests.put(url, documents, compress=compress, serializer=serializer)
|
|
5763
5918
|
result = TaskInfo(**response.json())
|
|
5764
5919
|
if self._post_update_documents_plugins:
|
|
5765
5920
|
post = Index._run_plugins(
|
|
@@ -5777,6 +5932,7 @@ class Index(_BaseIndex):
|
|
|
5777
5932
|
batch_size: int = 1000,
|
|
5778
5933
|
primary_key: str | None = None,
|
|
5779
5934
|
compress: bool = False,
|
|
5935
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
5780
5936
|
) -> list[TaskInfo]:
|
|
5781
5937
|
"""Update documents in batches to reduce RAM usage with indexing.
|
|
5782
5938
|
|
|
@@ -5790,6 +5946,8 @@ class Index(_BaseIndex):
|
|
|
5790
5946
|
primary_key: The primary key of the documents. This will be ignored if already set.
|
|
5791
5947
|
Defaults to None.
|
|
5792
5948
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
5949
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
5950
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
5793
5951
|
|
|
5794
5952
|
Returns:
|
|
5795
5953
|
|
|
@@ -5812,7 +5970,7 @@ class Index(_BaseIndex):
|
|
|
5812
5970
|
>>> index.update_documents_in_batches(documents)
|
|
5813
5971
|
"""
|
|
5814
5972
|
return [
|
|
5815
|
-
self.update_documents(x, primary_key, compress=compress)
|
|
5973
|
+
self.update_documents(x, primary_key, compress=compress, serializer=serializer)
|
|
5816
5974
|
for x in _batch(documents, batch_size)
|
|
5817
5975
|
]
|
|
5818
5976
|
|
|
@@ -5825,6 +5983,7 @@ class Index(_BaseIndex):
|
|
|
5825
5983
|
csv_delimiter: str | None = None,
|
|
5826
5984
|
combine_documents: bool = True,
|
|
5827
5985
|
compress: bool = False,
|
|
5986
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
5828
5987
|
) -> list[TaskInfo]:
|
|
5829
5988
|
"""Load all json files from a directory and update the documents.
|
|
5830
5989
|
|
|
@@ -5841,6 +6000,8 @@ class Index(_BaseIndex):
|
|
|
5841
6000
|
combine_documents: If set to True this will combine the documents from all the files
|
|
5842
6001
|
before indexing them. Defaults to True.
|
|
5843
6002
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
6003
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
6004
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
5844
6005
|
|
|
5845
6006
|
Returns:
|
|
5846
6007
|
|
|
@@ -5875,14 +6036,20 @@ class Index(_BaseIndex):
|
|
|
5875
6036
|
|
|
5876
6037
|
combined = _combine_documents(all_documents)
|
|
5877
6038
|
|
|
5878
|
-
response = self.update_documents(
|
|
6039
|
+
response = self.update_documents(
|
|
6040
|
+
combined, primary_key, compress=compress, serializer=serializer
|
|
6041
|
+
)
|
|
5879
6042
|
return [response]
|
|
5880
6043
|
|
|
5881
6044
|
responses = []
|
|
5882
6045
|
for path in directory.iterdir():
|
|
5883
6046
|
if path.suffix == f".{document_type}":
|
|
5884
6047
|
documents = _load_documents_from_file(path, csv_delimiter)
|
|
5885
|
-
responses.append(
|
|
6048
|
+
responses.append(
|
|
6049
|
+
self.update_documents(
|
|
6050
|
+
documents, primary_key, compress=compress, serializer=serializer
|
|
6051
|
+
)
|
|
6052
|
+
)
|
|
5886
6053
|
|
|
5887
6054
|
_raise_on_no_documents(responses, document_type, directory_path)
|
|
5888
6055
|
|
|
@@ -5898,6 +6065,7 @@ class Index(_BaseIndex):
|
|
|
5898
6065
|
csv_delimiter: str | None = None,
|
|
5899
6066
|
combine_documents: bool = True,
|
|
5900
6067
|
compress: bool = False,
|
|
6068
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
5901
6069
|
) -> list[TaskInfo]:
|
|
5902
6070
|
"""Load all json files from a directory and update the documents.
|
|
5903
6071
|
|
|
@@ -5916,6 +6084,8 @@ class Index(_BaseIndex):
|
|
|
5916
6084
|
combine_documents: If set to True this will combine the documents from all the files
|
|
5917
6085
|
before indexing them. Defaults to True.
|
|
5918
6086
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
6087
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
6088
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
5919
6089
|
|
|
5920
6090
|
Returns:
|
|
5921
6091
|
|
|
@@ -5951,7 +6121,11 @@ class Index(_BaseIndex):
|
|
|
5951
6121
|
combined = _combine_documents(all_documents)
|
|
5952
6122
|
|
|
5953
6123
|
return self.update_documents_in_batches(
|
|
5954
|
-
combined,
|
|
6124
|
+
combined,
|
|
6125
|
+
batch_size=batch_size,
|
|
6126
|
+
primary_key=primary_key,
|
|
6127
|
+
compress=compress,
|
|
6128
|
+
serializer=serializer,
|
|
5955
6129
|
)
|
|
5956
6130
|
|
|
5957
6131
|
responses: list[TaskInfo] = []
|
|
@@ -5961,7 +6135,11 @@ class Index(_BaseIndex):
|
|
|
5961
6135
|
documents = _load_documents_from_file(path, csv_delimiter)
|
|
5962
6136
|
responses.extend(
|
|
5963
6137
|
self.update_documents_in_batches(
|
|
5964
|
-
documents,
|
|
6138
|
+
documents,
|
|
6139
|
+
batch_size=batch_size,
|
|
6140
|
+
primary_key=primary_key,
|
|
6141
|
+
compress=compress,
|
|
6142
|
+
serializer=serializer,
|
|
5965
6143
|
)
|
|
5966
6144
|
)
|
|
5967
6145
|
|
|
@@ -5976,6 +6154,7 @@ class Index(_BaseIndex):
|
|
|
5976
6154
|
csv_delimiter: str | None = None,
|
|
5977
6155
|
*,
|
|
5978
6156
|
compress: bool = False,
|
|
6157
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
5979
6158
|
) -> TaskInfo:
|
|
5980
6159
|
"""Add documents in the index from a json file.
|
|
5981
6160
|
|
|
@@ -5987,6 +6166,8 @@ class Index(_BaseIndex):
|
|
|
5987
6166
|
csv_delimiter: A single ASCII character to specify the delimiter for csv files. This
|
|
5988
6167
|
can only be used if the file is a csv file. Defaults to comma.
|
|
5989
6168
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
6169
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
6170
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
5990
6171
|
|
|
5991
6172
|
Returns:
|
|
5992
6173
|
|
|
@@ -6008,7 +6189,9 @@ class Index(_BaseIndex):
|
|
|
6008
6189
|
"""
|
|
6009
6190
|
documents = _load_documents_from_file(file_path, csv_delimiter)
|
|
6010
6191
|
|
|
6011
|
-
return self.update_documents(
|
|
6192
|
+
return self.update_documents(
|
|
6193
|
+
documents, primary_key=primary_key, compress=compress, serializer=serializer
|
|
6194
|
+
)
|
|
6012
6195
|
|
|
6013
6196
|
def update_documents_from_file_in_batches(
|
|
6014
6197
|
self,
|
|
@@ -6017,6 +6200,7 @@ class Index(_BaseIndex):
|
|
|
6017
6200
|
batch_size: int = 1000,
|
|
6018
6201
|
primary_key: str | None = None,
|
|
6019
6202
|
compress: bool = False,
|
|
6203
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
6020
6204
|
) -> list[TaskInfo]:
|
|
6021
6205
|
"""Updates documents form a json file in batches to reduce RAM usage with indexing.
|
|
6022
6206
|
|
|
@@ -6028,6 +6212,8 @@ class Index(_BaseIndex):
|
|
|
6028
6212
|
primary_key: The primary key of the documents. This will be ignored if already set.
|
|
6029
6213
|
Defaults to None.
|
|
6030
6214
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
6215
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
6216
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
6031
6217
|
|
|
6032
6218
|
Returns:
|
|
6033
6219
|
|
|
@@ -6050,7 +6236,11 @@ class Index(_BaseIndex):
|
|
|
6050
6236
|
documents = _load_documents_from_file(file_path)
|
|
6051
6237
|
|
|
6052
6238
|
return self.update_documents_in_batches(
|
|
6053
|
-
documents,
|
|
6239
|
+
documents,
|
|
6240
|
+
batch_size=batch_size,
|
|
6241
|
+
primary_key=primary_key,
|
|
6242
|
+
compress=compress,
|
|
6243
|
+
serializer=serializer,
|
|
6054
6244
|
)
|
|
6055
6245
|
|
|
6056
6246
|
def update_documents_from_raw_file(
|
|
@@ -6060,6 +6250,7 @@ class Index(_BaseIndex):
|
|
|
6060
6250
|
csv_delimiter: str | None = None,
|
|
6061
6251
|
*,
|
|
6062
6252
|
compress: bool = False,
|
|
6253
|
+
serializer: type[json.JSONEncoder] | None = None,
|
|
6063
6254
|
) -> TaskInfo:
|
|
6064
6255
|
"""Directly send csv or ndjson files to Meilisearch without pre-processing.
|
|
6065
6256
|
|
|
@@ -6075,6 +6266,8 @@ class Index(_BaseIndex):
|
|
|
6075
6266
|
csv_delimiter: A single ASCII character to specify the delimiter for csv files. This
|
|
6076
6267
|
can only be used if the file is a csv file. Defaults to comma.
|
|
6077
6268
|
compress: If set to True the data will be sent in gzip format. Defaults to False.
|
|
6269
|
+
serializer: A custom JSONEncode to handle serializing fields that the build in
|
|
6270
|
+
json.dumps cannot handle, for example UUID and datetime. Defaults to None.
|
|
6078
6271
|
|
|
6079
6272
|
Returns:
|
|
6080
6273
|
|
|
@@ -6132,7 +6325,7 @@ class Index(_BaseIndex):
|
|
|
6132
6325
|
data = f.read()
|
|
6133
6326
|
|
|
6134
6327
|
response = self._http_requests.put(
|
|
6135
|
-
url, body=data, content_type=content_type, compress=compress
|
|
6328
|
+
url, body=data, content_type=content_type, compress=compress, serializer=serializer
|
|
6136
6329
|
)
|
|
6137
6330
|
|
|
6138
6331
|
return TaskInfo(**response.json())
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
VERSION = "2.9.0"
|
|
File without changes
|
|
File without changes
|
{meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/__init__.py
RENAMED
|
File without changes
|
{meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/_client.py
RENAMED
|
File without changes
|
{meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/_task.py
RENAMED
|
File without changes
|
{meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/_utils.py
RENAMED
|
File without changes
|
{meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/decorators.py
RENAMED
|
File without changes
|
{meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/errors.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/models/task.py
RENAMED
|
File without changes
|
|
File without changes
|
{meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/plugins.py
RENAMED
|
File without changes
|
{meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/py.typed
RENAMED
|
File without changes
|
{meilisearch_python_sdk-2.9.0 → meilisearch_python_sdk-2.10.0}/meilisearch_python_sdk/types.py
RENAMED
|
File without changes
|