I am currently unsure of the behavior of QueryParser and TermQuery in Lucene; I am using Lucene 3.6.
In my example, I will try the following examples at the same index, where the specified field is specified in Field.Store.NOand Field.Index.NOT_ANALYZED_NO_NORMS.
Query q1 = new TermQuery(new Term("names", "test three"));
QueryParser q2p = new QueryParser(GenericIndexer.LUCENE_VERSION, "names", someAnalyzer);
Query q2 = q2p.parse("names:test three");
Query q3 = q2p.parse("names:\"test three\"");
In both cases q2, q3I cannot reproduce the same syntax as q1; Having printed out the requests, I see that:
- q1 =
names:test three - q2 =
names:test names:three - q3 =
names:"test three"
Because of these differences query q2and q3returns no results and query q1returns the expected result.
Question . Is there a way for the query analyzer to play the same query as TermQuery, or am I missing some basic Lucene concepts here?
. QueryParser , , , .