同義詞文件僅用於更改正在搜索的單詞。 所以,如果你寫
汽車配件=>加迪marmat
當「汽車配件」編譯器匹配,它試圖在「加迪marmat」
它就像一個單一的令牌
匹配
你可以得到很好的效果混合元素分析儀這樣的
@AnalyzerDef(name = "integram",
tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
filters = {
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
@TokenFilterDef(factory = StopFilterFactory.class, params = {
@Parameter(name = "words", value = "lucene/dictionary/stopwords.txt"),
@Parameter(name = "ignoreCase", value = "true"),
@Parameter(name = "enablePositionIncrements", value = "true")
}),
@TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = {
@Parameter(name = "language", value = "English")
}),
@TokenFilterDef(factory = SynonymFilterFactory.class, params = {
@Parameter(name = "synonyms", value = "lucene/dictionary/synonyms.txt"),
@Parameter(name = "expand", value = "false")
}),
@TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = {
@Parameter(name = "language", value = "English")
})
})
注:擴展設置爲true。 – zdesam
您是否嘗試過使用'/ admin/analysis.jsp'來查看令牌擴展是否按照您的預期運行? – beerbajay