Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 20348 invoked from network); 22 Jun 2005 17:43:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Jun 2005 17:43:13 -0000 Received: (qmail 7901 invoked by uid 500); 22 Jun 2005 17:43:09 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 7528 invoked by uid 500); 22 Jun 2005 17:43:08 -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 7511 invoked by uid 99); 22 Jun 2005 17:43:07 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jun 2005 10:43:07 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [69.55.225.129] (HELO ehatchersolutions.com) (69.55.225.129) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jun 2005 10:43:08 -0700 Received: by ehatchersolutions.com (Postfix, from userid 504) id 02C7713E2005; Wed, 22 Jun 2005 13:43:02 -0400 (EDT) Received: from [128.143.167.108] (d-128-167-108.bootp.Virginia.EDU [128.143.167.108]) by ehatchersolutions.com (Postfix) with ESMTP id C1EED13E2005 for ; Wed, 22 Jun 2005 13:42:55 -0400 (EDT) Mime-Version: 1.0 (Apple Message framework v730) In-Reply-To: <5fca8ecd050622102423fe8921@mail.gmail.com> References: <5fca8ecd0506220749225221d8@mail.gmail.com> <20050622170235.37923.qmail@web31114.mail.mud.yahoo.com> <5fca8ecd050622102423fe8921@mail.gmail.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <684FA0EE-D73E-4FB2-A032-280D5F8D054B@ehatchersolutions.com> Content-Transfer-Encoding: 7bit From: Erik Hatcher Subject: Re: querying multiple fields Date: Wed, 22 Jun 2005 13:42:55 -0400 To: java-user@lucene.apache.org X-Mailer: Apple Mail (2.730) X-Spam-Checker-Version: SpamAssassin 3.0.1 (2004-10-22) on javelina X-Spam-Level: X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.1 X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N On Jun 22, 2005, at 1:24 PM, George Abraham wrote: > Otis, > I think MultiFieldQueryParser (if I am not mistaken) uses the same > query string to search multiple fields. Let me know if it is > otherwise. > > Erik, > Let me see if I can answer those questions. Here are some code > snippets, by the way. > > FOR INDEX > IndexWriter writer = new IndexWriter(indexDir, new StopAnalyzer(), > true); > while (rs.next()){ //rs is a database resultset I am looping over > Document doc = new Document(); > doc.add(Field.Keyword("ObjectID", ObjectID)); > doc.add(Field.Keyword("ImageExistsBit", > ImageExistsBit));//ImageExistsBit is 1 or 0 > doc.add(Field.Text("SearchTerms", SearchTerms)); > writer.addDocument(doc); > writer.optimize(); > writer.close(); > } > > FOR SEARCH > searcher = new IndexSearcher(IndexReader.open(indexPath) ); > Analyzer analyzer = new StopAnalyzer(); > luceneQuery = QueryParser.parse(queryString, "SearchTerms", analyzer); > hits = searcher.search(luceneQuery); > System.out.println("Found " + hits.length() + " document(s)."); > > What I want: I want all the ObjectIDs that have the term 'visnu > temple' in the SearchTerms field and has ImageExistsBit=1. So the > queryString above is: SearchTerms:\"visnu temple\" ImageExistsBit:1". > The .toString() for this query is SearchTerms:"visnu temple" Your analyzer is eating the ImageExistsBit:1 because "1" returns no tokens through StopAnalyzer. Here's a solution, adapted from the code that powers lucenebook.com. Use this as your analyzer: PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper (new StopAnalyzer()); analyzer.addAnalyzer("ImageExistsBit", new WhitespaceAnalyzer()); That should do the trick. Erik --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org