Analysis: fix ignoring tokenizer settings in SynonymTokenFilterFactory
add test for synonym with tokenizer settings
This commit is contained in:
parent
41343eca95
commit
deeea217e1
|
@ -33,6 +33,7 @@ import org.elasticsearch.common.inject.Inject;
|
|||
import org.elasticsearch.common.inject.assistedinject.Assisted;
|
||||
import org.elasticsearch.common.io.FastStringReader;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.index.Index;
|
||||
|
@ -80,7 +81,8 @@ public class SynonymTokenFilterFactory extends AbstractTokenFilterFactory {
|
|||
if (tokenizerFactoryFactory == null) {
|
||||
throw new ElasticsearchIllegalArgumentException("failed to find tokenizer [" + tokenizerName + "] for synonym token filter");
|
||||
}
|
||||
final TokenizerFactory tokenizerFactory = tokenizerFactoryFactory.create(tokenizerName, indexSettings);
|
||||
|
||||
final TokenizerFactory tokenizerFactory = tokenizerFactoryFactory.create(tokenizerName, ImmutableSettings.builder().put(indexSettings).put(settings).build());
|
||||
|
||||
Analyzer analyzer = new Analyzer() {
|
||||
@Override
|
||||
|
|
|
@ -83,6 +83,7 @@ public class SynonymsAnalysisTest extends ElasticsearchTestCase {
|
|||
match("synonymAnalyzer_file", "kimchy is the dude abides", "shay is the elasticsearch man!");
|
||||
match("synonymAnalyzerWordnet", "abstain", "abstain refrain desist");
|
||||
match("synonymAnalyzerWordnet_file", "abstain", "abstain refrain desist");
|
||||
match("synonymAnalyzerWithsettings", "kimchy", "sha hay");
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,17 @@
|
|||
"synonymAnalyzerWordnet_file":{
|
||||
"tokenizer":"standard",
|
||||
"filter":[ "synonymWordnet_file" ]
|
||||
},
|
||||
"synonymAnalyzerWithsettings":{
|
||||
"tokenizer":"trigram",
|
||||
"filter":["synonymWithTokenizerSettings"]
|
||||
}
|
||||
},
|
||||
"tokenizer":{
|
||||
"trigram" : {
|
||||
"type" : "ngram",
|
||||
"min_gram" : 3,
|
||||
"max_gram" : 3
|
||||
}
|
||||
},
|
||||
"filter":{
|
||||
|
@ -45,6 +56,15 @@
|
|||
"type":"synonym",
|
||||
"format":"wordnet",
|
||||
"synonyms_path":"org/elasticsearch/index/analysis/synonyms/synonyms_wordnet.txt"
|
||||
},
|
||||
"synonymWithTokenizerSettings":{
|
||||
"type":"synonym",
|
||||
"synonyms":[
|
||||
"kimchy => shay"
|
||||
],
|
||||
"tokenizer" : "trigram",
|
||||
"min_gram" : 3,
|
||||
"max_gram" : 3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue