Java Code Examples for org.apache.lucene.index.LiveIndexWriterConfig

The following examples show how to use org.apache.lucene.index.LiveIndexWriterConfig. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: dremio-oss   Source File: LuceneSearchIndex.java    License: Apache License 2.0 6 votes vote down vote up
public void forReindexing(Runnable r) {
  final LiveIndexWriterConfig config = writer.getConfig();
  final double maxRAMBufferSizeMB = config.getRAMBufferSizeMB();
  final boolean useCompoundFile = config.getUseCompoundFile();

  try {
    reindexing = true;
    // Adjust index writer settings to be better suited for reindexing
    config.setRAMBufferSizeMB(REINDEX_RAM_BUFFER_SIZE_MB);
    config.setUseCompoundFile(false);
    r.run();
    commit();
  } catch (Exception ex) {
    throw Throwables.propagate(ex);
  } finally {
    config.setRAMBufferSizeMB(maxRAMBufferSizeMB);
    config.setUseCompoundFile(useCompoundFile);
    reindexing = false;
  }
}
 
Example 2
Source Project: Elasticsearch   Source File: DLBasedEngine.java    License: Apache License 2.0 5 votes vote down vote up
private void updateIndexWriterSettings() {
    try {
        final LiveIndexWriterConfig iwc = indexWriter.getConfig();
        iwc.setRAMBufferSizeMB(engineConfig.getIndexingBufferSize().mbFrac());
        iwc.setUseCompoundFile(engineConfig.isCompoundOnFlush());
    } catch (AlreadyClosedException ex) {
        // ignore
    }
}
 
Example 3
Source Project: Elasticsearch   Source File: InternalEngine.java    License: Apache License 2.0 5 votes vote down vote up
private void updateIndexWriterSettings() {
    try {
        final LiveIndexWriterConfig iwc = indexWriter.getConfig();
        iwc.setRAMBufferSizeMB(engineConfig.getIndexingBufferSize().mbFrac());
        iwc.setUseCompoundFile(engineConfig.isCompoundOnFlush());
    } catch (AlreadyClosedException ex) {
        // ignore
    }
}
 
Example 4
Source Project: crate   Source File: EngineTestCase.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    primaryTerm.set(randomLongBetween(1, Long.MAX_VALUE));
    CodecService codecService = new CodecService(null, logger);
    String name = Codec.getDefault().getName();
    if (Arrays.asList(codecService.availableCodecs()).contains(name)) {
        // some codecs are read only so we only take the ones that we have in the service and randomly
        // selected by lucene test case.
        codecName = name;
    } else {
        codecName = "default";
    }
    defaultSettings = IndexSettingsModule.newIndexSettings("test", indexSettings());
    threadPool = new TestThreadPool(getClass().getName());
    store = createStore();
    storeReplica = createStore();
    Lucene.cleanLuceneIndex(store.directory());
    Lucene.cleanLuceneIndex(storeReplica.directory());
    primaryTranslogDir = createTempDir("translog-primary");
    translogHandler = createTranslogHandler(defaultSettings);
    engine = createEngine(store, primaryTranslogDir);
    LiveIndexWriterConfig currentIndexWriterConfig = engine.getCurrentIndexWriterConfig();

    assertEquals(engine.config().getCodec().getName(), codecService.codec(codecName).getName());
    assertEquals(currentIndexWriterConfig.getCodec().getName(), codecService.codec(codecName).getName());
    if (randomBoolean()) {
        engine.config().setEnableGcDeletes(false);
    }
    replicaTranslogDir = createTempDir("translog-replica");
    replicaEngine = createEngine(storeReplica, replicaTranslogDir);
    currentIndexWriterConfig = replicaEngine.getCurrentIndexWriterConfig();

    assertEquals(replicaEngine.config().getCodec().getName(), codecService.codec(codecName).getName());
    assertEquals(currentIndexWriterConfig.getCodec().getName(), codecService.codec(codecName).getName());
    if (randomBoolean()) {
        engine.config().setEnableGcDeletes(false);
    }
}
 
Example 5
Source Project: vscode-extension   Source File: test.java    License: MIT License 4 votes vote down vote up
LiveIndexWriterConfig getCurrentIndexWriterConfig() {
    return indexWriter.getConfig();
}
 
Example 6
Source Project: Elasticsearch   Source File: DLBasedEngine.java    License: Apache License 2.0 4 votes vote down vote up
LiveIndexWriterConfig getCurrentIndexWriterConfig() {
    return indexWriter.getConfig();
}
 
Example 7
Source Project: Elasticsearch   Source File: InternalEngine.java    License: Apache License 2.0 4 votes vote down vote up
LiveIndexWriterConfig getCurrentIndexWriterConfig() {
    return indexWriter.getConfig();
}
 
Example 8
Source Project: crate   Source File: InternalEngine.java    License: Apache License 2.0 4 votes vote down vote up
LiveIndexWriterConfig getCurrentIndexWriterConfig() {
    return indexWriter.getConfig();
}
 
Example 9
Source Project: lucene-solr   Source File: TestSolrIndexConfig.java    License: Apache License 2.0 3 votes vote down vote up
private void checkIndexWriterConfig(LiveIndexWriterConfig iwc) {

    assertTrue(iwc.getInfoStream() instanceof LoggingInfoStream);
    assertTrue(iwc.getMergePolicy().getClass().toString(),
               iwc.getMergePolicy() instanceof RandomMergePolicy);

  }