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 David Benson <da...@wallst.com> on 2010/08/09 00:01:17 UTC

Solr 1.4.1 and 3x: Grouping of query changes results

I'm seeing what I believe to be a logic error in the processing of a query.

Returns document 1234 as expected:
id:1234 AND -indexid:1 AND -indexid:2 AND -indexid:3

Does not return document as expected:
id:1234 AND (-indexid:1 AND -indexid:2) AND -indexid:3

Has anyone else experienced this? The exact placement of the parens isn't key, just adding a level of nesting changes the query results.

Thanks,

David

Re: Solr 1.4.1 and 3x: Grouping of query changes results

Posted by Chris Hostetter <ho...@fucit.org>.
: > Does not return document as expected:
: > id:1234 AND (-indexid:1 AND -indexid:2) AND -indexid:3
: > 
: > Has anyone else experienced this? The exact placement of the parens isn't
: > key, just adding a level of nesting changes the query results.
	...
: I could be wrong but I think this has to do with Solr's lack of support for
: purely negative queries, try the following and see if it behaves correctly:
: 
: id:1234 AND (*:* AND -indexid:1 AND -indexid:2) AND -indexid:3

1) correct.  In general a purely negative query can't work -- queries must 
select something, it doesn't matter if they are nested in another query or 
not.

the query string "A AND (-B AND -C) AND -D" says that a document must 
match A and it must match "a query which does not match anything" and it 
must not match D ... it's thta middle clause that prevents anything from 
matching.

Solr does support purely negative queries if they are the "top level" 
query (ie: "q=-foo") but it doesn't rewrite nested sub queries (ie: "q=foo 
(-bar -baz)")

2) FWIW: setting asside the pure negative query aspect of this question, 
changing the grouping of clauses can always affect the results of a query 
-- this is because the grouping dictates the scoring (due to queryNorms 
and coord factors) so "A (B C (D E)) F" can produce very results in a very 
different order then "A B C D E F" ... likewise "A C -B" will match 
different documents then "A (C -B)"  (the latter will match a document 
containing both A and B, the former will not)


-Hoss


Re: Solr 1.4.1 and 3x: Grouping of query changes results

Posted by gwk <gi...@eyefi.nl>.
On 8/9/2010 12:01 AM, David Benson wrote:
> I'm seeing what I believe to be a logic error in the processing of a query.
>
> Returns document 1234 as expected:
> id:1234 AND -indexid:1 AND -indexid:2 AND -indexid:3
>
> Does not return document as expected:
> id:1234 AND (-indexid:1 AND -indexid:2) AND -indexid:3
>
> Has anyone else experienced this? The exact placement of the parens isn't key, just adding a level of nesting changes the query results.
>
> Thanks,
>
> David
>    

Hi,

I could be wrong but I think this has to do with Solr's lack of support 
for purely negative queries, try the following and see if it behaves 
correctly:

id:1234 AND (*:* AND -indexid:1 AND -indexid:2) AND -indexid:3

Regards,

gwk