lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Heisey <apa...@elyograg.org>
Subject Re: Problem with queries that includes NOT
Date Wed, 25 Feb 2015 12:23:02 GMT
On 2/25/2015 4:04 AM, david.davila@correo.aeat.es wrote:
> We have problems with some queries. All of them include the tag NOT, and 
> in my opinion, the results donĀ“t make any sense.
> 
> First problem:
> 
> This query " NOT Proc:ID01 "   returns   95806 results, however this one "
> NOT Proc:ID01 OR FileType:PDF_TEXT" returns  11484 results. But it's 
> impossible that adding a tag OR the query has less number of results.
> 
> Second problem. Here the problem is because of the brackets and the NOT 
> tag:
> 
>  This query:
> 
> (NOT Proc:"ID01" AND NOT FileType:PDF_TEXT) AND sys_FileType:PROTOTIPE 
> returns 0 documents.
> 
> But this query:
> 
> (NOT Proc:"ID01" AND NOT FileType:PDF_TEXT AND sys_FileType:PROTOTIPE) 
> returns 53 documents, which is correct. So, the problem is the position of 
> the bracket. I have checked the same query without NOTs, and it works fine 
> returning the same number of results in both cases.  So, I think the 
> problem is the combination of the bracket positions and the NOT tag.

For the first query, there is a difference between "NOT condition1 OR
condition2" and "NOT (condition1 OR condition2)" ... I can imagine the
first one increasing the document count compared to just "NOT
condition1" ... the second one wouldn't increase it.

Boolean queries in Solr (and very likely Lucene as well) do not always
do what people expect.

http://robotlibrarian.billdueber.com/2011/12/solr-and-boolean-operators/
https://lucidworks.com/blog/why-not-and-or-and-not/

As mentioned in the second link above, you'll get better results if you
use the prefix operators with explicit parentheses.  One word of
warning, though -- the prefix operators do not work correctly if you
change the default operator to AND.

Thanks,
Shawn


Mime
View raw message