Skip to content

Commit 050b7cd

Browse files
authored
Include empty mappings in GET /{index}/_mappings requests (#25118)
Previously this would output: ``` GET /test-1/_mappings { } ``` And after this change: ``` GET /test-1/_mappings { "test-1": { "mappings": {} } } ``` To bring parity back to the REST output after #24723. Relates to #25090
1 parent 5b2ab96 commit 050b7cd

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ public RestResponse buildResponse(GetMappingsResponse response, XContentBuilder
8989

9090
builder.startObject();
9191
for (ObjectObjectCursor<String, ImmutableOpenMap<String, MappingMetaData>> indexEntry : mappingsByIndex) {
92-
if (indexEntry.value.isEmpty()) {
93-
continue;
94-
}
9592
builder.startObject(indexEntry.key);
9693
builder.startObject(Fields.MAPPINGS);
9794
for (ObjectObjectCursor<String, MappingMetaData> typeEntry : indexEntry.value) {

rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/10_basic.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ setup:
1919
type_2: {}
2020
type_3: {}
2121

22+
---
23+
"Get /{index}/_mapping with empty mappings":
24+
25+
- do:
26+
indices.create:
27+
index: t
28+
29+
- do:
30+
indices.get_mapping:
31+
index: t
32+
33+
- match: { t.mappings: {}}
34+
2235
---
2336
"Get /_mapping":
2437

0 commit comments

Comments
 (0)