[ 
https://issues.apache.org/jira/browse/LUCENE-5526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14086946#comment-14086946
 ] 

Uwe Schindler commented on LUCENE-5526:
---------------------------------------

How about adding MergePolicy as optional parameter to 
IndexWriterl#forceMerge(int, boolean, MergePolicy)

When doing the forceMerge, IndexWriter will then use the given MergePolicy 
instead of the default (this can easily be separated). This would also not 
interfere with other merges going on.

The good thing: You could also start a forceMerge with UpgradeIndexMergePolicy 
and then proceed with normal indexing. Elasticssearch or Solr can use this to 
allow forced merges or upgrading all segments written with an older version, 
without reopening a new IndexWriter or doing crazy hacks in a custom wrapper 
merge policy.

Another cool use would be: We could remove forceMergeDeletes from IndexWriter 
and just implement that by wrapping the current mergePolicy with one that only 
selects segments with deletions on forceMerge()? By that all mergePolicies 
don't need to implement a specific logic for deletes, this can be done just in 
the wrapper only and would be identical in all merge policies.

> Forced merges
> -------------
>
>                 Key: LUCENE-5526
>                 URL: https://issues.apache.org/jira/browse/LUCENE-5526
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Adrien Grand
>            Priority: Minor
>
> {{IndexWriter.forceMerge}} allows to force merges if the number of segments 
> is higher than a configured limit. I would like to have the ability to also 
> force a merge if there is a single segment in the directory. This is possible 
> today by closing the IndexWriter, reopening with a custom merge policy such 
> as {{UpgradeIndexMergePolicy}}, running a {{forceMerge}} and finally 
> reopening again with the original merge policy but this is a bit impractical 
> and if possible I would like to be able to do it without reopening the writer 
> twice.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to