lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andi rexha <a_re...@hotmail.com>
Subject Segment readers in Lucene 4.2
Date Tue, 02 Apr 2013 13:44:55 GMT
Hi,
I have a question about the Index Readers in Lucene. 
As far as I understand from the documentation, with the Lucene 4, we can create an Index Reader
from DirectoryReader.open(directory);

>From the code of the DirectoryReader, I have seen that it uses the SegmentReader to create
the reader. To get all the SegmentReaders we have to loop through the AtomicReaderContexts
that we can get from the "dirReader.leaves()"; 

Am I correct until here? Did I miss something from the whole picture?

My question is: I want to associate each segment to its AtomicReaderContext. I have an application
that caches information from each segment, and I want to keep the reference to the current
opened segments. I have found a way to do that but that is not elegant : 

I could associate the reader.toString() method to each of the segment information.

 SegmentInfos sis = new SegmentInfos();
 sis.read(open);
 for (int i = 0; i < sis.size(); i ++) {
            segmentInfo[i] = sis.info(i);
 }

List<AtomicReaderContext> leaves = dirReader.leaves();
        System.out.println(leaves.size());
        for (AtomicReaderContext context : leaves) {
            checkIfExist(segmentInfo(i), context.reader().toString()); //here the solution
is that I use the toString() method to extract the information of the segment. I cannot extract
the information of the segment because it is protected
}


Do you have any clue whether it is possible to have this mapping in a different way? 

Thanks in advance,
Best regards,
Andi


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