Search in sources :

Example 31 with RAMDirectory

use of org.apache.lucene.store.RAMDirectory in project neo4j-mobile-android by neo4j-contrib.

the class FullTxData method ensureLuceneDataInstantiated.

private void ensureLuceneDataInstantiated() {
    if (this.directory == null) {
        try {
            this.directory = new RAMDirectory();
            IndexWriterConfig writerConfig = new IndexWriterConfig(LUCENE_VERSION, index.type.analyzer);
            this.writer = new IndexWriter(directory, writerConfig);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : IndexWriter(org.apache.lucene.index.IndexWriter) IOException(java.io.IOException) RAMDirectory(org.apache.lucene.store.RAMDirectory) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig)

Example 32 with RAMDirectory

use of org.apache.lucene.store.RAMDirectory in project graphdb by neo4j-attic.

the class FullTxData method ensureLuceneDataInstantiated.

private void ensureLuceneDataInstantiated() {
    if (this.directory == null) {
        try {
            this.directory = new RAMDirectory();
            this.writer = new IndexWriter(directory, index.type.analyzer, MaxFieldLength.UNLIMITED);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : IndexWriter(org.apache.lucene.index.IndexWriter) IOException(java.io.IOException) RAMDirectory(org.apache.lucene.store.RAMDirectory)

Example 33 with RAMDirectory

use of org.apache.lucene.store.RAMDirectory in project neo4j by neo4j.

the class FullTxData method ensureLuceneDataInstantiated.

private void ensureLuceneDataInstantiated() {
    if (this.directory == null) {
        try {
            this.directory = new RAMDirectory();
            IndexWriterConfig writerConfig = new IndexWriterConfig(index.type.analyzer);
            this.writer = new IndexWriter(directory, writerConfig);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : IndexWriter(org.apache.lucene.index.IndexWriter) IOException(java.io.IOException) RAMDirectory(org.apache.lucene.store.RAMDirectory) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig)

Example 34 with RAMDirectory

use of org.apache.lucene.store.RAMDirectory in project orientdb by orientechnologies.

the class OLuceneDirectoryFactory method createDirectory.

private Directory createDirectory(ODatabaseDocumentInternal database, String indexName, ODocument metadata, String luceneType) {
    String luceneBasePath = metadata.containsField(DIRECTORY_PATH) ? metadata.<String>field(DIRECTORY_PATH) : OLUCENE_BASE_DIR;
    Path luceneIndexPath = Paths.get(database.getStorage().getConfiguration().getDirectory(), luceneBasePath, indexName);
    try {
        if (DIRECTORY_NIO.equals(luceneType)) {
            return new NIOFSDirectory(luceneIndexPath);
        }
        if (DIRECTORY_MMAP.equals(luceneType)) {
            return new MMapDirectory(luceneIndexPath);
        }
    } catch (IOException e) {
        OLogManager.instance().error(this, "unable to create Lucene Directory with type " + luceneType, e);
    }
    OLogManager.instance().warn(this, "unable to create Lucene Directory, FALL BACK to ramDir");
    return new RAMDirectory();
}
Also used : Path(java.nio.file.Path) NIOFSDirectory(org.apache.lucene.store.NIOFSDirectory) IOException(java.io.IOException) MMapDirectory(org.apache.lucene.store.MMapDirectory) RAMDirectory(org.apache.lucene.store.RAMDirectory)

Example 35 with RAMDirectory

use of org.apache.lucene.store.RAMDirectory in project orientdb by orientechnologies.

the class OLuceneStorage method reOpen.

private void reOpen() throws IOException {
    if (mgrWriter != null) {
        OLogManager.instance().info(this, "index storage is open don't reopen");
        return;
    }
    ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.INSTANCE.get();
    final OAbstractPaginatedStorage storageLocalAbstract = (OAbstractPaginatedStorage) database.getStorage().getUnderlying();
    Directory dir = null;
    if (storageLocalAbstract instanceof OLocalPaginatedStorage) {
        String pathname = getIndexPath((OLocalPaginatedStorage) storageLocalAbstract);
        OLogManager.instance().info(this, "Opening NIOFS Lucene db=%s, path=%s", database.getName(), pathname);
        dir = NIOFSDirectory.open(new File(pathname).toPath());
    } else {
        OLogManager.instance().info(this, "Opening RAM Lucene index db=%s", database.getName());
        dir = new RAMDirectory();
    }
    final IndexWriter indexWriter = createIndexWriter(dir);
    mgrWriter = new TrackingIndexWriter(indexWriter);
    searcherManager = new SearcherManager(indexWriter, true, null);
    if (nrt != null) {
        nrt.close();
    }
    nrt = new ControlledRealTimeReopenThread(mgrWriter, searcherManager, 60.00, 0.1);
    nrt.setDaemon(true);
    nrt.start();
    flush();
    OLogManager.instance().info(this, "REOPEN DONE");
}
Also used : ControlledRealTimeReopenThread(org.apache.lucene.search.ControlledRealTimeReopenThread) TrackingIndexWriter(org.apache.lucene.index.TrackingIndexWriter) IndexWriter(org.apache.lucene.index.IndexWriter) TrackingIndexWriter(org.apache.lucene.index.TrackingIndexWriter) OLocalPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage) SearcherManager(org.apache.lucene.search.SearcherManager) OAbstractPaginatedStorage(com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage) File(java.io.File) ODatabaseDocumentInternal(com.orientechnologies.orient.core.db.ODatabaseDocumentInternal) RAMDirectory(org.apache.lucene.store.RAMDirectory) RAMDirectory(org.apache.lucene.store.RAMDirectory) Directory(org.apache.lucene.store.Directory) NIOFSDirectory(org.apache.lucene.store.NIOFSDirectory)

Aggregations

RAMDirectory (org.apache.lucene.store.RAMDirectory)183 Directory (org.apache.lucene.store.Directory)101 IndexWriter (org.apache.lucene.index.IndexWriter)82 Document (org.apache.lucene.document.Document)75 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)73 IndexSearcher (org.apache.lucene.search.IndexSearcher)43 IndexReader (org.apache.lucene.index.IndexReader)41 Test (org.junit.Test)35 TextField (org.apache.lucene.document.TextField)33 Field (org.apache.lucene.document.Field)29 Term (org.apache.lucene.index.Term)25 StandardAnalyzer (org.apache.lucene.analysis.standard.StandardAnalyzer)21 Before (org.junit.Before)21 IOException (java.io.IOException)19 MockAnalyzer (org.apache.lucene.analysis.MockAnalyzer)19 Analyzer (org.apache.lucene.analysis.Analyzer)18 TopDocs (org.apache.lucene.search.TopDocs)16 DirectoryReader (org.apache.lucene.index.DirectoryReader)15 FilterDirectory (org.apache.lucene.store.FilterDirectory)15 FieldType (org.apache.lucene.document.FieldType)13