Search in sources :

Example 1 with DroppableLuceneIndex

use of org.neo4j.kernel.api.impl.index.DroppableLuceneIndex in project neo4j by neo4j.

the class FulltextIndexProvider method getPopulator.

@Override
public IndexPopulator getPopulator(IndexDescriptor descriptor, IndexSamplingConfig samplingConfig, ByteBufferFactory bufferFactory, MemoryTracker memoryTracker, TokenNameLookup tokenNameLookup) {
    if (isReadOnly()) {
        throw new UnsupportedOperationException("Can't create populator for read only index");
    }
    try {
        PartitionedIndexStorage indexStorage = getIndexStorage(descriptor.getId());
        Analyzer analyzer = createAnalyzer(descriptor, tokenNameLookup);
        String[] propertyNames = createPropertyNames(descriptor, tokenNameLookup);
        DatabaseIndex<FulltextIndexReader> fulltextIndex = FulltextIndexBuilder.create(descriptor, config, readOnlyChecker, tokenHolders.propertyKeyTokens(), analyzer, propertyNames).withFileSystem(fileSystem).withIndexStorage(indexStorage).withPopulatingMode(true).build();
        log.debug("Creating populator for fulltext schema index: %s", descriptor);
        return new FulltextIndexPopulator(descriptor, fulltextIndex, propertyNames);
    } catch (Exception e) {
        PartitionedIndexStorage indexStorage = getIndexStorage(descriptor.getId());
        DatabaseIndex<FulltextIndexReader> fulltextIndex = new DroppableIndex<>(new DroppableLuceneIndex<>(indexStorage, new ReadOnlyIndexPartitionFactory(), descriptor));
        log.debug("Creating failed index populator for fulltext schema index: %s", descriptor, e);
        return new FailedFulltextIndexPopulator(descriptor, fulltextIndex, e);
    }
}
Also used : DatabaseIndex(org.neo4j.kernel.api.impl.index.DatabaseIndex) FulltextIndexSettings.createAnalyzer(org.neo4j.kernel.api.impl.fulltext.FulltextIndexSettings.createAnalyzer) Analyzer(org.apache.lucene.analysis.Analyzer) IOException(java.io.IOException) TokenNotFoundException(org.neo4j.token.api.TokenNotFoundException) DroppableLuceneIndex(org.neo4j.kernel.api.impl.index.DroppableLuceneIndex) PartitionedIndexStorage(org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage) ReadOnlyIndexPartitionFactory(org.neo4j.kernel.api.impl.index.partition.ReadOnlyIndexPartitionFactory)

Aggregations

IOException (java.io.IOException)1 Analyzer (org.apache.lucene.analysis.Analyzer)1 FulltextIndexSettings.createAnalyzer (org.neo4j.kernel.api.impl.fulltext.FulltextIndexSettings.createAnalyzer)1 DatabaseIndex (org.neo4j.kernel.api.impl.index.DatabaseIndex)1 DroppableLuceneIndex (org.neo4j.kernel.api.impl.index.DroppableLuceneIndex)1 ReadOnlyIndexPartitionFactory (org.neo4j.kernel.api.impl.index.partition.ReadOnlyIndexPartitionFactory)1 PartitionedIndexStorage (org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage)1 TokenNotFoundException (org.neo4j.token.api.TokenNotFoundException)1