diff --git a/src/main/java/org/elasticsearch/index/mapper/MapperService.java b/src/main/java/org/elasticsearch/index/mapper/MapperService.java index 6bfac74e648..bd2b6e486eb 100644 --- a/src/main/java/org/elasticsearch/index/mapper/MapperService.java +++ b/src/main/java/org/elasticsearch/index/mapper/MapperService.java @@ -302,14 +302,18 @@ public class MapperService extends AbstractIndexComponent implements Iterable nameFieldMappers = newMapBuilder(this.nameFieldMappers); + MapBuilder indexNameFieldMappers = newMapBuilder(this.indexNameFieldMappers); + MapBuilder fullNameFieldMappers = newMapBuilder(this.fullNameFieldMappers); + for (FieldMapper mapper : docMapper.mappers()) { FieldMappers mappers = nameFieldMappers.get(mapper.names().name()); if (mappers != null) { mappers = mappers.remove(mapper); if (mappers.isEmpty()) { - nameFieldMappers = newMapBuilder(nameFieldMappers).remove(mapper.names().name()).map(); + nameFieldMappers.remove(mapper.names().name()); } else { - nameFieldMappers = newMapBuilder(nameFieldMappers).put(mapper.names().name(), mappers).map(); + nameFieldMappers.put(mapper.names().name(), mappers); } } @@ -317,9 +321,9 @@ public class MapperService extends AbstractIndexComponent implements Iterable fullPathObjectMappers = newMapBuilder(this.fullPathObjectMappers); for (ObjectMapper mapper : docMapper.objectMappers().values()) { ObjectMappers mappers = fullPathObjectMappers.get(mapper.fullPath()); if (mappers != null) { mappers = mappers.remove(mapper); if (mappers.isEmpty()) { - fullPathObjectMappers = newMapBuilder(fullPathObjectMappers).remove(mapper.fullPath()).map(); + fullPathObjectMappers.remove(mapper.fullPath()); } else { - fullPathObjectMappers = newMapBuilder(fullPathObjectMappers).put(mapper.fullPath(), mappers).map(); + fullPathObjectMappers.put(mapper.fullPath(), mappers); } } } + + this.fullPathObjectMappers = fullPathObjectMappers.map(); } /**