Search in sources :

Example 11 with LogMergePolicy

use of org.apache.lucene.index.LogMergePolicy in project jackrabbit by apache.

the class AbstractIndex method getIndexWriter.

/**
 * Returns an <code>IndexWriter</code> on this index.
 * @return an <code>IndexWriter</code> on this index.
 * @throws IOException if the writer cannot be obtained.
 */
protected synchronized IndexWriter getIndexWriter() throws IOException {
    if (indexReader != null) {
        indexReader.close();
        log.debug("closing IndexReader.");
        indexReader = null;
    }
    if (indexWriter == null) {
        IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_36, analyzer);
        config.setSimilarity(similarity);
        LogMergePolicy mergePolicy = new LogByteSizeMergePolicy();
        mergePolicy.setUseCompoundFile(useCompoundFile);
        mergePolicy.setNoCFSRatio(1.0);
        config.setMergePolicy(mergePolicy);
        indexWriter = new IndexWriter(getDirectory(), config);
        indexWriter.setInfoStream(STREAM_LOGGER);
    }
    return indexWriter;
}
Also used : LogByteSizeMergePolicy(org.apache.lucene.index.LogByteSizeMergePolicy) IndexWriter(org.apache.lucene.index.IndexWriter) LogMergePolicy(org.apache.lucene.index.LogMergePolicy) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig)

Example 12 with LogMergePolicy

use of org.apache.lucene.index.LogMergePolicy in project openolat by klemens.

the class JmsIndexer method newLogMergePolicy.

public LogMergePolicy newLogMergePolicy() {
    LogMergePolicy logmp = new LogDocMergePolicy();
    logmp.setCalibrateSizeByDeletes(true);
    logmp.setMergeFactor(INDEX_MERGE_FACTOR);
    return logmp;
}
Also used : LogMergePolicy(org.apache.lucene.index.LogMergePolicy) LogDocMergePolicy(org.apache.lucene.index.LogDocMergePolicy)

Aggregations

LogMergePolicy (org.apache.lucene.index.LogMergePolicy)12 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)7 IndexWriter (org.apache.lucene.index.IndexWriter)4 LogDocMergePolicy (org.apache.lucene.index.LogDocMergePolicy)4 IOException (java.io.IOException)2 MockAnalyzer (org.apache.lucene.analysis.MockAnalyzer)2 Document (org.apache.lucene.document.Document)2 ConcurrentMergeScheduler (org.apache.lucene.index.ConcurrentMergeScheduler)2 LogByteSizeMergePolicy (org.apache.lucene.index.LogByteSizeMergePolicy)2 MergePolicy (org.apache.lucene.index.MergePolicy)2 TieredMergePolicy (org.apache.lucene.index.TieredMergePolicy)2 Directory (org.apache.lucene.store.Directory)2 RAMDirectory (org.apache.lucene.store.RAMDirectory)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStreamReader (java.io.InputStreamReader)1 PrintStream (java.io.PrintStream)1 PostingsFormat (org.apache.lucene.codecs.PostingsFormat)1 Lucene70Codec (org.apache.lucene.codecs.lucene70.Lucene70Codec)1 Field (org.apache.lucene.document.Field)1 TextField (org.apache.lucene.document.TextField)1