You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by wburzyns <wo...@gmail.com> on 2012/03/04 21:40:21 UTC

PrecedenceQueryParser vs. QueryParser discrepancy

Hi devs,

There is a discrepancy in parsing behavior between PrecedenceQueryParser 
and QueryParser if the query is both single term and negative-only, e.g. 
"-exchange:nasdaq".

In this case with QueryParser the returned Query object is instanceof 
BooleanQuery whereas with PrecedenceQueryParser it's of TermQuery 
instance. This is inconvenient since with the parsed query which is an 
instance of BooleanQuery class it's easy to check if the user-supplied 
query is negative only. This is not possible with TermQuery. This also 
means that the PrecedenceQueryParser parses "-exchange:nasdaq" to 
"+exchange:nasdaq". What's interesting, there is no such problem with 
negative-only queries consisting of at least two terms.

Is the above behavior a "feature" of the contrib parser or a bug?


Thanks,
Wojtek Burzynski

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org