Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 98352 invoked from network); 7 Jun 2009 16:40:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Jun 2009 16:40:53 -0000 Received: (qmail 44889 invoked by uid 500); 7 Jun 2009 16:41:03 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 44851 invoked by uid 500); 7 Jun 2009 16:41:03 -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 44841 invoked by uid 99); 7 Jun 2009 16:41:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Jun 2009 16:41:03 +0000 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [208.97.132.74] (HELO spunkymail-a18.g.dreamhost.com) (208.97.132.74) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 07 Jun 2009 16:40:51 +0000 Received: from [192.168.0.105] (adsl-074-229-189-244.sip.rmo.bellsouth.net [74.229.189.244]) by spunkymail-a18.g.dreamhost.com (Postfix) with ESMTP id 751F55B52C for ; Sun, 7 Jun 2009 09:40:29 -0700 (PDT) Message-Id: <3D10555A-9719-47A0-B912-F1C35E5E7F22@apache.org> From: Grant Ingersoll To: java-user@lucene.apache.org In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v935.3) Subject: Re: Search fails every time Date: Sun, 7 Jun 2009 12:40:27 -0400 References: X-Mailer: Apple Mail (2.935.3) X-Virus-Checked: Checked by ClamAV on apache.org If I had to guess, I'd say you have some type of Analysis mismatch between what you are indexing and what you are searching. Do you really want to use the KeywordAnalyzer? You might use Luke (http://www.getopt.org/luke) to have a look at your index and see if that sheds some light. Also have a look at the Lucene FAQ: http://wiki.apache.org/lucene-java/LuceneFAQ -Grant On Jun 6, 2009, at 6:25 PM, Delip Rao wrote: > Hi, > > Mentioned below are snippets from my indexing and searching code. > For some > reason, I get zero hits all the time even for terms present in the > document > collection. Can somebody point out where I'm going wrong? I'm using > lucene-core-2.4.0.jar. > > Thanks! > Delip > > > ----------------------- > Indexer.java > > Directory dir = FSDirectory.getDirectory(path); > indexWriter = new IndexWriter(dir, new KeywordAnalyzer(), > true, IndexWriter.MaxFieldLength.UNLIMITED); > > // initialize docid and fileContents (in a loop) > ... > > currentDocument = new Document(); > currentDocument.add(new Field("id", docid, > Field.Store.YES, Field.Index.NOT_ANALYZED)); > currentDocument.add(new Field("content", fileContents, > Field.Store.YES, Field.Index.ANALYZED)); > > indexWriter.addDocument(currentDocument); > > > ---------------------- > Searcher.java > > indexSearcher = new IndexSearcher(indexPath); > queryParser = new QueryParser("content", new KeywordAnalyzer()); > > Query query = queryParser.parse(queryString); > TopDocCollector collector = new TopDocCollector(100); > indexSearcher.search(query, collector); > System.err.println("Hits: " + collector.getTotalHits()); -------------------------- Grant Ingersoll http://www.lucidimagination.com/ Search the Lucene ecosystem (Lucene/Solr/Nutch/Mahout/Tika/Droids) using Solr/Lucene: http://www.lucidimagination.com/search --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org