Search in sources :

Example 11 with SearcherManager

use of org.apache.lucene.search.SearcherManager in project neo4j by neo4j.

the class SimpleUniquenessVerifierTest method initLuceneResources.

@BeforeEach
void initLuceneResources() throws Exception {
    dirFactory = new DirectoryFactory.InMemoryDirectoryFactory();
    Directory dir = dirFactory.open(testDir.directory("test"));
    writer = new IndexWriter(dir, IndexWriterConfigs.standard(Config.defaults()));
    searcherManager = new SearcherManager(writer, new Neo4jSearcherFactory());
}
Also used : Neo4jSearcherFactory(org.neo4j.kernel.api.impl.index.partition.Neo4jSearcherFactory) IndexWriter(org.apache.lucene.index.IndexWriter) DirectoryFactory(org.neo4j.kernel.api.impl.index.storage.DirectoryFactory) SearcherManager(org.apache.lucene.search.SearcherManager) Directory(org.apache.lucene.store.Directory) TestDirectory(org.neo4j.test.rule.TestDirectory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 12 with SearcherManager

use of org.apache.lucene.search.SearcherManager 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)

Example 13 with SearcherManager

use of org.apache.lucene.search.SearcherManager in project OpenGrok by OpenGrok.

the class RuntimeEnvironment method maybeRefreshIndexSearchers.

public void maybeRefreshIndexSearchers() {
    LOGGER.log(Level.INFO, "refreshing searcher managers");
    Statistics stat = new Statistics();
    for (Map.Entry<String, SearcherManager> entry : searcherManagerMap.entrySet()) {
        maybeRefreshSearcherManager(entry.getValue());
    }
    stat.report(LOGGER, "Done refreshing searcher managers");
}
Also used : SearcherManager(org.apache.lucene.search.SearcherManager) Statistics(org.opengrok.indexer.util.Statistics) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 14 with SearcherManager

use of org.apache.lucene.search.SearcherManager in project che by eclipse.

the class LuceneSearcher method doInit.

protected final synchronized void doInit() throws ServerException {
    try {
        luceneIndexWriter = new IndexWriter(makeDirectory(), new IndexWriterConfig(makeAnalyzer()));
        searcherManager = new SearcherManager(luceneIndexWriter, true, new SearcherFactory());
        closed = false;
    } catch (IOException e) {
        throw new ServerException(e);
    }
}
Also used : SearcherFactory(org.apache.lucene.search.SearcherFactory) ServerException(org.eclipse.che.api.core.ServerException) IndexWriter(org.apache.lucene.index.IndexWriter) SearcherManager(org.apache.lucene.search.SearcherManager) IOException(java.io.IOException) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig)

Example 15 with SearcherManager

use of org.apache.lucene.search.SearcherManager in project neo4j by neo4j.

the class AllNodesCollector method getAllNodes.

public static List<Long> getAllNodes(Directory directory, Object propertyValue) throws IOException {
    try (SearcherManager manager = new SearcherManager(directory, new SearcherFactory())) {
        IndexSearcher searcher = manager.acquire();
        Query query = LuceneDocumentStructure.newSeekQuery(propertyValue);
        AllNodesCollector collector = new AllNodesCollector();
        searcher.search(query, collector);
        return collector.nodeIds;
    }
}
Also used : SearcherFactory(org.apache.lucene.search.SearcherFactory) IndexSearcher(org.apache.lucene.search.IndexSearcher) Query(org.apache.lucene.search.Query) SearcherManager(org.apache.lucene.search.SearcherManager)

Aggregations

SearcherManager (org.apache.lucene.search.SearcherManager)21 IndexSearcher (org.apache.lucene.search.IndexSearcher)11 IOException (java.io.IOException)8 Directory (org.apache.lucene.store.Directory)8 SearcherFactory (org.apache.lucene.search.SearcherFactory)7 IndexWriter (org.apache.lucene.index.IndexWriter)6 TermQuery (org.apache.lucene.search.TermQuery)4 RAMDirectory (org.apache.lucene.store.RAMDirectory)4 File (java.io.File)3 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)3 Query (org.apache.lucene.search.Query)3 TopDocs (org.apache.lucene.search.TopDocs)3 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 FilterLeafReader (org.apache.lucene.index.FilterLeafReader)2 LeafReader (org.apache.lucene.index.LeafReader)2 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)2 SegmentReader (org.apache.lucene.index.SegmentReader)2 Term (org.apache.lucene.index.Term)2 FSDirectory (org.apache.lucene.store.FSDirectory)2