From 050b7cd0f97c9a7835b837f2f64626f2acc39871 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Thu, 8 Jun 2017 10:57:04 -0600 Subject: [PATCH] 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 --- .../action/admin/indices/RestGetMappingAction.java | 3 --- .../test/indices.get_mapping/10_basic.yml | 13 +++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java index d596ab238cd..f379f18fe71 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java @@ -89,9 +89,6 @@ public class RestGetMappingAction extends BaseRestHandler { builder.startObject(); for (ObjectObjectCursor> indexEntry : mappingsByIndex) { - if (indexEntry.value.isEmpty()) { - continue; - } builder.startObject(indexEntry.key); builder.startObject(Fields.MAPPINGS); for (ObjectObjectCursor typeEntry : indexEntry.value) { diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/10_basic.yml index eed35fe4226..e9418f0a6cb 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/10_basic.yml @@ -19,6 +19,19 @@ setup: type_2: {} type_3: {} +--- +"Get /{index}/_mapping with empty mappings": + + - do: + indices.create: + index: t + + - do: + indices.get_mapping: + index: t + + - match: { t.mappings: {}} + --- "Get /_mapping":