@@ -6516,7 +6516,23 @@ public <T> List<BatchResponse> saveObjects(String indexName, Iterable<T> objects
6516
6516
* the transporter requestOptions. (optional)
6517
6517
*/
6518
6518
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 );
6520
6536
}
6521
6537
6522
6538
/**
@@ -6527,7 +6543,7 @@ public <T> List<BatchResponse> saveObjects(String indexName, Iterable<T> objects
6527
6543
* @param objectIDs The array of `objectIDs` to delete from the `indexName`.
6528
6544
*/
6529
6545
public List <BatchResponse > deleteObjects (String indexName , List <String > objectIDs ) {
6530
- return deleteObjects (indexName , objectIDs , null );
6546
+ return deleteObjects (indexName , objectIDs , false , null );
6531
6547
}
6532
6548
6533
6549
/**
@@ -6540,6 +6556,22 @@ public List<BatchResponse> deleteObjects(String indexName, List<String> objectID
6540
6556
* the transporter requestOptions. (optional)
6541
6557
*/
6542
6558
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 ) {
6543
6575
List <Map <String , String >> objects = new ArrayList <>();
6544
6576
6545
6577
for (String id : objectIDs ) {
@@ -6548,7 +6580,7 @@ public List<BatchResponse> deleteObjects(String indexName, List<String> objectID
6548
6580
objects .add (obj );
6549
6581
}
6550
6582
6551
- return chunkedBatch (indexName , objects , Action .DELETE_OBJECT , false , 1000 , requestOptions );
6583
+ return chunkedBatch (indexName , objects , Action .DELETE_OBJECT , waitForTasks , 1000 , requestOptions );
6552
6584
}
6553
6585
6554
6586
/**
@@ -6562,7 +6594,29 @@ public List<BatchResponse> deleteObjects(String indexName, List<String> objectID
6562
6594
* will fail.
6563
6595
*/
6564
6596
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 );
6566
6620
}
6567
6621
6568
6622
/**
@@ -6574,20 +6628,24 @@ public <T> List<BatchResponse> partialUpdateObjects(String indexName, Iterable<T
6574
6628
* @param objects The array of `objects` to update in the given Algolia `indexName`.
6575
6629
* @param createIfNotExists To be provided if non-existing objects are passed, otherwise, the call
6576
6630
* 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.
6577
6634
* @param requestOptions The requestOptions to send along with the query, they will be merged with
6578
6635
* the transporter requestOptions. (optional)
6579
6636
*/
6580
6637
public <T > List <BatchResponse > partialUpdateObjects (
6581
6638
String indexName ,
6582
6639
Iterable <T > objects ,
6583
6640
boolean createIfNotExists ,
6641
+ boolean waitForTasks ,
6584
6642
RequestOptions requestOptions
6585
6643
) {
6586
6644
return chunkedBatch (
6587
6645
indexName ,
6588
6646
objects ,
6589
6647
createIfNotExists ? Action .PARTIAL_UPDATE_OBJECT : Action .PARTIAL_UPDATE_OBJECT_NO_CREATE ,
6590
- false ,
6648
+ waitForTasks ,
6591
6649
1000 ,
6592
6650
requestOptions
6593
6651
);
0 commit comments