@@ -6612,7 +6612,31 @@ public <T> List<BatchResponse> saveObjects(String indexName, Iterable<T> objects
6612
6612
* the transporter requestOptions. (optional)
6613
6613
*/
6614
6614
public <T > List <BatchResponse > saveObjects (String indexName , Iterable <T > objects , boolean waitForTasks , RequestOptions requestOptions ) {
6615
- return chunkedBatch (indexName , objects , Action .ADD_OBJECT , waitForTasks , 1000 , requestOptions );
6615
+ return saveObjects (indexName , objects , false , 1000 , requestOptions );
6616
+ }
6617
+
6618
+ /**
6619
+ * Helper: Saves the given array of objects in the given index. The `chunkedBatch` helper is used
6620
+ * under the hood, which creates a `batch` requests with at most 1000 objects in it.
6621
+ *
6622
+ * @param indexName The `indexName` to replace `objects` in.
6623
+ * @param objects The array of `objects` to store in the given Algolia `indexName`.
6624
+ * @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
6625
+ * processed, this operation may slow the total execution time of this method but is more
6626
+ * reliable.
6627
+ * @param batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal
6628
+ * to `length(objects) / batchSize`.
6629
+ * @param requestOptions The requestOptions to send along with the query, they will be merged with
6630
+ * the transporter requestOptions. (optional)
6631
+ */
6632
+ public <T > List <BatchResponse > saveObjects (
6633
+ String indexName ,
6634
+ Iterable <T > objects ,
6635
+ boolean waitForTasks ,
6636
+ int batchSize ,
6637
+ RequestOptions requestOptions
6638
+ ) {
6639
+ return chunkedBatch (indexName , objects , Action .ADD_OBJECT , waitForTasks , batchSize , requestOptions );
6616
6640
}
6617
6641
6618
6642
/**
@@ -6652,6 +6676,30 @@ public List<BatchResponse> deleteObjects(String indexName, List<String> objectID
6652
6676
* the transporter requestOptions. (optional)
6653
6677
*/
6654
6678
public List <BatchResponse > deleteObjects (String indexName , List <String > objectIDs , boolean waitForTasks , RequestOptions requestOptions ) {
6679
+ return deleteObjects (indexName , objectIDs , false , 1000 , null );
6680
+ }
6681
+
6682
+ /**
6683
+ * Helper: Deletes every records for the given objectIDs. The `chunkedBatch` helper is used under
6684
+ * the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
6685
+ *
6686
+ * @param indexName The `indexName` to delete `objectIDs` from.
6687
+ * @param objectIDs The array of `objectIDs` to delete from the `indexName`.
6688
+ * @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
6689
+ * processed, this operation may slow the total execution time of this method but is more
6690
+ * reliable.
6691
+ * @param batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal
6692
+ * to `length(objects) / batchSize`.
6693
+ * @param requestOptions The requestOptions to send along with the query, they will be merged with
6694
+ * the transporter requestOptions. (optional)
6695
+ */
6696
+ public List <BatchResponse > deleteObjects (
6697
+ String indexName ,
6698
+ List <String > objectIDs ,
6699
+ boolean waitForTasks ,
6700
+ int batchSize ,
6701
+ RequestOptions requestOptions
6702
+ ) {
6655
6703
List <Map <String , String >> objects = new ArrayList <>();
6656
6704
6657
6705
for (String id : objectIDs ) {
@@ -6660,7 +6708,7 @@ public List<BatchResponse> deleteObjects(String indexName, List<String> objectID
6660
6708
objects .add (obj );
6661
6709
}
6662
6710
6663
- return chunkedBatch (indexName , objects , Action .DELETE_OBJECT , waitForTasks , 1000 , requestOptions );
6711
+ return chunkedBatch (indexName , objects , Action .DELETE_OBJECT , waitForTasks , batchSize , requestOptions );
6664
6712
}
6665
6713
6666
6714
/**
@@ -6720,13 +6768,41 @@ public <T> List<BatchResponse> partialUpdateObjects(
6720
6768
boolean createIfNotExists ,
6721
6769
boolean waitForTasks ,
6722
6770
RequestOptions requestOptions
6771
+ ) {
6772
+ return partialUpdateObjects (indexName , objects , createIfNotExists , waitForTasks , 1000 , null );
6773
+ }
6774
+
6775
+ /**
6776
+ * Helper: Replaces object content of all the given objects according to their respective
6777
+ * `objectID` field. The `chunkedBatch` helper is used under the hood, which creates a `batch`
6778
+ * requests with at most 1000 objects in it.
6779
+ *
6780
+ * @param indexName The `indexName` to update `objects` in.
6781
+ * @param objects The array of `objects` to update in the given Algolia `indexName`.
6782
+ * @param createIfNotExists To be provided if non-existing objects are passed, otherwise, the call
6783
+ * will fail.
6784
+ * @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
6785
+ * processed, this operation may slow the total execution time of this method but is more
6786
+ * reliable.
6787
+ * @param batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal
6788
+ * to `length(objects) / batchSize`.
6789
+ * @param requestOptions The requestOptions to send along with the query, they will be merged with
6790
+ * the transporter requestOptions. (optional)
6791
+ */
6792
+ public <T > List <BatchResponse > partialUpdateObjects (
6793
+ String indexName ,
6794
+ Iterable <T > objects ,
6795
+ boolean createIfNotExists ,
6796
+ boolean waitForTasks ,
6797
+ int batchSize ,
6798
+ RequestOptions requestOptions
6723
6799
) {
6724
6800
return chunkedBatch (
6725
6801
indexName ,
6726
6802
objects ,
6727
6803
createIfNotExists ? Action .PARTIAL_UPDATE_OBJECT : Action .PARTIAL_UPDATE_OBJECT_NO_CREATE ,
6728
6804
waitForTasks ,
6729
- 1000 ,
6805
+ batchSize ,
6730
6806
requestOptions
6731
6807
);
6732
6808
}
0 commit comments