Lucene 不敏感的空白分析器?
我使用 lucene 进行搜索,对于标签,我使用空白分析器。看起来它存储得很好。使用标准分析器,我的“C#”搜索将产生 C、C++ 的结果。我尝试过的每个分析器(我没有尝试过所有)都会这样做,除了空白分析器。这很好,除非我搜索 c# 我没有得到任何结果(我使用小写 C 而不是大写)。如果我搜索诸如“Lucene 不敏感空白分析器?”之类的标题,这会很烦人。当它恰好是“Lucene 不敏感空白分析器?”时。 (请注意,前 3 个单词以 upper 开头,最后一个单词与我的搜索中一个 upper 和 all lower 的搜索结果不同)。
如何制作不敏感的空白分析器?注意:WhitespaceAnalyzer 是密封的。
I am using lucene for searching and with tags i use the whitespace analyzer. It looks like its stored properly. With standard analyzer my 'C#' search will yield results for C, C++. Every analyzer i tried (i havent tried all) does this except for whitespace analyzer. This is fine except if i search c# i get no results (i'm using a lowercase C instead of uppercase). This is annoying if i search a title such as "Lucene insensitive whitespace analyzer?" when it happens to be "Lucene Insensitive Whitespace analyzer?". (Note the first 3 words start with upper and the last doesnt compared to my search with one upper and all lower).
How do i make an insensitive whitespace analyzer? Note: WhitespaceAnalyzer is sealed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试将 LowerCaseFilter 与 WhitespaceTokenizer 结合使用:
http ://lucene.apache.org/java/3_0_0/api/core/org/apache/lucene/analysis/LowerCaseFilter.html
http://lucene.apache.org/java/3_0_0/api/core/org/apache/lucene/analysis/WhitespaceTokenizer .html
Try using LowerCaseFilter in conjunction with WhitespaceTokenizer:
http://lucene.apache.org/java/3_0_0/api/core/org/apache/lucene/analysis/LowerCaseFilter.html
http://lucene.apache.org/java/3_0_0/api/core/org/apache/lucene/analysis/WhitespaceTokenizer.html
您可以创建一个自定义分析器,如下所示(以 Lucene 版本 4.10.4 为例),
并且您可以在索引时使用该分析器来配置索引编写器,并在搜索时使用它来创建查询解析器。
You can create a custom analyzer as below (for Lucene version 4.10.4 as an example)
And you can use the analyzer to config your index writer when indexing, and also use it to create your query parser when searching.
这是一个非常适合我的用例的 C# 版本。
Here's a C# version that works well for my use case.