Example usage for org.apache.lucene.index ReaderManager ReaderManager

List of usage examples for org.apache.lucene.index ReaderManager ReaderManager

Introduction

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

Prototype

public ReaderManager(IndexWriter writer, boolean applyAllDeletes, boolean writeAllDeletes) throws IOException 

Source Link

Document

Expert: creates and returns a new ReaderManager from the given IndexWriter , controlling whether past deletions should be applied.

Usage

From source file:spimedb.SpimeDB.java

License:Apache License

private SpimeDB(File file, Directory dir) {

    this.file = file;
    this.dir = dir;
    this.analyzer = new StandardAnalyzer();

    this.facetsConfig.setHierarchical(NObject.ID, true);
    this.facetsConfig.setMultiValued(NObject.ID, false);

    this.facetsConfig.setHierarchical(NObject.TAG, false);
    this.facetsConfig.setMultiValued(NObject.TAG, true);

    final String[] defaultFindFields = new String[] { NObject.NAME, NObject.DESC, NObject.TAG, NObject.ID };

    this.defaultFindQueryParser = ThreadLocal.withInitial(() -> new MultiFieldQueryParser(defaultFindFields,
            analyzer,/*  w  w  w.  j  a  v  a 2s.c o  m*/
            Maps.mutable.with(NObject.NAME, 1f, NObject.ID, 1f, NObject.DESC, 0.25f, NObject.TAG, 0.5f)));

    writerConf = new IndexWriterConfig(analyzer);
    writerConf.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
    writerConf.setCommitOnClose(true);
    try {
        writer = new IndexWriter(dir, writerConf);
        readerMgr = new ReaderManager(writer, true, true);
        searcherMgr = new SearcherManager(writer, true, true, new SearcherFactory());
    } catch (IOException e) {
        e.printStackTrace();
    }

}