@@ -708,7 +708,25 @@ public <T> List<BatchResponse> saveObjects(String indexName, Iterable<T> objects
708708 * the transporter requestOptions. (optional)
709709 */
710710public <T> List<BatchResponse> saveObjects(String indexName, Iterable<T> objects, boolean waitForTasks, RequestOptions requestOptions) {
711- return chunkedBatch(indexName, objects, Action.ADD_OBJECT, waitForTasks, 1000, requestOptions);
711+ return saveObjects(indexName, objects, false, 1000, requestOptions);
712+ }
713+
714+ /**
715+ * Helper: Saves the given array of objects in the given index. The `chunkedBatch` helper is used
716+ * under the hood, which creates a `batch` requests with at most 1000 objects in it.
717+ *
718+ * @param indexName The `indexName` to replace `objects` in.
719+ * @param objects The array of `objects` to store in the given Algolia `indexName`.
720+ * @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
721+ * processed, this operation may slow the total execution time of this method but is more
722+ * reliable.
723+ * @param batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal
724+ * to `length(objects) / batchSize`.
725+ * @param requestOptions The requestOptions to send along with the query, they will be merged with
726+ * the transporter requestOptions. (optional)
727+ */
728+ public <T> List<BatchResponse> saveObjects(String indexName, Iterable<T> objects, boolean waitForTasks, int batchSize, RequestOptions requestOptions) {
729+ return chunkedBatch(indexName, objects, Action.ADD_OBJECT, waitForTasks, batchSize, requestOptions);
712730}
713731
714732/**
@@ -747,7 +765,25 @@ public List<BatchResponse> deleteObjects(String indexName, List<String> objectID
747765 * @param requestOptions The requestOptions to send along with the query, they will be merged with
748766 * the transporter requestOptions. (optional)
749767 */
750- public List<BatchResponse> deleteObjects(String indexName, List<String> objectIDs, boolean waitForTasks, RequestOptions requestOptions) {
768+ public List<BatchResponse> deleteObjects(String indexName, List<String> objectIDs, boolean waitForTasks,RequestOptions requestOptions) {
769+ return deleteObjects(indexName, objectIDs, false, 1000, null);
770+ }
771+
772+ /**
773+ * Helper: Deletes every records for the given objectIDs. The `chunkedBatch` helper is used under
774+ * the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
775+ *
776+ * @param indexName The `indexName` to delete `objectIDs` from.
777+ * @param objectIDs The array of `objectIDs` to delete from the `indexName`.
778+ * @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
779+ * processed, this operation may slow the total execution time of this method but is more
780+ * reliable.
781+ * @param batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal
782+ * to `length(objects) / batchSize`.
783+ * @param requestOptions The requestOptions to send along with the query, they will be merged with
784+ * the transporter requestOptions. (optional)
785+ */
786+ public List<BatchResponse> deleteObjects(String indexName, List<String> objectIDs, boolean waitForTasks, int batchSize, RequestOptions requestOptions) {
751787 List<Map<String, String>> objects = new ArrayList<>();
752788
753789 for (String id : objectIDs) {
@@ -756,7 +792,7 @@ public List<BatchResponse> deleteObjects(String indexName, List<String> objectID
756792 objects.add(obj);
757793 }
758794
759- return chunkedBatch(indexName, objects, Action.DELETE_OBJECT, waitForTasks, 1000 , requestOptions);
795+ return chunkedBatch(indexName, objects, Action.DELETE_OBJECT, waitForTasks, batchSize , requestOptions);
760796}
761797
762798/**
@@ -816,13 +852,41 @@ public <T> List<BatchResponse> partialUpdateObjects(
816852 boolean createIfNotExists,
817853 boolean waitForTasks,
818854 RequestOptions requestOptions
855+ ) {
856+ return partialUpdateObjects(indexName, objects, createIfNotExists, waitForTasks, 1000, null);
857+ }
858+
859+ /**
860+ * Helper: Replaces object content of all the given objects according to their respective
861+ * `objectID` field. The `chunkedBatch` helper is used under the hood, which creates a `batch`
862+ * requests with at most 1000 objects in it.
863+ *
864+ * @param indexName The `indexName` to update `objects` in.
865+ * @param objects The array of `objects` to update in the given Algolia `indexName`.
866+ * @param createIfNotExists To be provided if non-existing objects are passed, otherwise, the call
867+ * will fail.
868+ * @param waitForTasks - Whether or not we should wait until every `batch` tasks has been
869+ * processed, this operation may slow the total execution time of this method but is more
870+ * reliable.
871+ * @param batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal
872+ * to `length(objects) / batchSize`.
873+ * @param requestOptions The requestOptions to send along with the query, they will be merged with
874+ * the transporter requestOptions. (optional)
875+ */
876+ public <T> List<BatchResponse> partialUpdateObjects(
877+ String indexName,
878+ Iterable<T> objects,
879+ boolean createIfNotExists,
880+ boolean waitForTasks,
881+ int batchSize,
882+ RequestOptions requestOptions
819883) {
820884 return chunkedBatch(
821885 indexName,
822886 objects,
823887 createIfNotExists ? Action.PARTIAL_UPDATE_OBJECT : Action.PARTIAL_UPDATE_OBJECT_NO_CREATE,
824888 waitForTasks,
825- 1000 ,
889+ batchSize ,
826890 requestOptions
827891 );
828892}
0 commit comments