Skip to content

Commit 296f2bc

Browse files
author
Christoph Büscher
committed
change mapping toXContent
1 parent d169030 commit 296f2bc

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

server/src/main/java/org/elasticsearch/action/admin/indices/get/GetIndexResponse.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,18 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
265265
}
266266
builder.endObject();
267267
} else {
268-
if (indexMappings != null && indexMappings.size() > 0) {
269-
builder.field("mappings");
270-
for (final ObjectObjectCursor<String, MappingMetaData> typeEntry : indexMappings) {
271-
builder.map(typeEntry.value.sourceAsMap());
268+
MappingMetaData mappings = null;
269+
for (final ObjectObjectCursor<String, MappingMetaData> typeEntry : indexMappings) {
270+
if (typeEntry.key.equals(MapperService.DEFAULT_MAPPING) == false) {
271+
assert mappings == null;
272+
mappings = typeEntry.value;
273+
}
274+
if (mappings == null) {
275+
// no mappings yet
276+
builder.startObject("mappings").endObject();
277+
} else {
278+
builder.field("mappings", mappings.sourceAsMap());
272279
}
273-
} else {
274-
// we always want to output a mappings object, even if empty
275-
builder.startObject("mappings");
276-
builder.endObject();
277280
}
278281
}
279282

server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ public class RestGetIndicesAction extends BaseRestHandler {
5050
static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Using `include_type_name` in get indices requests is deprecated. "
5151
+ "The parameter will be removed in the next major version.";
5252

53-
private static final Set<String> allowedResponseParameters = Collections.unmodifiableSet(Stream
54-
.concat(Collections.singleton(INCLUDE_TYPE_NAME_PARAMETER).stream(), Settings.FORMAT_PARAMS.stream()).collect(Collectors.toSet()));
53+
private static final Set<String> allowedResponseParameters = Collections
54+
.unmodifiableSet(Stream.concat(Collections.singleton(INCLUDE_TYPE_NAME_PARAMETER).stream(), Settings.FORMAT_PARAMS.stream())
55+
.collect(Collectors.toSet()));
5556

5657
public RestGetIndicesAction(
5758
final Settings settings,

0 commit comments

Comments
 (0)