@@ -855,7 +855,9 @@ async def create_item(
855
855
item (Item): The item to be created.
856
856
base_url (str, optional): The base URL for the item. Defaults to an empty string.
857
857
exist_ok (bool, optional): Whether to allow the item to exist already. Defaults to False.
858
- refresh (bool, optional): Refresh the index after performing the operation. Defaults to False.
858
+ **kwargs: Additional keyword arguments.
859
+ - refresh (str): Whether to refresh the index after the operation. Can be "true", "false", or "wait_for".
860
+ - refresh (bool): Whether to refresh the index after the operation. Defaults to the value in `self.async_settings.database_refresh`.
859
861
860
862
Raises:
861
863
ConflictError: If the item already exists in the database.
@@ -898,10 +900,15 @@ async def delete_item(self, item_id: str, collection_id: str, **kwargs: Any):
898
900
Args:
899
901
item_id (str): The id of the Item to be deleted.
900
902
collection_id (str): The id of the Collection that the Item belongs to.
901
- refresh (bool, optional): Whether to refresh the index after the deletion. Default is False.
903
+ **kwargs: Additional keyword arguments.
904
+ - refresh (str): Whether to refresh the index after the operation. Can be "true", "false", or "wait_for".
905
+ - refresh (bool): Whether to refresh the index after the operation. Defaults to the value in `self.async_settings.database_refresh`.
902
906
903
907
Raises:
904
908
NotFoundError: If the Item does not exist in the database.
909
+
910
+ Returns:
911
+ None
905
912
"""
906
913
# Ensure kwargs is a dictionary
907
914
kwargs = kwargs or {}
@@ -951,11 +958,16 @@ async def create_collection(self, collection: Collection, **kwargs: Any):
951
958
952
959
Args:
953
960
collection (Collection): The Collection object to be created.
954
- refresh (str, optional): Whether to refresh the index after the creation. Can be "true", "false", or "wait_for".
961
+ **kwargs: Additional keyword arguments.
962
+ - refresh (str): Whether to refresh the index after the operation. Can be "true", "false", or "wait_for".
963
+ - refresh (bool): Whether to refresh the index after the operation. Defaults to the value in `self.async_settings.database_refresh`.
955
964
956
965
Raises:
957
966
ConflictError: If a Collection with the same id already exists in the database.
958
967
968
+ Returns:
969
+ None
970
+
959
971
Notes:
960
972
A new index is created for the items in the Collection using the `create_item_index` function.
961
973
"""
@@ -1020,7 +1032,11 @@ async def update_collection(
1020
1032
Args:
1021
1033
collection_id (str): The ID of the collection to be updated.
1022
1034
collection (Collection): The Collection object to be used for the update.
1023
- kwargs (Any, optional): Additional keyword arguments, including `refresh`.
1035
+ **kwargs: Additional keyword arguments.
1036
+ - refresh (str): Whether to refresh the index after the operation. Can be "true", "false", or "wait_for".
1037
+ - refresh (bool): Whether to refresh the index after the operation. Defaults to the value in `self.async_settings.database_refresh`.
1038
+ Returns:
1039
+ None
1024
1040
1025
1041
Raises:
1026
1042
NotFoundError: If the collection with the given `collection_id` is not found in the database.
@@ -1086,10 +1102,15 @@ async def delete_collection(self, collection_id: str, **kwargs: Any):
1086
1102
Parameters:
1087
1103
collection_id (str): The ID of the collection to be deleted.
1088
1104
kwargs (Any, optional): Additional keyword arguments, including `refresh`.
1105
+ - refresh (str): Whether to refresh the index after the operation. Can be "true", "false", or "wait_for".
1106
+ - refresh (bool): Whether to refresh the index after the operation. Defaults to the value in `self.async_settings.database_refresh`.
1089
1107
1090
1108
Raises:
1091
1109
NotFoundError: If the collection with the given `collection_id` is not found in the database.
1092
1110
1111
+ Returns:
1112
+ None
1113
+
1093
1114
Notes:
1094
1115
This function first verifies that the collection with the specified `collection_id` exists in the database, and then
1095
1116
deletes the collection. If `refresh` is set to "true", "false", or "wait_for", the index is refreshed accordingly after
@@ -1133,7 +1154,12 @@ async def bulk_async(
1133
1154
Args:
1134
1155
collection_id (str): The ID of the collection to which the items belong.
1135
1156
processed_items (List[Item]): A list of `Item` objects to be inserted into the database.
1136
- refresh (bool): Whether to refresh the index after the bulk insert (default: False).
1157
+ **kwargs (Any): Additional keyword arguments, including:
1158
+ - refresh (str, optional): Whether to refresh the index after the bulk insert.
1159
+ Can be "true", "false", or "wait_for". Defaults to the value of `self.sync_settings.database_refresh`.
1160
+ - refresh (bool, optional): Whether to refresh the index after the bulk insert.
1161
+ - raise_on_error (bool, optional): Whether to raise an error if any of the bulk operations fail.
1162
+ Defaults to the value of `self.async_settings.raise_on_bulk_error`.
1137
1163
1138
1164
Returns:
1139
1165
Tuple[int, List[Dict[str, Any]]]: A tuple containing:
@@ -1142,9 +1168,12 @@ async def bulk_async(
1142
1168
1143
1169
Notes:
1144
1170
This function performs a bulk insert of `processed_items` into the database using the specified `collection_id`.
1145
- The insert is performed asynchronously, and the event loop is used to run the operation in a separate executor.
1146
- The `mk_actions` function is called to generate a list of actions for the bulk insert. If `refresh` is set to True,
1147
- the index is refreshed after the bulk insert.
1171
+ The insert is performed synchronously and blocking, meaning that the function does not return until the insert has
1172
+ completed. The `mk_actions` function is called to generate a list of actions for the bulk insert. The `refresh`
1173
+ parameter determines whether the index is refreshed after the bulk insert:
1174
+ - "true": Forces an immediate refresh of the index.
1175
+ - "false": Does not refresh the index immediately (default behavior).
1176
+ - "wait_for": Waits for the next refresh cycle to make the changes visible.
1148
1177
"""
1149
1178
# Ensure kwargs is a dictionary
1150
1179
kwargs = kwargs or {}
@@ -1194,6 +1223,9 @@ def bulk_sync(
1194
1223
**kwargs (Any): Additional keyword arguments, including:
1195
1224
- refresh (str, optional): Whether to refresh the index after the bulk insert.
1196
1225
Can be "true", "false", or "wait_for". Defaults to the value of `self.sync_settings.database_refresh`.
1226
+ - refresh (bool, optional): Whether to refresh the index after the bulk insert.
1227
+ - raise_on_error (bool, optional): Whether to raise an error if any of the bulk operations fail.
1228
+ Defaults to the value of `self.async_settings.raise_on_bulk_error`.
1197
1229
1198
1230
Returns:
1199
1231
Tuple[int, List[Dict[str, Any]]]: A tuple containing:
0 commit comments