Return-Path: Delivered-To: apmail-lucene-solr-user-archive@minotaur.apache.org Received: (qmail 326 invoked from network); 1 Jun 2010 23:14:09 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 1 Jun 2010 23:14:09 -0000 Received: (qmail 56070 invoked by uid 500); 1 Jun 2010 23:14:07 -0000 Delivered-To: apmail-lucene-solr-user-archive@lucene.apache.org Received: (qmail 55902 invoked by uid 500); 1 Jun 2010 23:14:07 -0000 Mailing-List: contact solr-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: solr-user@lucene.apache.org Delivered-To: mailing list solr-user@lucene.apache.org Received: (qmail 55894 invoked by uid 99); 1 Jun 2010 23:14:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Jun 2010 23:14:07 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [208.69.42.181] (HELO radix.cryptio.net) (208.69.42.181) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Jun 2010 23:14:00 +0000 Received: by radix.cryptio.net (Postfix, from userid 1007) id B821471C133; Tue, 1 Jun 2010 16:13:38 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by radix.cryptio.net (Postfix) with ESMTP id B4EC371C106 for ; Tue, 1 Jun 2010 16:13:38 -0700 (PDT) Date: Tue, 1 Jun 2010 16:13:38 -0700 (PDT) From: Chris Hostetter To: solr-user@lucene.apache.org Subject: Re: Help me understand query syntax of subqueries In-Reply-To: Message-ID: References: User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Checked: Checked by ClamAV on apache.org : Any idea why this query returns 0 records: : "sexual assault" AND (-obama) : while this one returns 1400 ? : "sexual assault" AND -(obama) in the first one, the parans create a boolean query consisting of a single negated clause -- but pure negative boolean queries (ie: boolean queries were every clause is negated) by definition can't match anything -- and then you say in your outermost query that that boolean query (that matches nothing) must match (because it's part of an "AND") this is expalined in your debugging info... : "sexual assault" AND (-obama), translates to: +text:"sexual assault" : +(-text:obama), returns 0 records In the second query, the negation applies to the entire boolean query -- since it contains one positive clause it's optimized away, also visible in your debugging info... : "sexual assault" AND -(obama), translates to: +text:"sexual assault" : -text:obama, returns 1400 records : (-obama), translates to: -text:obama, returns 716295 records : -(obama), translates to: -text:obama, returns 716295 records ...this is because at the "top level" Solr does allow "pure negative" queries by inverting the search for you -- but it can't do that for sub queries. -Hoss