@Override public ExplicitIndexRead indexRead() { return internal.indexRead(); }
@Override public IndexHits<Node> query( KernelTransaction ktx, String name, Object queryOrQueryObject, GraphDatabaseService graphDatabaseService ) throws ExplicitIndexNotFoundKernelException { NodeExplicitIndexCursor cursor = ktx.cursors().allocateNodeExplicitIndexCursor(); ktx.indexRead().nodeExplicitIndexQuery( cursor, name, queryOrQueryObject ); return new CursorWrappingNodeIndexHits( cursor, graphDatabaseService, ktx, name ); }
@Override public IndexHits<Relationship> get( KernelTransaction ktx, String name, String key, Object value, GraphDatabaseService graphDatabaseService ) throws ExplicitIndexNotFoundKernelException { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); ktx.indexRead().relationshipExplicitIndexLookup( cursor, name, key, value, -1, -1 ); return new CursorWrappingRelationshipIndexHits( cursor, graphDatabaseService, ktx, name ); }
@Override public IndexHits<Node> get( KernelTransaction ktx, String name, String key, Object value, GraphDatabaseService graphDatabaseService ) throws ExplicitIndexNotFoundKernelException { NodeExplicitIndexCursor cursor = ktx.cursors().allocateNodeExplicitIndexCursor(); ktx.indexRead().nodeExplicitIndexLookup( cursor, name, key, value ); return new CursorWrappingNodeIndexHits( cursor, graphDatabaseService, ktx, name ); }
@Override public IndexHits<Relationship> query( KernelTransaction ktx, String name, String key, Object queryOrQueryObject, GraphDatabaseService graphDatabaseService ) throws ExplicitIndexNotFoundKernelException { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); ktx.indexRead().relationshipExplicitIndexQuery( cursor, name, key, queryOrQueryObject,-1, -1 ); return new CursorWrappingRelationshipIndexHits( cursor, graphDatabaseService, ktx, name ); }
@Override public IndexHits<Node> query( KernelTransaction ktx, String name, String key, Object queryOrQueryObject, GraphDatabaseService graphDatabaseService ) throws ExplicitIndexNotFoundKernelException { NodeExplicitIndexCursor cursor = ktx.cursors().allocateNodeExplicitIndexCursor(); ktx.indexRead().nodeExplicitIndexQuery( cursor, name, key, queryOrQueryObject ); return new CursorWrappingNodeIndexHits( cursor, graphDatabaseService, ktx, name ); }
@Override public IndexHits<Relationship> query( KernelTransaction ktx, String name, Object queryOrQueryObject, GraphDatabaseService graphDatabaseService ) throws ExplicitIndexNotFoundKernelException { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); ktx.indexRead().relationshipExplicitIndexQuery( cursor, name, queryOrQueryObject, -1 , -1 ); return new CursorWrappingRelationshipIndexHits( cursor, graphDatabaseService, ktx, name ); }
@Deprecated @Description( "Search nodes in explicit automatic index. Replaces `START n=node:node_auto_index('key:foo*')`" ) @Procedure( name = "db.index.explicit.auto.searchNodes", mode = READ, deprecatedBy = EXPLICIT_INDEX_DEPRECATION ) public Stream<WeightedNodeResult> nodeAutoIndexSearch( @Name( "query" ) Object query ) { try ( Statement ignore = tx.acquireStatement() ) { NodeExplicitIndexCursor cursor = tx.cursors().allocateNodeExplicitIndexCursor(); tx.indexRead().nodeExplicitIndexQuery( cursor, "node_auto_index", query ); return toWeightedNodeResultStream( cursor ); } catch ( KernelException e ) { // auto index will not exist if no nodes have been added that match the auto-index rules return Stream.empty(); } }
@Deprecated @Description( "Search relationship in explicit automatic index. Replaces `START r=relationship:relationship_auto_index" + "('key:foo*')`" ) @Procedure( name = "db.index.explicit.auto.searchRelationships", mode = READ, deprecatedBy = EXPLICIT_INDEX_DEPRECATION ) public Stream<WeightedRelationshipResult> relationshipAutoIndexSearch( @Name( "query" ) Object query ) { try ( Statement ignore = tx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = tx.cursors().allocateRelationshipExplicitIndexCursor(); tx.indexRead().relationshipExplicitIndexQuery( cursor, "relationship_auto_index", query, -1, -1 ); return toWeightedRelationshipResultStream( cursor ); } catch ( KernelException e ) { // auto index will not exist if no relationships have been added that match the auto-index rules return Stream.empty(); } }
@Override public RelationshipIndex getOrCreateRelationshipIndex( String indexName, Map<String, String> customConfiguration ) { KernelTransaction ktx = transactionBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { if ( !ktx.indexRead().relationshipExplicitIndexExists( indexName, customConfiguration ) ) { // There's a sub-o-meta thing here where we create index config, // and the index will itself share the same IndexConfigStore as us and pick up and use // that. We should pass along config somehow with calls. ktx.indexWrite().relationshipExplicitIndexCreateLazily( indexName, customConfiguration ); } return new RelationshipExplicitIndexProxy( indexName, gds, transactionBridge ); } catch ( InvalidTransactionTypeKernelException e ) { throw new ConstraintViolationException( e.getMessage(), e ); } } }
@Override public Index<Node> getOrCreateNodeIndex( String indexName, Map<String,String> customConfiguration ) { KernelTransaction ktx = transactionBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { if ( !ktx.indexRead().nodeExplicitIndexExists( indexName, customConfiguration ) ) { // There's a sub-o-meta thing here where we create index config, // and the index will itself share the same IndexConfigStore as us and pick up and use // that. We should pass along config somehow with calls. ktx.indexWrite().nodeExplicitIndexCreateLazily( indexName, customConfiguration ); } return new ExplicitIndexProxy<>( indexName, ExplicitIndexProxy.NODE, gds, transactionBridge ); } catch ( InvalidTransactionTypeKernelException e ) { throw new ConstraintViolationException( e.getMessage(), e ); } }
@Deprecated @Description( "Get node from explicit automatic index. Replaces `START n=node:node_auto_index(key = 'A')`" ) @Procedure( name = "db.index.explicit.auto.seekNodes", mode = READ, deprecatedBy = EXPLICIT_INDEX_DEPRECATION ) public Stream<NodeResult> nodeAutoIndexSeek( @Name( "key" ) String key, @Name( "value" ) Object value ) { try ( Statement ignore = tx.acquireStatement() ) { NodeExplicitIndexCursor cursor = tx.cursors().allocateNodeExplicitIndexCursor(); tx.indexRead().nodeExplicitIndexLookup( cursor, "node_auto_index", key, value ); return toStream( cursor, id -> new NodeResult( graphDatabaseAPI.getNodeById( id ) ) ); } catch ( KernelException e ) { // auto index will not exist if no nodes have been added that match the auto-index rules return Stream.empty(); } }
@Override public IndexHits<Relationship> get( String key, Object valueOrNull, Node startNodeOrNull, Node endNodeOrNull ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); long source = startNodeOrNull == null ? NO_SUCH_NODE : startNodeOrNull.getId(); long target = endNodeOrNull == null ? NO_SUCH_NODE : endNodeOrNull.getId(); ktx.indexRead().relationshipExplicitIndexLookup( cursor, name, key, valueOrNull, source, target ); return new CursorWrappingRelationshipIndexHits( cursor, getGraphDatabase(), ktx, name ); } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } }
@Deprecated @Description( "Get relationship from explicit automatic index. Replaces `START r=relationship:relationship_auto_index(key " + "= 'A')`" ) @Procedure( name = "db.index.explicit.auto.seekRelationships", mode = READ, deprecatedBy = EXPLICIT_INDEX_DEPRECATION ) public Stream<RelationshipResult> relationshipAutoIndexSeek( @Name( "key" ) String key, @Name( "value" ) Object value ) { try ( Statement ignore = tx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = tx.cursors().allocateRelationshipExplicitIndexCursor(); tx.indexRead() .relationshipExplicitIndexLookup( cursor, "relationship_auto_index", key, value, -1, -1 ); return toStream( cursor, id -> new RelationshipResult( graphDatabaseAPI.getRelationshipById( id ) ) ); } catch ( KernelException e ) { // auto index will not exist if no relationships have been added that match the auto-index rules return Stream.empty(); } }
@Override public IndexHits<Relationship> query( String key, Object queryOrQueryObjectOrNull, Node startNodeOrNull, Node endNodeOrNull ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); long source = startNodeOrNull == null ? NO_SUCH_NODE : startNodeOrNull.getId(); long target = endNodeOrNull == null ? NO_SUCH_NODE : endNodeOrNull.getId(); ktx.indexRead().relationshipExplicitIndexQuery( cursor, name, key, queryOrQueryObjectOrNull, source, target ); return new CursorWrappingRelationshipIndexHits( cursor, getGraphDatabase(), ktx, name ); } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } }
@Override public IndexHits<Relationship> query( Object queryOrQueryObjectOrNull, Node startNodeOrNull, Node endNodeOrNull ) { KernelTransaction ktx = txBridge.get(); try ( Statement ignore = ktx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = ktx.cursors().allocateRelationshipExplicitIndexCursor(); long source = startNodeOrNull == null ? NO_SUCH_NODE : startNodeOrNull.getId(); long target = endNodeOrNull == null ? NO_SUCH_NODE : endNodeOrNull.getId(); ktx.indexRead().relationshipExplicitIndexQuery( cursor, name, queryOrQueryObjectOrNull, source, target ); return new CursorWrappingRelationshipIndexHits( cursor, getGraphDatabase(), ktx, name ); } catch ( ExplicitIndexNotFoundKernelException e ) { throw new NotFoundException( type + " index '" + name + "' doesn't exist" ); } } }
@Deprecated @Description( "Search relationship in explicit index. Replaces `START r=relationship:relIndex('key:foo*')`" ) @Procedure( name = "db.index.explicit.searchRelationships", mode = READ, deprecatedBy = EXPLICIT_INDEX_DEPRECATION ) public Stream<WeightedRelationshipResult> relationshipManualIndexSearch( @Name( "indexName" ) String manualIndexName, @Name( "query" ) Object query ) throws ProcedureException { try ( Statement ignore = tx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = tx.cursors().allocateRelationshipExplicitIndexCursor(); tx.indexRead().relationshipExplicitIndexQuery( cursor, manualIndexName, query, -1, -1 ); return toWeightedRelationshipResultStream( cursor ); } catch ( KernelException e ) { throw new ProcedureException( Status.LegacyIndex.LegacyIndexNotFound, "Relationship index %s not found", manualIndexName ); } }
@Deprecated @Description( "Search nodes in explicit index. Replaces `START n=node:nodes('key:foo*')`" ) @Procedure( name = "db.index.explicit.searchNodes", mode = READ, deprecatedBy = EXPLICIT_INDEX_DEPRECATION ) public Stream<WeightedNodeResult> nodeManualIndexSearch( @Name( "indexName" ) String manualIndexName, @Name( "query" ) Object query ) throws ProcedureException { try ( Statement ignore = tx.acquireStatement() ) { NodeExplicitIndexCursor cursor = tx.cursors().allocateNodeExplicitIndexCursor(); tx.indexRead().nodeExplicitIndexQuery( cursor, manualIndexName, query ); return toWeightedNodeResultStream( cursor ); } catch ( KernelException e ) { throw new ProcedureException( Status.LegacyIndex.LegacyIndexNotFound, "Node index %s not found", manualIndexName ); } }
@Deprecated @Description( "Get node from explicit index. Replaces `START n=node:nodes(key = 'A')`" ) @Procedure( name = "db.index.explicit.seekNodes", mode = READ, deprecatedBy = EXPLICIT_INDEX_DEPRECATION ) public Stream<NodeResult> nodeManualIndexSeek( @Name( "indexName" ) String explicitIndexName, @Name( "key" ) String key, @Name( "value" ) Object value ) throws ProcedureException { try ( Statement ignore = tx.acquireStatement() ) { NodeExplicitIndexCursor cursor = tx.cursors().allocateNodeExplicitIndexCursor(); tx.indexRead().nodeExplicitIndexLookup( cursor, explicitIndexName, key, value ); return toStream( cursor, id -> new NodeResult( graphDatabaseAPI.getNodeById( id ) ) ); } catch ( KernelException e ) { throw new ProcedureException( Status.LegacyIndex.LegacyIndexNotFound, "Node index %s not found", explicitIndexName ); } }
@Deprecated @Description( "Search relationship in explicit index, starting at the node 'in' and ending at 'out'." ) @Procedure( name = "db.index.explicit.searchRelationshipsBetween", mode = READ, deprecatedBy = EXPLICIT_INDEX_DEPRECATION ) public Stream<WeightedRelationshipResult> relationshipManualIndexSearchWithBoundNodes( @Name( "indexName" ) String indexName, @Name( "in" ) Node in, @Name( "out" ) Node out, @Name( "query" ) Object query ) throws ProcedureException { try ( Statement ignore = tx.acquireStatement() ) { RelationshipExplicitIndexCursor cursor = tx.cursors().allocateRelationshipExplicitIndexCursor(); tx.indexRead().relationshipExplicitIndexQuery( cursor, indexName, query, in.getId(), out.getId() ); return toWeightedRelationshipResultStream( cursor ); } catch ( KernelException e ) { throw new ProcedureException( Status.LegacyIndex.LegacyIndexNotFound, "Relationship index %s not found", indexName ); } }