lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bushman, Lamont" <>
Subject Discrepancies between search results and reader.document(i).get("path")
Date Fri, 29 Mar 2013 09:23:21 GMT
I am getting a really weird problem. I am getting a discrepancy between what my search results
are the
files that are listed in my index, through their docId's

These are the files that the index says it has
File: admin/hello.txt
File: admin/change.txt
File: admin/hello.txt~

Here I search for the word back, and I get admin/file.txt
Searching for: back
1 total matching documents
I am <B>back</B>.

My last change was to remove hello.txt~  and add file.txt.  The search results reflect that
Yet, the listing of the files that I get through the following procedure:
               for (0 to numDocs)
gives me the above listing of files.

Following are the essential parts of my code, thanks for any help.

This snippet of one of my classes looks at all of my documents and displays their file path.
Directory dir =;
IndexReader reader =;
int numDocs = reader.numDocs();
filesToDelete = new HashMap<Integer,File>();

for (int i = 0; i < numDocs; i++)
File file = new File(reader.document(i).get("path"));
System.out.println("Files: " + file);

This is another class snippet where I add documents
parser = new TextParser(file);

Document doc = new Document();
String path = file.getPath();
Field relativeURLField = new StringField("path",path, Field.Store.YES);

Field lastModified = new LongField("date", file.lastModified(), Field.Store.YES);

Field bodyField = new TextField("body",parser.getBody(), Field.Store.NO);

indexWriter.updateDocument(new Term("path",path),doc);

And this is where I delete documents

Directory dir =;
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_41);
IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_41, analyzer);
indexWriter = new IndexWriter(dir, iwc);

TermQuery query = new TermQuery(new Term("path",file.getPath()));

Directory dir =;
IndexReader reader =;

IndexSearcher is = new IndexSearcher(reader);
TopDocs topDocs =, 100);
System.out.println("hits " + topDocs.totalHits);

indexWriter.deleteDocuments(new TermQuery(new Term("path",file.getPath())));

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