Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 73796 invoked from network); 28 Jun 2006 18:30:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 28 Jun 2006 18:30:47 -0000 Received: (qmail 87347 invoked by uid 500); 28 Jun 2006 18:30:41 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 87321 invoked by uid 500); 28 Jun 2006 18:30:40 -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 87310 invoked by uid 99); 28 Jun 2006 18:30:40 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Jun 2006 11:30:40 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [169.229.70.167] (HELO rescomp.berkeley.edu) (169.229.70.167) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Jun 2006 11:30:39 -0700 Received: by rescomp.berkeley.edu (Postfix, from userid 1007) id 112FB5B778; Wed, 28 Jun 2006 11:30:09 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by rescomp.berkeley.edu (Postfix) with ESMTP id 0BF2C7F403 for ; Wed, 28 Jun 2006 11:30:09 -0700 (PDT) Date: Wed, 28 Jun 2006 11:30:09 -0700 (PDT) From: Chris Hostetter To: java-user@lucene.apache.org Subject: Re: Exact match on a single term / word In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N : I am trying to get Lucene to perform an exact match on a single term or word : using the default query parser. It works fine whenever I have more than one : word / term in the search string (it parses the string into a PhraseQuery : with a slop of 0 which is correct). However when the search string just : contains a single word ie "state", the query parser parses this into a : TermQuery despite the quotes when I would have expected a phrase query. : Is there any easy way around this? the quotes tell the query parser to send the entire contents of the string to the analyzer -- even if it has spaces (which query parser would normally split on) and if your analyzer returns one token query parser makes a TermQuery and if it returns more then one toke query parser makes a PhraseQuery. the real question is: why do you feel TermQuery is the wrong thing to use in this case? ... if you're searching for a single Term, it's what makes the most sense. -Hoss --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org