我想构建自己的分析器,同时使用过滤器/标记器.
I want to build my own analyzer that uses both filters/tokenizers.
我的意思是,相同的字段是 Keyword(整个流作为单个标记)和小写
I mean, the same field is Keyword (entire stream as a single token) and lowercase
如果 KeywordAnalyzer仅使用,字段的值不区分大小写.如果我使用 LowerCaseTokenizer 或LowerCaseFilter 我要结合它们与其他执行相同操作的分析器 KeywordAnalyzer(不使用字母、空格、删除停用词等分隔)
If KeywordAnalyzer use only, the value of field keeps the case-insensitive. If I use LowerCaseTokenizer or LowerCaseFilter I have to combine them with other analyzers that do the same thing KeywordAnalyzer (separated by no letter, by spaces, remove stop-words, etc.)
问题是:有没有办法使用过滤器或分析器 Lucene 或标记器将该字段设为关键字(将整个流作为单个标记)和 小写?
The question is: Is there any way to make that field as Keyword (entire stream as a single token) and that lowercase using filters or analyzers Lucene or tokenizers?
(谷歌翻译,错误见谅)
(google translated, sorry about errors)
这应该可行:
public final class YourAnalyzer extends ReusableAnalyzerBase {
@Override
protected TokenStreamComponents createComponents(final String fieldName, final Reader reader) {
final TokenStream source = new KeywordTokenizer(reader);
return new TokenStreamComponents(source, new LowercaseFilter(Version.LUCENE_36, source));
}
}
这篇关于KeywordAnalyzer 和 LowerCaseFilter/LowerCaseTokenizer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!