Skip to content

Commit

Permalink
Multi field mapper with more than one extra mapping can cause endless…
Browse files Browse the repository at this point in the history
… re-sync'ing of mapping between nodes, closes elastic#1487.
  • Loading branch information
kimchy committed Nov 23, 2011
1 parent 7cf8105 commit 6be2c7f
Showing 1 changed file with 11 additions and 2 deletions.
Expand Up @@ -39,6 +39,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import static org.elasticsearch.common.collect.Lists.*;
import static org.elasticsearch.common.collect.MapBuilder.*;
Expand Down Expand Up @@ -305,8 +306,16 @@ public ImmutableMap<String, Mapper> mappers() {
if (defaultMapper != null) {
defaultMapper.toXContent(builder, params);
}
for (Mapper mapper : mappers.values()) {
mapper.toXContent(builder, params);
if (mappers.size() <= 1) {
for (Mapper mapper : mappers.values()) {
mapper.toXContent(builder, params);
}
} else {
// sort the mappers (by name) if there is more than one mapping
TreeMap<String, Mapper> sortedMappers = new TreeMap<String, Mapper>(mappers);
for (Mapper mapper : sortedMappers.values()) {
mapper.toXContent(builder, params);
}
}
builder.endObject();

Expand Down

0 comments on commit 6be2c7f

Please sign in to comment.