use of org.neo4j.kernel.api.schema.LabelSchemaDescriptor in project neo4j-apoc-procedures by neo4j-contrib.
the class SchemaIndex method getLuceneIndexReader.
private SimpleIndexReader getLuceneIndexReader(String label, String key) throws SchemaRuleNotFoundException, IndexNotFoundKernelException, DuplicateSchemaRuleException {
try (KernelStatement stmt = (KernelStatement) tx.acquireStatement()) {
ReadOperations reads = stmt.readOperations();
LabelSchemaDescriptor labelSchemaDescriptor = new LabelSchemaDescriptor(reads.labelGetForName(label), reads.propertyKeyGetForName(key));
IndexDescriptor descriptor = reads.indexGetForSchema(labelSchemaDescriptor);
IndexReader indexReader = stmt.getStoreStatement().getIndexReader(descriptor);
if (indexReader.getClass().getName().endsWith("FusionIndexReader")) {
try {
Field field = indexReader.getClass().getDeclaredField("luceneReader");
field.setAccessible(true);
return (SimpleIndexReader) field.get(indexReader);
} catch (IllegalAccessException | NoSuchFieldException e) {
throw new RuntimeException("Error accessing index reader", e);
}
}
return (SimpleIndexReader) indexReader;
}
}
Aggregations