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;
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentParser.Token;
|
||||
import org.elasticsearch.index.analysis.ShingleTokenFilterFactory;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.script.CompiledScript;
|
||||
import org.elasticsearch.search.suggest.SuggestContextParser;
|
||||
|
@ -180,9 +181,17 @@ public final class PhraseSuggestParser implements SuggestContextParser {
|
|||
if (suggestion.getField() == null) {
|
||||
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() + "]");
|
||||
} 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) {
|
||||
|
@ -190,7 +199,7 @@ public final class PhraseSuggestParser implements SuggestContextParser {
|
|||
}
|
||||
|
||||
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) {
|
||||
// try to detect the shingle size
|
||||
if (shingleFilterFactory != null) {
|
||||
|
|
Loading…
Reference in New Issue