Question

I want to have a control in Lucene on the segment merging. To be more precise I have a per segment cache and each time there is a merge I want to have a "callback" and check which segment is going to be merged.

I had a look to the IndexWriter code and looks like its an internal operation of the index writer. I also dont want to hack the IndexWriter. I see an interface called MergeScheduler. Is the best idea to implement this class?

Do you have any idea how to do that? Thanks in advance!

Was it helpful?

Solution

Maybe you could subclass the MergePolicy you are using (the default one is TieredMergePolicy) and intercept the segments to be merged by overriding the findMerges method like this?

MergePolicy.MergeSpecification mergeSpecification = super.findMerges(segmentInfos);

// use information from mergeSpecifiation

return mergeSpecification;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top