平静

遵循美德行事,纵使没有增加快乐,也可减轻焦虑。

导航

mergePolicy

Posted on 2016-10-14 15:00  mdong  阅读(220)  评论(0编辑  收藏  举报

solrconfig.xml

<mergePolicy class="org.apache.lucene.index.LogByteSizeMergePolicy">
<int name="mergeFactor">2</int>
</mergePolicy>


public abstract class LogMergePolicy extends MergePolicy

This class implements a MergePolicy that tries to merge segments into levels of exponentially increasing size, where each level has fewer segments than the value of the merge factor. Whenever extra segments (beyond the merge factor upper bound) are encountered, all segments within the level are merged. You can get or set the merge factor using getMergeFactor() and setMergeFactor(int) respectively.

This class is abstract and requires a subclass to define the size(org.apache.lucene.index.SegmentInfoPerCommit) method which specifies how a segment's size is determined. LogDocMergePolicy is one subclass that measures size by document count in the segment. LogByteSizeMergePolicy is another subclass that measures size as the total byte size of the file(s) for the segment.

 

合并策略使每一级的段的数量小于merge factor属性。每当段的数量超过了merge factor设定的大小时,这些段会被合并。

LogDocMergePolicy 子类使用段的文档数来衡量段的大小。

LogByteSizeMergePolicy 以字节大小来衡量。

 

1. 属性介绍

mergeFactor: A merge is necessary when there are more than {@link #setMergeFactor} segments at a given level.

当段的数量超过了mergeFactor时,开始进行合并。

注意:mergeFactor cannot be less than 2

  • maxMergeSize:当一个段的大小大于此值的时候,就不再参与合并。
  • maxMergeDocs:当一个段包含的文档数大于此值的时候,就不再参与合并。

 

 

 

http://www.cnblogs.com/forfuture1978/archive/2010/03/06/1679501.html#top