diff --git a/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetMappingsAction.java b/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetMappingsAction.java index 17ff5f2362a..c134a862d0e 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetMappingsAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetMappingsAction.java @@ -57,6 +57,7 @@ public class TransportGetMappingsAction extends TransportClusterInfoAction listener) throws ElasticSearchException { + logger.debug("Serving getMapping request based on version {}", state.version()); ImmutableMap> result = state.metaData().findMappings( request.indices(), request.types() ); diff --git a/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeOperationAction.java b/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeOperationAction.java index e0912301dc7..66b3045df97 100644 --- a/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeOperationAction.java +++ b/src/main/java/org/elasticsearch/action/support/master/TransportMasterNodeOperationAction.java @@ -141,7 +141,7 @@ public abstract class TransportMasterNodeOperationAction defaultMapping = response.getMappings().get("test").get(MapperService.DEFAULT_MAPPING).sourceAsMap(); + assertThat(putResponse.isAcknowledged(), equalTo(true)); + logger.info("DONE: Creating _default_ mappings"); + + GetMappingsResponse getResponse = client().admin().indices().prepareGetMappings("test").addTypes(MapperService.DEFAULT_MAPPING).get(); + Map defaultMapping = getResponse.getMappings().get("test").get(MapperService.DEFAULT_MAPPING).sourceAsMap(); assertThat(defaultMapping, hasKey("date_detection")); + logger.info("Emptying _default_ mappings"); // now remove it - client().admin().indices().preparePutMapping("test").setType(MapperService.DEFAULT_MAPPING).setSource( + putResponse = client().admin().indices().preparePutMapping("test").setType(MapperService.DEFAULT_MAPPING).setSource( JsonXContent.contentBuilder().startObject().startObject(MapperService.DEFAULT_MAPPING) .endObject().endObject() ).get(); + assertThat(putResponse.isAcknowledged(), equalTo(true)); + logger.info("Done Emptying _default_ mappings"); - response = client().admin().indices().prepareGetMappings("test").addTypes(MapperService.DEFAULT_MAPPING).get(); - defaultMapping = response.getMappings().get("test").get(MapperService.DEFAULT_MAPPING).sourceAsMap(); + getResponse = client().admin().indices().prepareGetMappings("test").addTypes(MapperService.DEFAULT_MAPPING).get(); + defaultMapping = getResponse.getMappings().get("test").get(MapperService.DEFAULT_MAPPING).sourceAsMap(); assertThat(defaultMapping, not(hasKey("date_detection"))); // now test you can change stuff that are normally unchangable - client().admin().indices().preparePutMapping("test").setType(MapperService.DEFAULT_MAPPING).setSource( + logger.info("Creating _default_ mappings with an analyzed field"); + putResponse = client().admin().indices().preparePutMapping("test").setType(MapperService.DEFAULT_MAPPING).setSource( JsonXContent.contentBuilder().startObject().startObject(MapperService.DEFAULT_MAPPING) .startObject("properties").startObject("f").field("type", "string").field("index", "analyzed").endObject().endObject() .endObject().endObject() ).get(); + assertThat(putResponse.isAcknowledged(), equalTo(true)); - client().admin().indices().preparePutMapping("test").setType(MapperService.DEFAULT_MAPPING).setSource( + logger.info("Changing _default_ mappings field from analyzed to non-analyzed"); + putResponse = client().admin().indices().preparePutMapping("test").setType(MapperService.DEFAULT_MAPPING).setSource( JsonXContent.contentBuilder().startObject().startObject(MapperService.DEFAULT_MAPPING) .startObject("properties").startObject("f").field("type", "string").field("index", "not_analyzed").endObject().endObject() .endObject().endObject() ).get(); - response = client().admin().indices().prepareGetMappings("test").addTypes(MapperService.DEFAULT_MAPPING).get(); - defaultMapping = response.getMappings().get("test").get(MapperService.DEFAULT_MAPPING).sourceAsMap(); + assertThat(putResponse.isAcknowledged(), equalTo(true)); + logger.info("Done changing _default_ mappings field from analyzed to non-analyzed"); + + getResponse = client().admin().indices().prepareGetMappings("test").addTypes(MapperService.DEFAULT_MAPPING).get(); + defaultMapping = getResponse.getMappings().get("test").get(MapperService.DEFAULT_MAPPING).sourceAsMap(); Map fieldSettings = (Map) ((Map) defaultMapping.get("properties")).get("f"); assertThat(fieldSettings, hasEntry("index", (Object) "not_analyzed")); // but we still validate the _default_ type + logger.info("Confirming _default_ mappings validation"); assertThrows(client().admin().indices().preparePutMapping("test").setType(MapperService.DEFAULT_MAPPING).setSource( JsonXContent.contentBuilder().startObject().startObject(MapperService.DEFAULT_MAPPING) .startObject("properties").startObject("f").field("type", "DOESNT_EXIST").endObject().endObject()