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:
parent
eea72a6d86
commit
09006ace11
|
@ -234,15 +234,15 @@ public class MetaDataMappingService extends AbstractComponent {
|
||||||
final IndexMetaData indexMetaData = currentState.metaData().index(index);
|
final IndexMetaData indexMetaData = currentState.metaData().index(index);
|
||||||
IndexService indexService;
|
IndexService indexService;
|
||||||
if (indicesService.hasIndex(index) == false) {
|
if (indicesService.hasIndex(index) == false) {
|
||||||
indexService = indicesService.createIndex(nodeServicesProvider, indexMetaData, Collections.EMPTY_LIST);
|
|
||||||
indicesToClose.add(index);
|
indicesToClose.add(index);
|
||||||
} else {
|
indexService = indicesService.createIndex(nodeServicesProvider, indexMetaData, Collections.EMPTY_LIST);
|
||||||
indexService = indicesService.indexService(index);
|
|
||||||
}
|
|
||||||
// make sure to add custom default mapping if exists
|
// make sure to add custom default mapping if exists
|
||||||
if (indexMetaData.getMappings().containsKey(MapperService.DEFAULT_MAPPING)) {
|
if (indexMetaData.getMappings().containsKey(MapperService.DEFAULT_MAPPING)) {
|
||||||
indexService.mapperService().merge(MapperService.DEFAULT_MAPPING, indexMetaData.getMappings().get(MapperService.DEFAULT_MAPPING).source(), false, request.updateAllTypes());
|
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)
|
// only add the current relevant mapping (if exists)
|
||||||
if (indexMetaData.getMappings().containsKey(request.type())) {
|
if (indexMetaData.getMappings().containsKey(request.type())) {
|
||||||
indexService.mapperService().merge(request.type(), indexMetaData.getMappings().get(request.type()).source(), false, request.updateAllTypes());
|
indexService.mapperService().merge(request.type(), indexMetaData.getMappings().get(request.type()).source(), false, request.updateAllTypes());
|
||||||
|
|
Loading…
Reference in New Issue