Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6994698B0 for ; Mon, 30 Jan 2012 22:39:48 +0000 (UTC) Received: (qmail 78592 invoked by uid 500); 30 Jan 2012 22:39:45 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 78477 invoked by uid 500); 30 Jan 2012 22:39:45 -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 78421 invoked by uid 99); 30 Jan 2012 22:39:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Jan 2012 22:39:44 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of felipe.carvalho@gmail.com designates 209.85.214.176 as permitted sender) Received: from [209.85.214.176] (HELO mail-tul01m020-f176.google.com) (209.85.214.176) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Jan 2012 22:39:39 +0000 Received: by obbwd18 with SMTP id wd18so3532701obb.35 for ; Mon, 30 Jan 2012 14:39:19 -0800 (PST) Received-SPF: pass (google.com: domain of felipe.carvalho@gmail.com designates 10.182.225.33 as permitted sender) client-ip=10.182.225.33; Authentication-Results: mr.google.com; spf=pass (google.com: domain of felipe.carvalho@gmail.com designates 10.182.225.33 as permitted sender) smtp.mail=felipe.carvalho@gmail.com; dkim=pass header.i=felipe.carvalho@gmail.com Received: from mr.google.com ([10.182.225.33]) by 10.182.225.33 with SMTP id rh1mr51875625obc.71.1327963159259 (num_hops = 1); Mon, 30 Jan 2012 14:39:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Fb0dyq/4KNtf6+GF8Q/T5i2QD/sWfJTzpxEAVT6Y0IM=; b=i8LWtIh2DNwAhCh8UfXp90fP6AMeKuTqiTbgue55eBy+i4luaZV1fIn35jUCSUK0XC RxOYHllA2yi5Jsrnl3FQd6trn31NMxfQZF4nxpdcTSj5I3R5CqJ01ciYAY/y5sW+JeDB pCWg0buBsAaLliNrP/giBO0dA09VeUkCjArgk= Received: by 10.182.225.33 with SMTP id rh1mr32090655obc.71.1327963159211; Mon, 30 Jan 2012 14:39:19 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.241.39 with HTTP; Mon, 30 Jan 2012 14:38:58 -0800 (PST) In-Reply-To: References: From: Felipe Carvalho Date: Mon, 30 Jan 2012 20:38:58 -0200 Message-ID: Subject: Re: Differences between BooleanQuery and QueryParser To: java-user@lucene.apache.org Content-Type: multipart/alternative; boundary=f46d044469f9612ebd04b7c6846e --f46d044469f9612ebd04b7c6846e Content-Type: text/plain; charset=ISO-8859-1 Has anyone ever measured the difference? Could it make a 10%+ difference on a search involving around 5 terms? On Mon, Jan 30, 2012 at 8:05 PM, Brandon Mintern wrote: > A QueryParser has to actually parse your text and build up the > BooleanQuery exactly as you do in your second example. Since the > QueryParser is doing extra work that you don't have to do considering > that you already know everything about the query, your second example > is faster. > > On Mon, Jan 30, 2012 at 1:55 PM, Felipe Carvalho > wrote: > > Is there any difference, from a performance standpoint (or any other > > standpoint whatsoever), between instantiating a query using QueryParser > and > > BooleanQuery? Is either of them preferable to use? > > > > Eg: > > > > QueryParser parser = new QueryParser(Version.LUCENE_33, "name", wrapper) > > Query query = parser.parse("size:small AND color:blue") > > > > versus > > > > BooleanQuery skuQuery = new BooleanQuery(); > > skuQuery.add(new TermQuery(new Term("size", "small")), Occur.MUST); > > skuQuery.add(new TermQuery(new Term("color", "blue")), Occur.MUST); > > > > > > Thanks > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > --f46d044469f9612ebd04b7c6846e--