ftk*_*tkg 8 lucene full-text-search hibernate hibernate-search
这是Lucene的新手.我在Java客户端中使用Hibernate,并且在特定查询中遇到此错误:
HSEARCH000146: The query string 'a' applied on field 'name' has no meaningfull tokens to
be matched. Validate the query input against the Analyzer applied on this field.
Run Code Online (Sandbox Code Playgroud)
搜索适用于所有其他查询,即使是空结果集.我的测试数据库确实记录了'a'.这可能有什么问题?
'a'是一个停用词,将由StandardAnalyzer过滤掉您的查询.停用词是您搜索的语言中常见的单词,对于生成搜索结果不具有意义.这是一个简短的清单,但'a'是英语中的一个.
由于分析器已经摆脱了该术语,并且它是唯一存在的术语,因此您现在发送一个空查询,这是不可接受的,并且搜索失败.
对于好奇,这些是标准的Lucene英语关键词:
"a", "an", "and", "are", "as", "at", "be", "but", "by",
"for", "if", "in", "into", "is", "it",
"no", "not", "of", "on", "or", "such",
"that", "the", "their", "then", "there", "these",
"they", "this", "to", "was", "will", "with"
Run Code Online (Sandbox Code Playgroud)
如果你不想删除停用词,那么你应该设置你Analyzer没有StopFilter,或者设置一个空的停止词.在这种情况下StandardAnalyzer,您可以将自定义停止集传递给构造函数:
Analyzer analyzer = new StandardAnalyzer(CharArraySet.EMPTY_SET);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3110 次 |
| 最近记录: |