Skip to content

Commit f6c0444

Browse files
feat(clients): expose waitForTasks to batch helpers [skip-bc] (generated)
algolia/api-clients-automation#4030 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 00e515c commit f6c0444

File tree

1 file changed

+63
-5
lines changed

1 file changed

+63
-5
lines changed

algoliasearch/src/main/java/com/algolia/api/SearchClient.java

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6516,7 +6516,23 @@ public <T> List<BatchResponse> saveObjects(String indexName, Iterable<T> objects
65166516
* the transporter requestOptions. (optional)
65176517
*/
65186518
public <T> List<BatchResponse> saveObjects(String indexName, Iterable<T> objects, RequestOptions requestOptions) {
6519-
return chunkedBatch(indexName, objects, Action.ADD_OBJECT, false, 1000, requestOptions);
6519+
return saveObjects(indexName, objects, false, requestOptions);
6520+
}
6521+
6522+
/**
6523+
* Helper: Saves the given array of objects in the given index. The `chunkedBatch` helper is used
6524+
* under the hood, which creates a `batch` requests with at most 1000 objects in it.
6525+
*
6526+
* @param indexName The `indexName` to replace `objects` in.
6527+
* @param objects The array of `objects` to store in the given Algolia `indexName`.
6528+
* @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
6529+
* processed, this operation may slow the total execution time of this method but is more
6530+
* reliable.
6531+
* @param requestOptions The requestOptions to send along with the query, they will be merged with
6532+
* the transporter requestOptions. (optional)
6533+
*/
6534+
public <T> List<BatchResponse> saveObjects(String indexName, Iterable<T> objects, boolean waitForTasks, RequestOptions requestOptions) {
6535+
return chunkedBatch(indexName, objects, Action.ADD_OBJECT, waitForTasks, 1000, requestOptions);
65206536
}
65216537

65226538
/**
@@ -6527,7 +6543,7 @@ public <T> List<BatchResponse> saveObjects(String indexName, Iterable<T> objects
65276543
* @param objectIDs The array of `objectIDs` to delete from the `indexName`.
65286544
*/
65296545
public List<BatchResponse> deleteObjects(String indexName, List<String> objectIDs) {
6530-
return deleteObjects(indexName, objectIDs, null);
6546+
return deleteObjects(indexName, objectIDs, false, null);
65316547
}
65326548

65336549
/**
@@ -6540,6 +6556,22 @@ public List<BatchResponse> deleteObjects(String indexName, List<String> objectID
65406556
* the transporter requestOptions. (optional)
65416557
*/
65426558
public List<BatchResponse> deleteObjects(String indexName, List<String> objectIDs, RequestOptions requestOptions) {
6559+
return deleteObjects(indexName, objectIDs, false, null);
6560+
}
6561+
6562+
/**
6563+
* Helper: Deletes every records for the given objectIDs. The `chunkedBatch` helper is used under
6564+
* the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
6565+
*
6566+
* @param indexName The `indexName` to delete `objectIDs` from.
6567+
* @param objectIDs The array of `objectIDs` to delete from the `indexName`.
6568+
* @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
6569+
* processed, this operation may slow the total execution time of this method but is more
6570+
* reliable.
6571+
* @param requestOptions The requestOptions to send along with the query, they will be merged with
6572+
* the transporter requestOptions. (optional)
6573+
*/
6574+
public List<BatchResponse> deleteObjects(String indexName, List<String> objectIDs, boolean waitForTasks, RequestOptions requestOptions) {
65436575
List<Map<String, String>> objects = new ArrayList<>();
65446576

65456577
for (String id : objectIDs) {
@@ -6548,7 +6580,7 @@ public List<BatchResponse> deleteObjects(String indexName, List<String> objectID
65486580
objects.add(obj);
65496581
}
65506582

6551-
return chunkedBatch(indexName, objects, Action.DELETE_OBJECT, false, 1000, requestOptions);
6583+
return chunkedBatch(indexName, objects, Action.DELETE_OBJECT, waitForTasks, 1000, requestOptions);
65526584
}
65536585

65546586
/**
@@ -6562,7 +6594,29 @@ public List<BatchResponse> deleteObjects(String indexName, List<String> objectID
65626594
* will fail.
65636595
*/
65646596
public <T> List<BatchResponse> partialUpdateObjects(String indexName, Iterable<T> objects, boolean createIfNotExists) {
6565-
return partialUpdateObjects(indexName, objects, createIfNotExists, null);
6597+
return partialUpdateObjects(indexName, objects, createIfNotExists, false, null);
6598+
}
6599+
6600+
/**
6601+
* Helper: Replaces object content of all the given objects according to their respective
6602+
* `objectID` field. The `chunkedBatch` helper is used under the hood, which creates a `batch`
6603+
* requests with at most 1000 objects in it.
6604+
*
6605+
* @param indexName The `indexName` to update `objects` in.
6606+
* @param objects The array of `objects` to update in the given Algolia `indexName`.
6607+
* @param createIfNotExists To be provided if non-existing objects are passed, otherwise, the call
6608+
* will fail.
6609+
* @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
6610+
* processed, this operation may slow the total execution time of this method but is more
6611+
* reliable.
6612+
*/
6613+
public <T> List<BatchResponse> partialUpdateObjects(
6614+
String indexName,
6615+
Iterable<T> objects,
6616+
boolean createIfNotExists,
6617+
boolean waitForTasks
6618+
) {
6619+
return partialUpdateObjects(indexName, objects, createIfNotExists, waitForTasks, null);
65666620
}
65676621

65686622
/**
@@ -6574,20 +6628,24 @@ public <T> List<BatchResponse> partialUpdateObjects(String indexName, Iterable<T
65746628
* @param objects The array of `objects` to update in the given Algolia `indexName`.
65756629
* @param createIfNotExists To be provided if non-existing objects are passed, otherwise, the call
65766630
* will fail.
6631+
* @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
6632+
* processed, this operation may slow the total execution time of this method but is more
6633+
* reliable.
65776634
* @param requestOptions The requestOptions to send along with the query, they will be merged with
65786635
* the transporter requestOptions. (optional)
65796636
*/
65806637
public <T> List<BatchResponse> partialUpdateObjects(
65816638
String indexName,
65826639
Iterable<T> objects,
65836640
boolean createIfNotExists,
6641+
boolean waitForTasks,
65846642
RequestOptions requestOptions
65856643
) {
65866644
return chunkedBatch(
65876645
indexName,
65886646
objects,
65896647
createIfNotExists ? Action.PARTIAL_UPDATE_OBJECT : Action.PARTIAL_UPDATE_OBJECT_NO_CREATE,
6590-
false,
6648+
waitForTasks,
65916649
1000,
65926650
requestOptions
65936651
);

0 commit comments

Comments
 (0)