lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrien Grand <jpou...@gmail.com>
Subject Re: Discrepancies between search results and reader.document(i).get("path")
Date Fri, 29 Mar 2013 23:18:35 GMT
Hi,

On Fri, Mar 29, 2013 at 10:23 AM, Bushman, Lamont <bus08002@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-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message