8
8
import com .algolia .config .ClientOptions ;
9
9
import com .algolia .exceptions .*;
10
10
import com .algolia .internal .JsonSerializer ;
11
- import com .algolia .model .ingestion .PushTaskPayload ;
12
- import com .algolia .model .ingestion .PushTaskRecords ;
13
11
import com .algolia .model .ingestion .WatchResponse ;
14
12
import com .algolia .model .search .*;
15
13
import com .algolia .utils .*;
16
14
import com .fasterxml .jackson .core .type .TypeReference ;
17
- import com .fasterxml .jackson .databind .ObjectMapper ;
18
15
import java .nio .charset .Charset ;
19
16
import java .security .InvalidKeyException ;
20
17
import java .security .NoSuchAlgorithmException ;
@@ -6765,7 +6762,7 @@ public <T> List<BatchResponse> chunkedBatch(
6765
6762
* @throws AlgoliaApiException When the API sends an http error code
6766
6763
* @throws AlgoliaRuntimeException When an error occurred during the serialization
6767
6764
*/
6768
- public <T > WatchResponse saveObjectsWithTransformation (String indexName , Iterable <T > objects ) {
6765
+ public <T > List < WatchResponse > saveObjectsWithTransformation (String indexName , Iterable <T > objects ) {
6769
6766
return saveObjectsWithTransformation (indexName , objects , null );
6770
6767
}
6771
6768
@@ -6780,7 +6777,7 @@ public <T> WatchResponse saveObjectsWithTransformation(String indexName, Iterabl
6780
6777
* @param requestOptions The requestOptions to send along with the query, they will be merged with
6781
6778
* the transporter requestOptions. (optional)
6782
6779
*/
6783
- public <T > WatchResponse saveObjectsWithTransformation (String indexName , Iterable <T > objects , RequestOptions requestOptions ) {
6780
+ public <T > List < WatchResponse > saveObjectsWithTransformation (String indexName , Iterable <T > objects , RequestOptions requestOptions ) {
6784
6781
return saveObjectsWithTransformation (indexName , objects , false , requestOptions );
6785
6782
}
6786
6783
@@ -6798,7 +6795,7 @@ public <T> WatchResponse saveObjectsWithTransformation(String indexName, Iterabl
6798
6795
* @param requestOptions The requestOptions to send along with the query, they will be merged with
6799
6796
* the transporter requestOptions. (optional)
6800
6797
*/
6801
- public <T > WatchResponse saveObjectsWithTransformation (
6798
+ public <T > List < WatchResponse > saveObjectsWithTransformation (
6802
6799
String indexName ,
6803
6800
Iterable <T > objects ,
6804
6801
boolean waitForTasks ,
@@ -6823,7 +6820,7 @@ public <T> WatchResponse saveObjectsWithTransformation(
6823
6820
* @param requestOptions The requestOptions to send along with the query, they will be merged with
6824
6821
* the transporter requestOptions. (optional)
6825
6822
*/
6826
- public <T > WatchResponse saveObjectsWithTransformation (
6823
+ public <T > List < WatchResponse > saveObjectsWithTransformation (
6827
6824
String indexName ,
6828
6825
Iterable <T > objects ,
6829
6826
boolean waitForTasks ,
@@ -6834,28 +6831,17 @@ public <T> WatchResponse saveObjectsWithTransformation(
6834
6831
throw new AlgoliaRuntimeException ("`setTransformationRegion` must have been called before calling this method." );
6835
6832
}
6836
6833
6837
- return this .ingestionTransporter .push (
6834
+ return this .ingestionTransporter .chunkedPush (
6838
6835
indexName ,
6839
- new PushTaskPayload ().setAction (com .algolia .model .ingestion .Action .ADD_OBJECT ).setRecords (this .objectsToPushTaskRecords (objects )),
6836
+ objects ,
6837
+ com .algolia .model .ingestion .Action .ADD_OBJECT ,
6840
6838
waitForTasks ,
6839
+ batchSize ,
6841
6840
null ,
6842
6841
requestOptions
6843
6842
);
6844
6843
}
6845
6844
6846
- private <T > List <PushTaskRecords > objectsToPushTaskRecords (Iterable <T > objects ) {
6847
- try {
6848
- ObjectMapper mapper = new ObjectMapper ();
6849
- String json = mapper .writeValueAsString (objects );
6850
-
6851
- return mapper .readValue (json , new TypeReference <List <PushTaskRecords >>() {});
6852
- } catch (Exception e ) {
6853
- throw new AlgoliaRuntimeException (
6854
- "each object must have an `objectID` key in order to be used with the" + " WithTransformation methods"
6855
- );
6856
- }
6857
- }
6858
-
6859
6845
/**
6860
6846
* Helper: Saves the given array of objects in the given index. The `chunkedBatch` helper is used
6861
6847
* under the hood, which creates a `batch` requests with at most 1000 objects in it.
@@ -7003,7 +6989,7 @@ public List<BatchResponse> deleteObjects(
7003
6989
* @param createIfNotExists To be provided if non-existing objects are passed, otherwise, the call
7004
6990
* will fail.
7005
6991
*/
7006
- public <T > WatchResponse partialUpdateObjectsWithTransformation (String indexName , Iterable <T > objects , boolean createIfNotExists ) {
6992
+ public <T > List < WatchResponse > partialUpdateObjectsWithTransformation (String indexName , Iterable <T > objects , boolean createIfNotExists ) {
7007
6993
return partialUpdateObjectsWithTransformation (indexName , objects , createIfNotExists , false , null );
7008
6994
}
7009
6995
@@ -7021,7 +7007,7 @@ public <T> WatchResponse partialUpdateObjectsWithTransformation(String indexName
7021
7007
* processed, this operation may slow the total execution time of this method but is more
7022
7008
* reliable.
7023
7009
*/
7024
- public <T > WatchResponse partialUpdateObjectsWithTransformation (
7010
+ public <T > List < WatchResponse > partialUpdateObjectsWithTransformation (
7025
7011
String indexName ,
7026
7012
Iterable <T > objects ,
7027
7013
boolean createIfNotExists ,
@@ -7046,7 +7032,7 @@ public <T> WatchResponse partialUpdateObjectsWithTransformation(
7046
7032
* @param requestOptions The requestOptions to send along with the query, they will be merged with
7047
7033
* the transporter requestOptions. (optional)
7048
7034
*/
7049
- public <T > WatchResponse partialUpdateObjectsWithTransformation (
7035
+ public <T > List < WatchResponse > partialUpdateObjectsWithTransformation (
7050
7036
String indexName ,
7051
7037
Iterable <T > objects ,
7052
7038
boolean createIfNotExists ,
@@ -7074,7 +7060,7 @@ public <T> WatchResponse partialUpdateObjectsWithTransformation(
7074
7060
* @param requestOptions The requestOptions to send along with the query, they will be merged with
7075
7061
* the transporter requestOptions. (optional)
7076
7062
*/
7077
- public <T > WatchResponse partialUpdateObjectsWithTransformation (
7063
+ public <T > List < WatchResponse > partialUpdateObjectsWithTransformation (
7078
7064
String indexName ,
7079
7065
Iterable <T > objects ,
7080
7066
boolean createIfNotExists ,
@@ -7086,16 +7072,14 @@ public <T> WatchResponse partialUpdateObjectsWithTransformation(
7086
7072
throw new AlgoliaRuntimeException ("`setTransformationRegion` must have been called before calling this method." );
7087
7073
}
7088
7074
7089
- return this .ingestionTransporter .push (
7075
+ return this .ingestionTransporter .chunkedPush (
7090
7076
indexName ,
7091
- new PushTaskPayload ()
7092
- .setAction (
7093
- createIfNotExists
7094
- ? com .algolia .model .ingestion .Action .PARTIAL_UPDATE_OBJECT
7095
- : com .algolia .model .ingestion .Action .PARTIAL_UPDATE_OBJECT_NO_CREATE
7096
- )
7097
- .setRecords (this .objectsToPushTaskRecords (objects )),
7077
+ objects ,
7078
+ createIfNotExists
7079
+ ? com .algolia .model .ingestion .Action .PARTIAL_UPDATE_OBJECT
7080
+ : com .algolia .model .ingestion .Action .PARTIAL_UPDATE_OBJECT_NO_CREATE ,
7098
7081
waitForTasks ,
7082
+ batchSize ,
7099
7083
null ,
7100
7084
requestOptions
7101
7085
);
0 commit comments