34
34
35
35
import com .carrotsearch .hppc .cursors .ObjectCursor ;
36
36
import com .carrotsearch .hppc .cursors .ObjectObjectCursor ;
37
+
37
38
import org .apache .lucene .document .Field ;
38
39
import org .apache .lucene .document .FieldType ;
39
40
import org .apache .lucene .index .IndexOptions ;
@@ -265,6 +266,7 @@ public boolean parsesArrayValue() {
265
266
* Parse the field value using the provided {@link ParseContext}.
266
267
*/
267
268
public void parse (ParseContext context ) throws IOException {
269
+ boolean ignore_malformed = IGNORE_MALFORMED_SETTING .get (context .indexSettings ().getSettings ());
268
270
try {
269
271
parseCreateField (context );
270
272
} catch (Exception e ) {
@@ -278,23 +280,27 @@ public void parse(ParseContext context) throws IOException {
278
280
valuePreview = complexValue .toString ();
279
281
}
280
282
} catch (Exception innerException ) {
283
+ if (!ignore_malformed ) {
284
+ throw new MapperParsingException (
285
+ "failed to parse field [{}] of type [{}] in document with id '{}'. " + "Could not parse field value preview," ,
286
+ e ,
287
+ fieldType ().name (),
288
+ fieldType ().typeName (),
289
+ context .sourceToParse ().id ()
290
+ );
291
+ }
292
+ }
293
+
294
+ if (!ignore_malformed ) {
281
295
throw new MapperParsingException (
282
- "failed to parse field [{}] of type [{}] in document with id '{}'. " + "Could not parse field value preview, " ,
296
+ "failed to parse field [{}] of type [{}] in document with id '{}'. " + "Preview of field's value: '{}' " ,
283
297
e ,
284
298
fieldType ().name (),
285
299
fieldType ().typeName (),
286
- context .sourceToParse ().id ()
300
+ context .sourceToParse ().id (),
301
+ valuePreview
287
302
);
288
303
}
289
-
290
- throw new MapperParsingException (
291
- "failed to parse field [{}] of type [{}] in document with id '{}'. " + "Preview of field's value: '{}'" ,
292
- e ,
293
- fieldType ().name (),
294
- fieldType ().typeName (),
295
- context .sourceToParse ().id (),
296
- valuePreview
297
- );
298
304
}
299
305
multiFields .parse (this , context );
300
306
}
0 commit comments