Add each mapping at most once on batch mapping updates

When creating an index on master for the purpose of updating mappings, a
mapping being updated could needlessly be merged multiple times. This
commit ensures that each mapping is merged at most once while preparing
to update mappings.
This commit is contained in:
Jason Tedor 2015-12-01 07:43:45 -05:00
parent 09006ace11
commit 13dbed9c92
1 changed files with 3 additions and 2 deletions

View File

@ -243,8 +243,9 @@ public class MetaDataMappingService extends AbstractComponent {
} else { } else {
indexService = indicesService.indexService(index); indexService = indicesService.indexService(index);
} }
// only add the current relevant mapping (if exists) // only add the current relevant mapping (if exists and not yet added)
if (indexMetaData.getMappings().containsKey(request.type())) { if (indexMetaData.getMappings().containsKey(request.type()) &&
!indexService.mapperService().hasMapping(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());
} }
} }