diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/analysis/FieldNameAnalyzer.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/analysis/FieldNameAnalyzer.java index b9b387ea82c..8404112c2e9 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/analysis/FieldNameAnalyzer.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/analysis/FieldNameAnalyzer.java @@ -21,6 +21,7 @@ package org.elasticsearch.index.analysis; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; +import org.apache.lucene.document.Fieldable; import org.elasticsearch.common.collect.ImmutableMap; import java.io.IOException; @@ -53,6 +54,10 @@ public class FieldNameAnalyzer extends Analyzer { return getAnalyzer(fieldName).getPositionIncrementGap(fieldName); } + @Override public int getOffsetGap(Fieldable field) { + return getAnalyzer(field.name()).getOffsetGap(field); + } + private Analyzer getAnalyzer(String name) { Analyzer analyzer = analyzers.get(name); if (analyzer != null) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/MapperService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/MapperService.java index 9a0cb0878a4..cee5b550428 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/MapperService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/MapperService.java @@ -21,6 +21,7 @@ package org.elasticsearch.index.mapper; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; +import org.apache.lucene.document.Fieldable; import org.elasticsearch.common.collect.ImmutableMap; import org.elasticsearch.common.collect.UnmodifiableIterator; import org.elasticsearch.common.inject.Inject; @@ -380,14 +381,57 @@ public class MapperService extends AbstractIndexComponent implements Iterable