diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java index 343d3a407d0..5d0d77fb6de 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java @@ -154,9 +154,6 @@ public class StringFieldMapper extends FieldMapper implements AllFieldMapper.Inc throw new IllegalArgumentException("Can't parse [index] value [" + index + "] for field [" + fieldName + "], expected [true], [false], [no], [not_analyzed] or [analyzed]"); } } - builder.fieldType().setIndexAnalyzer(parserContext.analysisService().defaultIndexAnalyzer()); - builder.fieldType().setSearchAnalyzer(parserContext.analysisService().defaultSearchAnalyzer()); - builder.fieldType().setSearchQuoteAnalyzer(parserContext.analysisService().defaultSearchQuoteAnalyzer()); parseTextField(builder, fieldName, node, parserContext); for (Iterator> iterator = node.entrySet().iterator(); iterator.hasNext();) { Map.Entry entry = iterator.next(); @@ -174,6 +171,17 @@ public class StringFieldMapper extends FieldMapper implements AllFieldMapper.Inc throw new MapperParsingException("positions_increment_gap less than 0 aren't allowed."); } builder.positionIncrementGap(newPositionIncrementGap); + // we need to update to actual analyzers if they are not set in this case... + // so we can inject the position increment gap... + if (builder.fieldType().indexAnalyzer() == null) { + builder.fieldType().setIndexAnalyzer(parserContext.analysisService().defaultIndexAnalyzer()); + } + if (builder.fieldType().searchAnalyzer() == null) { + builder.fieldType().setSearchAnalyzer(parserContext.analysisService().defaultSearchAnalyzer()); + } + if (builder.fieldType().searchQuoteAnalyzer() == null) { + builder.fieldType().setSearchQuoteAnalyzer(parserContext.analysisService().defaultSearchQuoteAnalyzer()); + } iterator.remove(); } else if (propName.equals("ignore_above")) { builder.ignoreAbove(XContentMapValues.nodeIntegerValue(propNode, -1));