lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Muir (Commented) (JIRA)" <>
Subject [jira] [Commented] (LUCENE-3569) Consolidate IndexWriter's optimize, maybeMerge and expungeDeletes under one merge(MP) method
Date Tue, 15 Nov 2011 11:42:52 GMT


Robert Muir commented on LUCENE-3569:

Mike suggested that we keep MP passed to IWC, and introduce this new class for the explicit
merge() call. I like that idea, even though they will both have similar API signatures: findSegmentsForMerge,
findSegmentsForMaintenance. But, it will also solve Robert's concern – if we develop an
OptimizingMaintenancePolicy, you cannot pass it to IWC.

After thinking about all this, I honestly don't understand the benefit of this change. It

just seems to shuffle methods around.

Having a mergepolicy with findMergesToExpunge() [as 99.999999999999999999999999999999999%
of users will never write a mergepolicy] seems a lot better than making a vague class like
maintenance policy [that also itself might also contain a merge policy?], just so we have
what... one method on indexwriter?

I don't think we should make this change: as long as we support dangerous things like 'optimize'
(force-merge) then I want them to be totally explicit simple methods, not masked under layers.
forceMerge(N) solves the naming problem of optimize() completely for me, and its even more
explicit with 'force'.

> Consolidate IndexWriter's optimize, maybeMerge and expungeDeletes under one merge(MP)
> --------------------------------------------------------------------------------------------
>                 Key: LUCENE-3569
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: core/index
>            Reporter: Shai Erera
> Today, IndexWriter exposes 3 methods for 'cleaning up' / 'compacting' / 'optimizing'
your index:
> * optimize() -- merges as much segments as possible (down to 1 segment), and is discouraged
in many cases because of its performance implications.
> * maybeMerge() -- runs 'subtle' merges. Attempts to balance the index by not leaving
too many segments, yet not merging large segments if unneeded.
> * expungeDeletes() -- cleans up deleted documents from segments and on the go merges
> * a default MP that can be set on IndexWriterConfig, for ongoing merges IW performs (i.e.
as a result of flushing a new segment).
> These methods are confusing in several levels:
> * Their names are misleading, see LUCENE-3454.
> * Why does expungeDeletes need to merge segments?
> * Eventually, they really do what the MergePolicy decides that should be done. I.e.,
one could write an MP that always merges all segments, and therefore calling maybeMerge would
not be so subtle anymore. On the other hand, one could write an MP that never merges large
segments (we in fact have several of those), and therefore calling optimize(1) would not end
up with one segment.
> So the proposal is to replace all these methods with a single one merge(MergePolicy)
(more on the names later). MergePolicy will have only one method findSegmentsForMerge and
the caller will be responsible to configure it in order to perform the needed merges. We will
provide ready-to-use MPs:
> * LightMergePolicy -- for setting on IWC and doing the ongoing merges IW executes. This
one will pick segments respecting various parameters such as mergeFactor, segmentSizes etc.
> * HeavyMergePolicy -- for doing the optimize()-style merges.
> * ExpungeDeletesMergePolicy -- for expunging deletes (my proposal is to drop segment
merging from it, by default).
> Now about the names:
> * I think that it will be good, API-backcompat wise and in general, if we name that method
doMaintenance (as expungeDeletes does not have to merge anything).
> * Instead of MergePolicy we call it MaintenancePolicy and similarly its single method
findSegmentsForMaintenance, or getMaintenanceSpecification.
> * I called the MPs Light and Heavy just for the text, I think a better name should be
found, but nothing comes up to mind now.
> It will allow us to use this on 3.x, by deprecating MP and all related methods.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message