Add the default mapping at most once on batch mapping updates

When creating an index on master for the purpose of updating mappings,
the default mapping could needlessly be added multiple times. This
commit ensures that the default mapping is added at most once while
preparing to update mappings.
This commit is contained in:
Jason Tedor 2015-12-01 07:24:19 -05:00
parent eea72a6d86
commit 09006ace11
1 changed files with 5 additions and 5 deletions

View File

@ -234,15 +234,15 @@ public class MetaDataMappingService extends AbstractComponent {
final IndexMetaData indexMetaData = currentState.metaData().index(index);
IndexService indexService;
if (indicesService.hasIndex(index) == false) {
indexService = indicesService.createIndex(nodeServicesProvider, indexMetaData, Collections.EMPTY_LIST);
indicesToClose.add(index);
} else {
indexService = indicesService.indexService(index);
}
indexService = indicesService.createIndex(nodeServicesProvider, indexMetaData, Collections.EMPTY_LIST);
// make sure to add custom default mapping if exists
if (indexMetaData.getMappings().containsKey(MapperService.DEFAULT_MAPPING)) {
indexService.mapperService().merge(MapperService.DEFAULT_MAPPING, indexMetaData.getMappings().get(MapperService.DEFAULT_MAPPING).source(), false, request.updateAllTypes());
}
} else {
indexService = indicesService.indexService(index);
}
// only add the current relevant mapping (if exists)
if (indexMetaData.getMappings().containsKey(request.type())) {
indexService.mapperService().merge(request.type(), indexMetaData.getMappings().get(request.type()).source(), false, request.updateAllTypes());