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:
If you don’t want stop words to be removed, then you should set up your
Analyzerwithout aStopFilter, or with an empty stop word set. In the case ofStandardAnalyzer, you are able to pass in a custom stop set to the constructor: