You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by electroyou <el...@gmail.com> on 2011/09/09 16:43:35 UTC

Weird behaviors with not operators.

Hi all.
I'm crashing into a weird behavior with - operators.
If I execute the query
-text AND -text
I get all expected results (lot), but if I put some parenthesis like
-text AND (-text)
or
(-text) AND (-text)
then I get no results at all. I can't understand why.
Do you have an explanation for this behavior?

Thank you in advance.

--
View this message in context: http://lucene.472066.n3.nabble.com/Weird-behaviors-with-not-operators-tp3323065p3323065.html
Sent from the Solr - User mailing list archive at Nabble.com.

RE: Weird behaviors with not operators.

Posted by electroyou <el...@gmail.com>.
Thank you a lot for your answers! They help me to understand better how query
parser works.

--
View this message in context: http://lucene.472066.n3.nabble.com/Weird-behaviors-with-not-operators-tp3323065p3335087.html
Sent from the Solr - User mailing list archive at Nabble.com.

RE: Weird behaviors with not operators.

Posted by Patrick Sauts <pa...@gmail.com>.
I mean it's a known bug.

Hostetter  AND (-chris *:*) 

Should do the trick.
Depending on your request.

NAME:(-chris *:*)

-----Original Message-----
From: Patrick Sauts [mailto:patrick.viadeo@gmail.com] 
Sent: Monday, September 12, 2011 3:57 PM
To: solr-user@lucene.apache.org
Subject: RE: Weird behaviors with not operators.

Maybe this will answer your question
http://wiki.apache.org/solr/FAQ

Why does 'foo AND -baz' match docs, but 'foo AND (-bar)' doesn't ?

Boolean queries must have at least one "positive" expression (ie; MUST or
SHOULD) in order to match. Solr tries to help with this, and if asked to
execute a BooleanQuery that does contains only negatived clauses _at the
topmost level_, it adds a match all docs query (ie: *:*)

If the top level BoolenQuery contains somewhere inside of it a nested
BooleanQuery which contains only negated clauses, that nested query will not
be modified, and it (by definition) an't match any documents -- if it is
required, that means the outer query will not match.

More Detail:

    *      https://issues.apache.org/jira/browse/SOLR-80
    *
https://mail-archives.apache.org/mod_mbox/lucene-solr-user/201006.mbox/%3Cal
pine.DEB.1.10.1006011609080.29455@radix.cryptio.net%3E


Patrick.
-----Original Message-----
From: Chris Hostetter [mailto:hossman_lucene@fucit.org]
Sent: Monday, September 12, 2011 3:04 PM
To: solr-user@lucene.apache.org
Subject: Re: Weird behaviors with not operators.


: I'm crashing into a weird behavior with - operators.

I went ahead and added a FAQ on this using some text from a previous nearly
identical email ...

https://wiki.apache.org/solr/FAQ#Why_does_.27foo_AND_-baz.27_match_docs.2C_b
ut_.27foo_AND_.28-bar.29.27_doesn.27t_.3F

please reply if you have followup questions.


-Hoss



RE: Weird behaviors with not operators.

Posted by Patrick Sauts <pa...@gmail.com>.
Maybe this will answer your question
http://wiki.apache.org/solr/FAQ

Why does 'foo AND -baz' match docs, but 'foo AND (-bar)' doesn't ?

Boolean queries must have at least one "positive" expression (ie; MUST or
SHOULD) in order to match. Solr tries to help with this, and if asked to
execute a BooleanQuery that does contains only negatived clauses _at the
topmost level_, it adds a match all docs query (ie: *:*)

If the top level BoolenQuery contains somewhere inside of it a nested
BooleanQuery which contains only negated clauses, that nested query will not
be modified, and it (by definition) an't match any documents -- if it is
required, that means the outer query will not match.

More Detail:

    *      https://issues.apache.org/jira/browse/SOLR-80
    *
https://mail-archives.apache.org/mod_mbox/lucene-solr-user/201006.mbox/%3Cal
pine.DEB.1.10.1006011609080.29455@radix.cryptio.net%3E


Patrick.
-----Original Message-----
From: Chris Hostetter [mailto:hossman_lucene@fucit.org] 
Sent: Monday, September 12, 2011 3:04 PM
To: solr-user@lucene.apache.org
Subject: Re: Weird behaviors with not operators.


: I'm crashing into a weird behavior with - operators.

I went ahead and added a FAQ on this using some text from a previous nearly
identical email ...

https://wiki.apache.org/solr/FAQ#Why_does_.27foo_AND_-baz.27_match_docs.2C_b
ut_.27foo_AND_.28-bar.29.27_doesn.27t_.3F

please reply if you have followup questions.


-Hoss


Re: Weird behaviors with not operators.

Posted by Chris Hostetter <ho...@fucit.org>.
: I'm crashing into a weird behavior with - operators.

I went ahead and added a FAQ on this using some text from a previous 
nearly identical email ...

https://wiki.apache.org/solr/FAQ#Why_does_.27foo_AND_-baz.27_match_docs.2C_but_.27foo_AND_.28-bar.29.27_doesn.27t_.3F

please reply if you have followup questions.


-Hoss