Multi field mapper with more than one extra mapping can cause endless re-sync'ing of mapping between nodes, closes #1487.

This commit is contained in:
Shay Banon 2011-11-23 09:04:28 +02:00
parent 05f98634d8
commit f47b77199d
1 changed files with 11 additions and 2 deletions

View File

@ -39,6 +39,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap;
import static org.elasticsearch.common.collect.Lists.*; import static org.elasticsearch.common.collect.Lists.*;
import static org.elasticsearch.common.collect.MapBuilder.*; import static org.elasticsearch.common.collect.MapBuilder.*;
@ -305,8 +306,16 @@ public class MultiFieldMapper implements Mapper, AllFieldMapper.IncludeInAll {
if (defaultMapper != null) { if (defaultMapper != null) {
defaultMapper.toXContent(builder, params); defaultMapper.toXContent(builder, params);
} }
for (Mapper mapper : mappers.values()) { if (mappers.size() <= 1) {
mapper.toXContent(builder, params); 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(); builder.endObject();