Search in sources :

Example 1 with ReadableRelationshipIndex

use of org.neo4j.graphdb.index.ReadableRelationshipIndex in project neo4j by neo4j.

the class AutoIndexOperationsTest method shouldNotSeeDeletedRelationshipWhenQueryingWithStartAndEndNode.

@Test
public void shouldNotSeeDeletedRelationshipWhenQueryingWithStartAndEndNode() {
    RelationshipType type = MyRelTypes.TEST;
    long startId;
    long endId;
    Relationship rel;
    try (Transaction tx = db.beginTx()) {
        Node start = db.createNode();
        Node end = db.createNode();
        startId = start.getId();
        endId = end.getId();
        rel = start.createRelationshipTo(end, type);
        rel.setProperty("Type", type.name());
        tx.success();
    }
    try (Transaction tx = db.beginTx()) {
        ReadableRelationshipIndex autoRelationshipIndex = db.index().getRelationshipAutoIndexer().getAutoIndex();
        Node start = db.getNodeById(startId);
        Node end = db.getNodeById(endId);
        IndexHits<Relationship> hits = autoRelationshipIndex.get("Type", type.name(), start, end);
        assertEquals(1, count(hits));
        assertEquals(1, hits.size());
        rel.delete();
        autoRelationshipIndex = db.index().getRelationshipAutoIndexer().getAutoIndex();
        hits = autoRelationshipIndex.get("Type", type.name(), start, end);
        assertEquals(0, count(hits));
        assertEquals(0, hits.size());
        tx.success();
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) Relationship(org.neo4j.graphdb.Relationship) Node(org.neo4j.graphdb.Node) RelationshipType(org.neo4j.graphdb.RelationshipType) ReadableRelationshipIndex(org.neo4j.graphdb.index.ReadableRelationshipIndex) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Node (org.neo4j.graphdb.Node)1 Relationship (org.neo4j.graphdb.Relationship)1 RelationshipType (org.neo4j.graphdb.RelationshipType)1 Transaction (org.neo4j.graphdb.Transaction)1 ReadableRelationshipIndex (org.neo4j.graphdb.index.ReadableRelationshipIndex)1