lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Delip Rao <delip...@gmail.com>
Subject Search fails every time
Date Sat, 06 Jun 2009 22:25:52 GMT
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());

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