Example usage for org.apache.lucene.index LogDocMergePolicy setMinMergeDocs

List of usage examples for org.apache.lucene.index LogDocMergePolicy setMinMergeDocs

Introduction

In this page you can find the example usage for org.apache.lucene.index LogDocMergePolicy setMinMergeDocs.

Prototype

public void setMinMergeDocs(int minMergeDocs) 

Source Link

Document

Sets the minimum size for the lowest level segments.

Usage

From source file:com.zimbra.cs.index.LuceneIndex.java

License:Open Source License

private IndexWriterConfig getWriterConfig() {
    IndexWriterConfig config = new IndexWriterConfig(VERSION, mailbox.index.getAnalyzer());
    config.setMergeScheduler(new MergeScheduler());
    config.setMaxBufferedDocs(LC.zimbra_index_lucene_max_buffered_docs.intValue());
    config.setRAMBufferSizeMB(LC.zimbra_index_lucene_ram_buffer_size_kb.intValue() / 1024.0);
    if (LC.zimbra_index_lucene_merge_policy.booleanValue()) {
        LogDocMergePolicy policy = new LogDocMergePolicy();
        config.setMergePolicy(policy);// w w w . j ava2 s. co m
        policy.setUseCompoundFile(LC.zimbra_index_lucene_use_compound_file.booleanValue());
        policy.setMergeFactor(LC.zimbra_index_lucene_merge_factor.intValue());
        policy.setMinMergeDocs(LC.zimbra_index_lucene_min_merge.intValue());
        if (LC.zimbra_index_lucene_max_merge.intValue() != Integer.MAX_VALUE) {
            policy.setMaxMergeDocs(LC.zimbra_index_lucene_max_merge.intValue());
        }
    } else {
        LogByteSizeMergePolicy policy = new LogByteSizeMergePolicy();
        config.setMergePolicy(policy);
        policy.setUseCompoundFile(LC.zimbra_index_lucene_use_compound_file.booleanValue());
        policy.setMergeFactor(LC.zimbra_index_lucene_merge_factor.intValue());
        policy.setMinMergeMB(LC.zimbra_index_lucene_min_merge.intValue() / 1024.0);
        if (LC.zimbra_index_lucene_max_merge.intValue() != Integer.MAX_VALUE) {
            policy.setMaxMergeMB(LC.zimbra_index_lucene_max_merge.intValue() / 1024.0);
        }
    }
    return config;
}

From source file:org.compass.core.lucene.engine.merge.policy.LogDocMergePolicyProvider.java

License:Apache License

public MergePolicy create(CompassSettings settings) throws SearchEngineException {
    LogDocMergePolicy mergePolicy = new LogDocMergePolicy();
    mergePolicy.setMaxMergeDocs(settings.getSettingAsInt(LuceneEnvironment.MergePolicy.LogDoc.MAX_MERGE_DOCS,
            LogDocMergePolicy.DEFAULT_MAX_MERGE_DOCS));
    mergePolicy.setMinMergeDocs(settings.getSettingAsInt(LuceneEnvironment.MergePolicy.LogDoc.MIN_MERGE_DOCS,
            LogDocMergePolicy.DEFAULT_MIN_MERGE_DOCS));
    return mergePolicy;
}

From source file:org.meresco.lucene.numerate.UriEnumerate.java

License:Open Source License

/**
 *
 * @param path//from  w  ww .j  a  v a 2 s . co  m
 * @param max_cache_size
 * @param withTransactionLog allows for crash recovery, but slows down UriNumerate considerably because of file system flush.
 * @throws IOException
 */
public UriEnumerate(String path, int max_cache_size, boolean withTransactionLog) throws IOException {
    IndexWriterConfig config = new IndexWriterConfig(null);
    ConcurrentMergeScheduler ms = (ConcurrentMergeScheduler) config.getMergeScheduler();
    ms.setDefaultMaxMergesAndThreads(/* spins= */false);
    LogDocMergePolicy mp = new LogDocMergePolicy();
    mp.setMergeFactor(2);
    mp.setMinMergeDocs(max_cache_size);
    config.setMergePolicy(mp);
    config.setCodec(new Lucene60Codec() {
        @Override
        public PostingsFormat getPostingsFormatForField(String field) {
            return new BloomFilteringPostingsFormat(super.getPostingsFormatForField(field));
        }
    });
    config.setUseCompoundFile(false);
    this.writer = new IndexWriter(FSDirectory.open(FileSystems.getDefault().getPath(path)), config);
    this.next_ord = writer.numDocs() + 1;
    this.searcher = new SimpleSearcher(this.writer);
    this.cache = new Cache(max_cache_size, () -> this.commit());
    this.transactionLog = new TransactionLog(withTransactionLog ? path + "/transactionLog" : null);
    this.transactionLog.maybeRecover();
}