Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 60777 invoked from network); 6 Mar 2008 09:35:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Mar 2008 09:35:29 -0000 Received: (qmail 90080 invoked by uid 500); 6 Mar 2008 09:35:18 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 90049 invoked by uid 500); 6 Mar 2008 09:35:18 -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 90038 invoked by uid 99); 6 Mar 2008 09:35:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Mar 2008 01:35:18 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of blueye117@gmail.com designates 72.14.204.226 as permitted sender) Received: from [72.14.204.226] (HELO qb-out-0506.google.com) (72.14.204.226) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Mar 2008 09:34:43 +0000 Received: by qb-out-0506.google.com with SMTP id o21so1741177qba.9 for ; Thu, 06 Mar 2008 01:34:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=kgjBb3rHn65QJQ8yFxAa2gBWVRtFAq6A5Z5jWUNrPXM=; b=kOlql5LmrycAxOz+zdXNms2aAip58Qtd6Dq9cB8BJvRsdXH71uOiY/Rh2glaqbCZQfVSiSGQuRr0OhxyiPjRcQwaeXXuoQAAoNE667xhtLfO90uzIPaCHzexB71keHmCtiEbEt72TWOZ+mLQ19/oOdjwm1EFHVeCBbu6AKvG2R8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=GiuJGQfE6GcmbHEUI5idK6s4l9z1kjYsUjr9k1VGgqQ3baW7xOP9NWOPDsOqLcNjrosJ9T9obc7lUG65gjmupkawJST2Gseoku3WNDhf7f6uSdpKPonqz7rTkTn2oxUJKlvUGKbnIAuXVTUrexO0TjwuwaJ0hIKYdhZrAmPjt64= Received: by 10.141.197.8 with SMTP id z8mr1853858rvp.285.1204796092664; Thu, 06 Mar 2008 01:34:52 -0800 (PST) Received: by 10.141.97.7 with HTTP; Thu, 6 Mar 2008 01:34:52 -0800 (PST) Message-ID: Date: Thu, 6 Mar 2008 17:34:52 +0800 From: "Eric Th" To: java-user@lucene.apache.org Subject: Re: Boolean Query search performance In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_26943_15482291.1204796092664" References: X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_26943_15482291.1204796092664 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 2008/3/6, Chris Hostetter : > > > : If I do a query.toString(), both queries give different results, which > > : is probably a clue (additional paren's with the BooleanQuery) > : > : Query.toString the old way using queryParser: > : +(id:1^2.0 id:2 ... ) +type:CORE > : > : Query.toString the new way using BooleanQuery: > : +((id:1^2.0) (id:2) ... ) +type:CORE > > > i didn't look too closely at the psuedo code you posted, but the > additional parens normally indicates that you are actually creating an > extra layer of BooleanQueries (ie: a BooleanQuery with only one clause for > each term) ... but the rewrite method should optimize those away (even > back in lucene 2.2) ... if you look at query.rewrite(reader).toString() > then the queries *really* should be the same, if they aren't, then that > may be your culprit. look here, parens will also be add is each term has a boost value larger than 1.0. public String toString(String field) { StringBuffer buffer = new StringBuffer(); boolean needParens=(getBoost() != 1.0) || (getMinimumNumberShouldMatch()>0) ; if (needParens) { buffer.append("("); } for (int i = 0 ; i < clauses.size(); i++) { BooleanClause c = (BooleanClause)clauses.get(i); if (c.isProhibited()) buffer.append("-"); else if (c.isRequired()) buffer.append("+"); Query subQuery = c.getQuery(); if (subQuery instanceof BooleanQuery) { // wrap sub-bools in parens buffer.append("("); buffer.append(c.getQuery().toString(field)); buffer.append(")"); } else buffer.append(c.getQuery().toString(field)); if (i != clauses.size()-1) buffer.append(" "); } if (needParens) { buffer.append(")"); } if (getMinimumNumberShouldMatch()>0) { buffer.append('~'); buffer.append(getMinimumNumberShouldMatch()); } if (getBoost() != 1.0f) { buffer.append(ToStringUtils.boost(getBoost())); } return buffer.toString(); } -Hoss --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > ------=_Part_26943_15482291.1204796092664--