'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);