在 Luke 中,如果我输入搜索表达式docfile:Tomatoes.jpg*
,则解析后的查询是docfile:Tomatoes.jpg*
. 当搜索表达式为docfile:Tomatoes.jpg
,(无星号 *)时,解析后的查询docfile:tomatoes.jpg
带有小写的 't'。
- 为什么?
- 我怎样才能改变这个?
顺便说一句,使用 org.apache.lucene.analysis.standard.StandardAnalyzer。
StandardAnalyzer
使用LowerCaseFilter
这意味着它将您的查询和数据小写。这在 Javadocs http://lucene.apache.org/java/3_0_1/api/core/org/apache/lucene/analysis/standard/StandardAnalyzer.html中有描述。
如果我没记错的话WhitespaceAnalyzer
不小写,但验证它是否适合您的需求http://lucene.apache.org/java/3_0_1/api/core/org/apache/lucene/analysis/WhitespaceAnalyzer.html。
对于 Lucene 5.3.0,使用 SimpleAnalyzer 解决了这个问题。
例子:
Analyzer analyzer = new org.apache.lucene.analysis.core.SimpleAnalyzer();
最后,使用相同的分析器来构建索引和搜索。