Example usage for org.apache.lucene.index IndexWriterConfig DEFAULT_MAX_BUFFERED_DOCS

List of usage examples for org.apache.lucene.index IndexWriterConfig DEFAULT_MAX_BUFFERED_DOCS

Introduction

In this page you can find the example usage for org.apache.lucene.index IndexWriterConfig DEFAULT_MAX_BUFFERED_DOCS.

Prototype

int DEFAULT_MAX_BUFFERED_DOCS

To view the source code for org.apache.lucene.index IndexWriterConfig DEFAULT_MAX_BUFFERED_DOCS.

Click Source Link

Document

Disabled by default (because IndexWriter flushes by RAM usage by default).

Usage

From source file:com.google.gerrit.lucene.GerritIndexWriterConfig.java

License:Apache License

GerritIndexWriterConfig(Config cfg, String name) {
    analyzer = new CustomMappingAnalyzer(new StandardAnalyzer(CharArraySet.EMPTY_SET), CUSTOM_CHAR_MAPPING);
    luceneConfig = new IndexWriterConfig(analyzer).setOpenMode(OpenMode.CREATE_OR_APPEND)
            .setCommitOnClose(true);//from  w  w w.  j  av a 2 s  .c om
    double m = 1 << 20;
    luceneConfig.setRAMBufferSizeMB(cfg.getLong("index", name, "ramBufferSize",
            (long) (IndexWriterConfig.DEFAULT_RAM_BUFFER_SIZE_MB * m)) / m);
    luceneConfig.setMaxBufferedDocs(
            cfg.getInt("index", name, "maxBufferedDocs", IndexWriterConfig.DEFAULT_MAX_BUFFERED_DOCS));
    try {
        commitWithinMs = ConfigUtil.getTimeUnit(cfg, "index", name, "commitWithin",
                MILLISECONDS.convert(5, MINUTES), MILLISECONDS);
    } catch (IllegalArgumentException e) {
        commitWithinMs = cfg.getLong("index", name, "commitWithin", 0);
    }
}