Thanks Adrien,

So far I think I figured out a solution to my problem.
I added the following lines to my deletion and it seems to work fine.

indexWriter.commit();
indexWriter.forceMergeDeletes(true);
indexWriter.deleteUnusedFiles();

However, with your response, especially if I come across problems later.   
reader.liveDocs() is not found in IndexWriter.  I am guessing you are referring 
to the TermsEnum class.  I assume numDocs() returns the amount of documents 
that are left to search and maxDoc() is the greatest id that still exists.  I 
believe my program is working fine for me now because I am using the 
forceMergeDeletes() method, so that numDocs() will always be the same as 
maxDoc().  Am I right on my assumptions?

Thanks,
Lamont
________________________________________
From: Adrien Grand [jpou...@gmail.com]
Sent: Friday, March 29, 2013 5:18 PM
To: java-user@lucene.apache.org
Subject: Re: Discrepancies between search results and 
reader.document(i).get("path")

Hi,

On Fri, Mar 29, 2013 at 10:23 AM, Bushman, Lamont <bus08...@byui.edu> wrote:
> This snippet of one of my classes looks at all of my documents and displays 
> their file path.
> ------------------------------------------------------------------------------------------------
> Directory dir = FSDirectory.open(mIndexFolder);
> IndexReader reader = DirectoryReader.open(dir);
> 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 not correct if there are deleted documents. You must iterate
from 0 to maxDoc() and skip deleted documents (using
reader.liveDocs()).

--
Adrien

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to