Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 81356 invoked from network); 15 Jun 2006 14:20:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 Jun 2006 14:20:37 -0000 Received: (qmail 57563 invoked by uid 500); 15 Jun 2006 14:20:22 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 57517 invoked by uid 500); 15 Jun 2006 14:20:22 -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 57490 invoked by uid 99); 15 Jun 2006 14:20:22 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Jun 2006 07:20:22 -0700 X-ASF-Spam-Status: No, hits=1.9 required=10.0 tests=DNS_FROM_RFC_ABUSE,DNS_FROM_RFC_WHOIS,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [68.142.207.106] (HELO web32009.mail.mud.yahoo.com) (68.142.207.106) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 15 Jun 2006 07:20:21 -0700 Received: (qmail 777 invoked by uid 60001); 15 Jun 2006 14:20:00 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=PmAacuvYQTcGgtHiC9jDm93YlUiuEoe5ml0jexUcywnQs7HRVsPAIsuioviY6WgprjUi28NEnqnQcGnjy3iLg18aTQi1PwuCEjsU8uQf/+pptjWWstpVCs6jrLemPOpybjOdHoSmpwjZvGQi4BrWESs0hNWAzM1IM47LZ/ZK8I8= ; Message-ID: <20060615142000.775.qmail@web32009.mail.mud.yahoo.com> Received: from [70.61.22.83] by web32009.mail.mud.yahoo.com via HTTP; Thu, 15 Jun 2006 07:20:00 PDT Date: Thu, 15 Jun 2006 07:20:00 -0700 (PDT) From: Reply-To: deshmol-lists@yahoo.com Subject: Re: Searching UN_TOKENIZED fields To: java-user@lucene.apache.org In-Reply-To: <44916A0B.6040902@curtin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Thanks Michael, I general my queries could be more complex than the example I outlined earlier, so I do need to use the Query Parser. Hence, PerFieldAnalyzerWrapper and KeywordAnalyzer seemed to do the trick for me. PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new StandardAnalyzer()); analyzer.addAnalyzer("PROJECT", new KeywordAnalyzer()); QueryParser parser = new QueryParser(defaultField, analyzer); ~ amol --- "Michael D. Curtin" wrote: > deshmol-lists@yahoo.com wrote: > > Hi, > > > > I have a field indexed as follows: > > > > new Field(name, value, Store.YES, > Index.UN_TOKENIZED) > > > > > > I would like to search this field for exact match > of > > the query term. Thus if, for instance in the above > > code snippet: > > > > String name="PROJECT"; > > String value="Apache Lucene"; > > > > I would like to get a hit in the following case: > > query is PROJECT:"apache lucene" > > OR query is PROJECT:"Apache Lucene" > > OR query is PROJECT:"Apache Luc*" > > > > ...but not in the following case: > > query is: PROJECT:apache > > OR query is: PROJECT:lucene > > > > With the Indexing call as above, and a query > string of > > PROJECT:"Apache Lucene" I get 0 hits. I do get > hits if > > I create the Field as TOKENIZED, but then it also > > matches the query PROJECT:apache which is not what > I > > want. > > > > It is my understanding that I'm indexing > correctly, > > but when I query, I need to indicate to the > > QueryParser that it should not tokenize the query > > string. > > Since the call: > > Term[] terms = ((PhraseQuery) query).getTerms(); > > > > returns 2 terms, which for the above example are: > > "Apache" and "Lucene" > > > > Any ideas on how I can make this work? > > If your queries are really as simple as this > example, then you could just > build queries up programmatically instead of using > QueryParser, e.g. with new > TermQuery(). Otherwise, you might want to look into > using PerFieldAnalyzer > and KeywordAnalyzer with QueryParser. > > --MDC > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: > java-user-help@lucene.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org