File tree Expand file tree Collapse file tree 3 files changed +19
-7
lines changed
server/src/main/java/org/elasticsearch/index/mapper Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -769,8 +769,12 @@ private static void parseNonDynamicArray(
769769 }
770770 previousToken = token ;
771771 }
772- if (mapper != null && previousToken == XContentParser .Token .START_ARRAY ) {
773- mapper .handleEmptyArray (context );
772+ if (mapper != null
773+ && mapper .supportStoringArrayOffsets (context )
774+ && previousToken == XContentParser .Token .START_ARRAY
775+ && context .isImmediateParentAnArray ()
776+ && context .getRecordedSource () == false ) {
777+ context .getOffSetContext ().maybeRecordEmptyArray (mapper .getOffsetFieldName ());
774778 }
775779 context .setImmediateXContentParent (token );
776780 if (elements <= 1 && canRemoveSingleLeafElement ) {
Original file line number Diff line number Diff line change @@ -1114,10 +1114,9 @@ public boolean supportStoringArrayOffsets(DocumentParserContext context) {
11141114 }
11151115 }
11161116
1117- public void handleEmptyArray (DocumentParserContext context ) {
1118- if (offsetsFieldName != null && context .isImmediateParentAnArray () && context .getRecordedSource () == false ) {
1119- context .getOffSetContext ().maybeRecordEmptyArray (offsetsFieldName );
1120- }
1117+ @ Override
1118+ public String getOffsetFieldName () {
1119+ return offsetsFieldName ;
11211120 }
11221121
11231122 protected void parseCreateField (DocumentParserContext context ) throws IOException {
Original file line number Diff line number Diff line change @@ -213,9 +213,18 @@ public static FieldType freezeAndDeduplicateFieldType(FieldType fieldType) {
213213 */
214214 public abstract int getTotalFieldsCount ();
215215
216+ /**
217+ * @return whether this mapper support storing leaf array elements natively when synthetic source is enabled.
218+ */
216219 public boolean supportStoringArrayOffsets (DocumentParserContext context ) {
217220 return false ;
218221 }
219222
220- public void handleEmptyArray (DocumentParserContext context ) {}
223+ /**
224+ * @return the offset field name use the store offsets iff {@link #supportStoringArrayOffsets(DocumentParserContext)} returns
225+ * <code>true</code>.
226+ */
227+ public String getOffsetFieldName () {
228+ return null ;
229+ }
221230}
You can’t perform that action at this time.
0 commit comments