Merge pull request #15217 from jpountz/fix/simplify_MetaDataMappingService
Simplify MetaDataMappingService.
This commit is contained in:
commit
d2e07f21e0
|
@ -208,21 +208,14 @@ public class MetaDataMappingService extends AbstractComponent {
|
||||||
for (PutMappingClusterStateUpdateRequest request : tasks) {
|
for (PutMappingClusterStateUpdateRequest request : tasks) {
|
||||||
// failures here mean something is broken with our cluster state - fail all tasks by letting exceptions bubble up
|
// failures here mean something is broken with our cluster state - fail all tasks by letting exceptions bubble up
|
||||||
for (String index : request.indices()) {
|
for (String index : request.indices()) {
|
||||||
if (currentState.metaData().hasIndex(index)) {
|
final IndexMetaData indexMetaData = currentState.metaData().index(index);
|
||||||
|
if (indexMetaData != null && indicesService.hasIndex(index) == false) {
|
||||||
// if we don't have the index, we will throw exceptions later;
|
// if we don't have the index, we will throw exceptions later;
|
||||||
if (indicesService.hasIndex(index) == false || indicesToClose.contains(index)) {
|
indicesToClose.add(index);
|
||||||
final IndexMetaData indexMetaData = currentState.metaData().index(index);
|
IndexService indexService = indicesService.createIndex(nodeServicesProvider, indexMetaData, Collections.emptyList());
|
||||||
IndexService indexService;
|
// add mappings for all types, we need them for cross-type validation
|
||||||
if (indicesService.hasIndex(index) == false) {
|
for (ObjectCursor<MappingMetaData> mapping : indexMetaData.getMappings().values()) {
|
||||||
indicesToClose.add(index);
|
indexService.mapperService().merge(mapping.value.type(), mapping.value.source(), false, request.updateAllTypes());
|
||||||
indexService = indicesService.createIndex(nodeServicesProvider, indexMetaData, Collections.emptyList());
|
|
||||||
// add mappings for all types, we need them for cross-type validation
|
|
||||||
for (ObjectCursor<MappingMetaData> mapping : indexMetaData.getMappings().values()) {
|
|
||||||
indexService.mapperService().merge(mapping.value.type(), mapping.value.source(), false, request.updateAllTypes());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
indexService = indicesService.indexService(index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue