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 Otis Gospodnetic <ot...@yahoo.com> on 2004/01/23 19:16:43 UTC

Re: Query madness with NOTs...

Redirecting to lucene-user....

--- Jim Hargrave <Ha...@ldschurch.org> wrote:
> Can anyone tell me why these two queries would produce different
> results:
>  
> +A -B
>  
> A -(-B) 

A and +A are not the same thing when you have multiple terms in a
query.

> Also, we are having a hard time understanding why the Query parser
> takes this
> query: "A AND NOT B" and returns this "+A +(-B)". Shouldn't this be
> "+A -B"?

Maybe it should.  QueryParser is not the smartest piece of code,
unfortunately, and this issue has been discussed several times before. 
It looks like QP is just translating things 'nicely' left to right and
not looking for 'AND NOT' and turning that into '-'.

Otis

 The
> first gives incorrect results, the later works as expected.
>  
>  
> Jim 
>  
>  
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

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


Re: Query madness with NOTs...

Posted by Morus Walter <mo...@gmx.de>.
Otis Gospodnetic writes:
> Redirecting to lucene-user....
> 
> --- Jim Hargrave <Ha...@ldschurch.org> wrote:
> > Can anyone tell me why these two queries would produce different
> > results:
> >  
> > +A -B
> >  
> > A -(-B) 
> 
> A and +A are not the same thing when you have multiple terms in a
> query.
> 
Hmm. As far as I understood boolean queries so far
a -b and +a -b 
should be the same (while a b -c and +a +b -c are different of course).

a -(-b) on the other side contains a boolean query only searching for -b.
Lucene can not handle this type of query. I'm not sure what happens in this
case. But AFAIK you should never use a boolean query containing only 
prohibited terms in a query. 
If I test this, I don't get any results for a -(-b) and the same result
for 'a' and 'a +(-b)'.
The query parser patch I added yesterday to bugzilla, drops such queries.

> > Also, we are having a hard time understanding why the Query parser
> > takes this
> > query: "A AND NOT B" and returns this "+A +(-B)". Shouldn't this be
> > "+A -B"?
> 
a AND NOT b IS parsed to +a -b by lucenes standard query parser.
Don't know where you found +a +(-b).

+a +(-b) would be wrong in the above sense.

Morus

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