: > 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