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 Sonu SR <so...@gmail.com> on 2007/07/30 17:49:27 UTC

Question regarding boolean query

Hi,

    I am getting different results for the following queries.

   1. ABST:"spring-elastic"^3 AND SPEC:"internal combustion"^2 OR
ABST:"cylinder"^3
   2. SPEC:"internal combustion"^2 AND ABST:"spring-elastic"^3 OR
ABST:"cylinder"^3

I think the above two queries are similar and will give the same results.
I want to know the order of boolean operators. Is there any grouping is
applied when fields repeats in the query?

By applying the queries to lucene QueryParser, I got the results as

   1. +ABST:"spring elastic"^3.0 SPEC:"internal combustion"^2.0ABST:cylinder^
3.0
   2. +SPEC:"internal combustion"^2.0 ABST:"spring elastic"^3.0ABST:cylinder^
3.0

I have set the QueryParser operator as 'AND'.  I was confused by looking on
the QueryParser output.
Please give me a good explanation, how lucene handling the boolean queries.

Thanks,
Sonu

RE: Question regarding boolean query

Posted by Renaud Waldura <re...@library.ucsf.edu>.
Yeah, it's a surprise, isn't it? I'm afraid there isn't a good answer.

http://wiki.apache.org/lucene-java/BooleanQuerySyntax

The "best practice" appears to be to require parens everywhere to force the
evaluation order. Not very satisfying, but it does work 100%.



-----Original Message-----
From: Sonu SR [mailto:sonusr@gmail.com] 
Sent: Monday, July 30, 2007 8:49 AM
To: java-user@lucene.apache.org
Subject: Question regarding boolean query

Hi,

    I am getting different results for the following queries.

   1. ABST:"spring-elastic"^3 AND SPEC:"internal combustion"^2 OR
ABST:"cylinder"^3
   2. SPEC:"internal combustion"^2 AND ABST:"spring-elastic"^3 OR
ABST:"cylinder"^3

I think the above two queries are similar and will give the same results.
I want to know the order of boolean operators. Is there any grouping is
applied when fields repeats in the query?

By applying the queries to lucene QueryParser, I got the results as

   1. +ABST:"spring elastic"^3.0 SPEC:"internal
combustion"^2.0ABST:cylinder^ 3.0
   2. +SPEC:"internal combustion"^2.0 ABST:"spring
elastic"^3.0ABST:cylinder^ 3.0

I have set the QueryParser operator as 'AND'.  I was confused by looking on
the QueryParser output.
Please give me a good explanation, how lucene handling the boolean queries.

Thanks,
Sonu



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