@@ -186,7 +186,13 @@ private static List<IngestDocument> parseDocs(Map<String, Object> config) {
186
186
dataMap , Metadata .ROUTING .getFieldName ());
187
187
Long version = null ;
188
188
if (dataMap .containsKey (Metadata .VERSION .getFieldName ())) {
189
- version = (Long ) ConfigurationUtils .readObject (null , null , dataMap , Metadata .VERSION .getFieldName ());
189
+ String versionValue = ConfigurationUtils .readOptionalStringOrIntProperty (null , null ,
190
+ dataMap , Metadata .VERSION .getFieldName ());
191
+ if (versionValue != null ) {
192
+ version = Long .valueOf (versionValue );
193
+ } else {
194
+ throw new IllegalArgumentException ("[_version] cannot be null" );
195
+ }
190
196
}
191
197
VersionType versionType = null ;
192
198
if (dataMap .containsKey (Metadata .VERSION_TYPE .getFieldName ())) {
@@ -196,12 +202,24 @@ private static List<IngestDocument> parseDocs(Map<String, Object> config) {
196
202
IngestDocument ingestDocument =
197
203
new IngestDocument (index , id , routing , version , versionType , document );
198
204
if (dataMap .containsKey (Metadata .IF_SEQ_NO .getFieldName ())) {
199
- Long ifSeqNo = (Long ) ConfigurationUtils .readObject (null , null , dataMap , Metadata .IF_SEQ_NO .getFieldName ());
200
- ingestDocument .setFieldValue (Metadata .IF_SEQ_NO .getFieldName (), ifSeqNo );
205
+ String ifSeqNoValue = ConfigurationUtils .readOptionalStringOrIntProperty (null , null ,
206
+ dataMap , Metadata .IF_SEQ_NO .getFieldName ());
207
+ if (ifSeqNoValue != null ) {
208
+ Long ifSeqNo = Long .valueOf (ifSeqNoValue );
209
+ ingestDocument .setFieldValue (Metadata .IF_SEQ_NO .getFieldName (), ifSeqNo );
210
+ } else {
211
+ throw new IllegalArgumentException ("[_if_seq_no] cannot be null" );
212
+ }
201
213
}
202
214
if (dataMap .containsKey (Metadata .IF_PRIMARY_TERM .getFieldName ())) {
203
- Long ifPrimaryTerm = (Long ) ConfigurationUtils .readObject (null , null , dataMap , Metadata .IF_PRIMARY_TERM .getFieldName ());
204
- ingestDocument .setFieldValue (Metadata .IF_PRIMARY_TERM .getFieldName (), ifPrimaryTerm );
215
+ String ifPrimaryTermValue = ConfigurationUtils .readOptionalStringOrIntProperty (null , null ,
216
+ dataMap , Metadata .IF_PRIMARY_TERM .getFieldName ());
217
+ if (ifPrimaryTermValue != null ) {
218
+ Long ifPrimaryTerm = Long .valueOf (ifPrimaryTermValue );
219
+ ingestDocument .setFieldValue (Metadata .IF_PRIMARY_TERM .getFieldName (), ifPrimaryTerm );
220
+ } else {
221
+ throw new IllegalArgumentException ("[_if_primary_term] cannot be null" );
222
+ }
205
223
}
206
224
ingestDocumentList .add (ingestDocument );
207
225
}
0 commit comments