Skip to content

Commit 1cf9eac

Browse files
authored
Tweak toXContent implementation of ParametrizedFieldMapper (#59968)
ParametrizedFieldMapper overrides `toXContent` from `FieldMapper`, yet it could override `doXContentBody` and rely on the `toXContent` from the base class. Additionally, this allows to make `doXContentBody` final. Also, toXContent is still overridden only to make it final.
1 parent 57719fc commit 1cf9eac

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

server/src/main/java/org/elasticsearch/index/mapper/ParametrizedFieldMapper.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,15 @@ protected final void mergeOptions(FieldMapper other, List<String> conflicts) {
105105

106106
@Override
107107
public final XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
108-
builder.startObject(simpleName());
108+
return super.toXContent(builder, params);
109+
}
110+
111+
@Override
112+
protected final void doXContentBody(XContentBuilder builder, boolean includeDefaults, Params params) throws IOException {
109113
builder.field("type", contentType());
110-
boolean includeDefaults = params.paramAsBoolean("include_defaults", false);
111114
getMergeBuilder().toXContent(builder, includeDefaults);
112115
multiFields.toXContent(builder, params);
113116
copyTo.toXContent(builder, params);
114-
return builder.endObject();
115117
}
116118

117119
/**

0 commit comments

Comments
 (0)