获取特定查询的错误 [英] Getting error on a specific query

查看:125
本文介绍了获取特定查询的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里Lucene的新手。
在一个java客户端中,我将它与Hibernate一起使用,并且在特定的查询中得到了这个错误:

  HSEARCH000146:在字段'名称'上应用的查询字符串'a'没有任何意义完整标记与
匹配。根据应用于此字段的分析器验证查询输入。

即使使用空的结果集,搜索对所有其他查询也可以正常工作。
我的测试数据库确实有'a'的记录。这里有什么可能是错误的? 解决方案

'a'是一个停用词,将由StandardAnalyzer过滤出您的查询。停用词是在您搜索的语言中足够常见的词,并且不会对生成搜索结果有意义。这是一个简短的列表,但'a'是其中的一个英文名称。



由于分析器已经摆脱了这个术语,而且这是唯一存在的术语,现在正在发送一个空查询,这是不可接受的,并且搜索失败。



好奇的是,这些是标准的Lucene英语停用词:

 a,an,and,are,as,at,be,but,如果,在,到,是,它,
否,not,of,on ,或,这样的,
that,the,their,then,there,these,
they,this, to,was,will,with






如果您不想停止单词被删除,那么您应该在没有 StopFilter Analyzer c>,或者设置一个空的停止词。在 StandardAnalyzer 的情况下,您可以将自定义停止设置传递给构造函数

 分析仪分析仪=新的StandardAnalyzer(CharArraySet.EMPTY_SET); 


Novice on Lucene here. I'm using it with Hibernate in a java client, and have been getting this error on a particular query:

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.

Search works fine for all other queries, even with empty resultset. My testing DB does have this record with 'a'. What could be wrong here?

解决方案

'a' is a stopword, and will be filtered out of your query by the StandardAnalyzer. Stopwords are words which are common enough in the language your searching in, and are not deemed meaningful to generating search results. It's a short list, but 'a' is one of them in English.

Since the Analyzer has got rid of that term, and it was the only term present, you now are sending an empty query, which is not acceptable, and searching fails.

For the curious, these are the standard Lucene english stopwords:

"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"


If you don't want stop words to be removed, then you should set up your Analyzer without a StopFilter, or with an empty stop word set. In the case of StandardAnalyzer, you are able to pass in a custom stop set to the constructor:

Analyzer analyzer = new StandardAnalyzer(CharArraySet.EMPTY_SET);

这篇关于获取特定查询的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆