Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 96374 invoked from network); 12 Sep 2010 20:30:03 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 12 Sep 2010 20:30:03 -0000 Received: (qmail 82848 invoked by uid 500); 12 Sep 2010 20:30:01 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 82738 invoked by uid 500); 12 Sep 2010 20:30:00 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 82730 invoked by uid 99); 12 Sep 2010 20:30:00 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 12 Sep 2010 20:30:00 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of oren.liat@gmail.com designates 209.85.216.48 as permitted sender) Received: from [209.85.216.48] (HELO mail-qw0-f48.google.com) (209.85.216.48) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 12 Sep 2010 20:29:38 +0000 Received: by qwk3 with SMTP id 3so3573590qwk.35 for ; Sun, 12 Sep 2010 13:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=4VbwSMN8/CugZAdkpg3A0uGEHyPL3Zp+fpxS5mhfjUo=; b=tI0LZjNW/iHIkgrdCMDUeQGNj0QfRL+58SdbKiuBFMR97qokqOEPvJYfHFvBsAVMXZ sdWc7tvuD4jFyFhIZxgBdmqW1eECJqpaFD9nZF88ZzVgiTkbM0CPsXUqiyvRfiEfTWOY plTM/Qt/l4ZyFLlJwpt6dHShrrFem/K8W2IxI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=xWZmjELw29YomBg0IeMjDI9ZyaCoOpbdNPxp9YFqlOoQjL5posBkkNLBdoVvCvuKEB kQu212ZtUhZCaKc/rcsYor7uTId1hDpdTaWcVk2ERa6ou2//5bsuNnbMIPIsLgwWEk1z jKXFYf8rAeT42tBe0z+TYpIRvLt3MsHNgHQGY= MIME-Version: 1.0 Received: by 10.224.115.38 with SMTP id g38mr2202317qaq.281.1284323357753; Sun, 12 Sep 2010 13:29:17 -0700 (PDT) Received: by 10.229.212.20 with HTTP; Sun, 12 Sep 2010 13:29:17 -0700 (PDT) In-Reply-To: <004501cb5281$aacab020$00601060$@thetaphi.de> References: <004501cb5281$aacab020$00601060$@thetaphi.de> Date: Sun, 12 Sep 2010 23:29:17 +0300 Message-ID: Subject: Re: Unexpected Results - using should and must in boolean query From: liat oren To: java-user@lucene.apache.org Content-Type: multipart/alternative; boundary=00148502aee58401d5049015d5fa X-Virus-Checked: Checked by ClamAV on apache.org --00148502aee58401d5049015d5fa Content-Type: text/plain; charset=ISO-8859-1 Hi, Thanks for both of you for the answer. I will try the solution of Uwe, it looks like your suggestion will solve my problem. Many thanks, Liat On 12 September 2010 16:51, Uwe Schindler wrote: > Hi, > > I always recommend my customers to not mix should and must in the same > BooleanQuery if strict boolean matching is needed. It will match all docs, > containing the MUST clause and "boost" all SHOULD terms. > > If you have some MUST terms, but you also want to have at least one of a > list of other terms (like 5 SHOULD clauses), the trick is to separate both: > Create a BooleanQuery with 2 MUST clauses, one is your required TermQuery > and the second clause is itself a BooleanQuery with all the SHOULD clauses. > This ensures that at least one of the SHOULD terms is needed together with > the MUST term. > > Uwe > > ----- > Uwe Schindler > H.-H.-Meier-Allee 63, D-28213 Bremen > http://www.thetaphi.de > eMail: uwe@thetaphi.de > > > > -----Original Message----- > > From: liat oren [mailto:oren.liat@gmail.com] > > Sent: Sunday, September 12, 2010 2:04 PM > > To: java-user@lucene.apache.org > > Subject: Unexpected Results - using should and must in boolean query > > > > Hi, > > > > I am running a query and get some unexpected results. > > > > When I run boolean query on a text field for the word X, using occur = > SHOULD, > > the results contain the word X. > > > > However, when I add another boolean query on another field (country) for > the > > word Y, using occur = MUST, in the results I get only documents in > country > Y, > > but from some reason, not only that I get documents that don't contain > the > > word X, they get higher score than those contain the word X. > > > > If I change the occur of the word X in the query to MUST, it of course > fixes it, > > but I don't understand why the SHOULD "lost" its "power" when I added the > > MUST on another field. > > > > Could something like this can happen? > > How can it be solved? > > > > Many thanks, > > Liat > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > --00148502aee58401d5049015d5fa--