Skip to content

Commit

Permalink
Delete Mapping API: Wrongly deleting existing mapping information, cl…
Browse files Browse the repository at this point in the history
…oses elastic#531.
  • Loading branch information
kimchy committed Dec 3, 2010
1 parent 00f1b5b commit 666de6a
Showing 1 changed file with 7 additions and 7 deletions.
Expand Up @@ -188,23 +188,23 @@ public void remove(String type) {
}
}

mappers = indexNameFieldMappers.get(mapper.names().name());
mappers = indexNameFieldMappers.get(mapper.names().indexName());
if (mappers != null) {
mappers = mappers.remove(mapper);
if (mappers.isEmpty()) {
indexNameFieldMappers = newMapBuilder(indexNameFieldMappers).remove(mapper.names().name()).immutableMap();
indexNameFieldMappers = newMapBuilder(indexNameFieldMappers).remove(mapper.names().indexName()).immutableMap();
} else {
indexNameFieldMappers = newMapBuilder(indexNameFieldMappers).put(mapper.names().name(), mappers).immutableMap();
indexNameFieldMappers = newMapBuilder(indexNameFieldMappers).put(mapper.names().indexName(), mappers).immutableMap();
}
}

mappers = fullNameFieldMappers.get(mapper.names().name());
mappers = fullNameFieldMappers.get(mapper.names().fullName());
if (mappers != null) {
mappers = mappers.remove(mapper);
if (mappers.isEmpty()) {
fullNameFieldMappers = newMapBuilder(fullNameFieldMappers).remove(mapper.names().name()).immutableMap();
fullNameFieldMappers = newMapBuilder(fullNameFieldMappers).remove(mapper.names().fullName()).immutableMap();
} else {
fullNameFieldMappers = newMapBuilder(fullNameFieldMappers).put(mapper.names().name(), mappers).immutableMap();
fullNameFieldMappers = newMapBuilder(fullNameFieldMappers).put(mapper.names().fullName(), mappers).immutableMap();
}
}
}
Expand Down Expand Up @@ -555,7 +555,7 @@ private class InternalFieldMapperListener implements FieldMapperListener {
}
indexNameFieldMappers = newMapBuilder(indexNameFieldMappers).put(fieldMapper.names().indexName(), mappers).immutableMap();

mappers = fullNameFieldMappers.get(fieldMapper.names().indexName());
mappers = fullNameFieldMappers.get(fieldMapper.names().fullName());
if (mappers == null) {
mappers = new FieldMappers(fieldMapper);
} else {
Expand Down

0 comments on commit 666de6a

Please sign in to comment.