lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Delip Rao <>
Subject Search fails every time
Date Sat, 06 Jun 2009 22:25:52 GMT

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



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));



indexSearcher = new IndexSearcher(indexPath);
queryParser = new QueryParser("content", new KeywordAnalyzer());

Query query = queryParser.parse(queryString);
TopDocCollector collector = new TopDocCollector(100);, collector);
System.err.println("Hits: " + collector.getTotalHits());

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message