Mappings: Remove fieldSearchAnalyzer and fieldSearchQuoteAnalyzer from
MapperService. Instead, get the FieldMapper for the field and check the analyzer there.
This commit is contained in:
parent
c29c18f0f2
commit
48bc132927
|
@ -905,15 +905,6 @@ public class MapperService extends AbstractIndexComponent {
|
||||||
return this.searchQuoteAnalyzer;
|
return this.searchQuoteAnalyzer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Analyzer fieldSearchAnalyzer(String field) {
|
|
||||||
return this.searchAnalyzer.getWrappedAnalyzer(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Analyzer fieldSearchQuoteAnalyzer(String field) {
|
|
||||||
return this.searchQuoteAnalyzer.getWrappedAnalyzer(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves the closest inherited {@link ObjectMapper} that is nested.
|
* Resolves the closest inherited {@link ObjectMapper} that is nested.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
||||||
import org.elasticsearch.index.analysis.ShingleTokenFilterFactory;
|
import org.elasticsearch.index.analysis.ShingleTokenFilterFactory;
|
||||||
|
import org.elasticsearch.index.mapper.FieldMapper;
|
||||||
import org.elasticsearch.index.mapper.MapperService;
|
import org.elasticsearch.index.mapper.MapperService;
|
||||||
import org.elasticsearch.script.CompiledScript;
|
import org.elasticsearch.script.CompiledScript;
|
||||||
import org.elasticsearch.search.suggest.SuggestContextParser;
|
import org.elasticsearch.search.suggest.SuggestContextParser;
|
||||||
|
@ -181,8 +182,16 @@ public final class PhraseSuggestParser implements SuggestContextParser {
|
||||||
throw new ElasticsearchIllegalArgumentException("The required field option is missing");
|
throw new ElasticsearchIllegalArgumentException("The required field option is missing");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mapperService.smartNameFieldMapper(suggestion.getField()) == null) {
|
FieldMapper fieldMapper = mapperService.smartNameFieldMapper(suggestion.getField());
|
||||||
|
if (fieldMapper == null) {
|
||||||
throw new ElasticsearchIllegalArgumentException("No mapping found for field [" + suggestion.getField() + "]");
|
throw new ElasticsearchIllegalArgumentException("No mapping found for field [" + suggestion.getField() + "]");
|
||||||
|
} else if (suggestion.getAnalyzer() == null) {
|
||||||
|
// no analyzer name passed in, so try the field's analyzer, or the default analyzer
|
||||||
|
if (fieldMapper.searchAnalyzer() == null) {
|
||||||
|
suggestion.setAnalyzer(mapperService.searchAnalyzer());
|
||||||
|
} else {
|
||||||
|
suggestion.setAnalyzer(fieldMapper.searchAnalyzer());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (suggestion.model() == null) {
|
if (suggestion.model() == null) {
|
||||||
|
@ -190,7 +199,7 @@ public final class PhraseSuggestParser implements SuggestContextParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gramSizeSet || suggestion.generators().isEmpty()) {
|
if (!gramSizeSet || suggestion.generators().isEmpty()) {
|
||||||
final ShingleTokenFilterFactory.Factory shingleFilterFactory = SuggestUtils.getShingleFilterFactory(suggestion.getAnalyzer() == null ? mapperService.fieldSearchAnalyzer(suggestion.getField()) : suggestion.getAnalyzer()); ;
|
final ShingleTokenFilterFactory.Factory shingleFilterFactory = SuggestUtils.getShingleFilterFactory(suggestion.getAnalyzer());
|
||||||
if (!gramSizeSet) {
|
if (!gramSizeSet) {
|
||||||
// try to detect the shingle size
|
// try to detect the shingle size
|
||||||
if (shingleFilterFactory != null) {
|
if (shingleFilterFactory != null) {
|
||||||
|
|
Loading…
Reference in New Issue