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 Patrick Duc <pa...@yahoo.fr> on 2013/11/08 16:33:56 UTC

Unexpected query result

I'm using Solr 4.4.0 running on Tomcat 7.0.29. The solrconfig.xlm is
as-delivered (excepted for the Solr home directory of course). I could pass
on the schema.xml, though I doubt this would help much, as the following
will show.

If I select all documents containing "russia" in the text, which is the
default field, ie if I execute the query "russia", I find only 1 document,
which is correct.

If I select all documents containing "web" in the text ("web"), the result
is 29, which is also correct.

If I search for all documents that do not contain "russia" ("NOT(russia)"),
the result is still correct (202).

If I search for all documents that contain "web" and do not contain "russia"
("web AND NOT(russia)"), the result is, once again, correct (28, because the
document containing "russia" also contains "web").

But if I search for all documents that contain "web" or do not contain
"russia" ("web OR NOT(russia)"), the result is still 28, though I should get
203 matches (the whole set).

Has anyone got an explanation ??

For information, the AND and OR work correctly if I don't use a NOT
somewhere in the query, i.e. : "web AND russia" --> OK "web OR russia" -->
OK



--
View this message in context: http://lucene.472066.n3.nabble.com/Unexpected-query-result-tp4100006.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Unexpected query result

Posted by Patrick Duc <pa...@yahoo.fr>.
Thank you for your very quick reply - and for your solution, that works
perfectly well.

Still, I wonder why this simple and straightforward syntax "web OR
NOT(russia)" needs some translation to be processed correctly...
>From the many related posts I read before asking my question, I know that
I'm not the first one to be puzzled by this behavior. Wouldn't it be a good
idea to modify the (Lucene, I guess ?) parser so that the subsequent
processing would produce a correct result ?

Thanks again for your help !



--
View this message in context: http://lucene.472066.n3.nabble.com/Unexpected-query-result-tp4100006p4100015.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Unexpected query result

Posted by Erick Erickson <er...@gmail.com>.
Good blog on the fact that Solr/Lucene query language is
not strict boolean logic, and why:
http://searchhub.org/dev/2011/12/28/why-not-and-or-and-not/

Best,
Erick


On Fri, Nov 8, 2013 at 10:45 AM, Yonik Seeley <yo...@heliosearch.com> wrote:

> On Fri, Nov 8, 2013 at 10:33 AM, Patrick Duc <pa...@yahoo.fr> wrote:
> > "russia" ("web OR NOT(russia)"
>
> russia (web (*:* -russia))
>
> Negative clauses often need something positive to subtract from... so
> replace "NOT russia" with "(*:* -russia)"
>
> -Yonik
> http://heliosearch.com -- making solr shine
>

Re: Unexpected query result

Posted by Yonik Seeley <yo...@heliosearch.com>.
On Fri, Nov 8, 2013 at 10:33 AM, Patrick Duc <pa...@yahoo.fr> wrote:
> "russia" ("web OR NOT(russia)"

russia (web (*:* -russia))

Negative clauses often need something positive to subtract from... so
replace "NOT russia" with "(*:* -russia)"

-Yonik
http://heliosearch.com -- making solr shine