GraphDatabaseService db = new TestGraphDatabaseFactory().newImpermanentDatabase();
try (Transaction tx = db.beginTx()) {
AutoIndexer<Relationship> autoIndexer = db.index().getRelationshipAutoIndexer();
autoIndexer.setEnabled(true);
autoIndexer.startAutoIndexingProperty("foo");
Infrastructure infrastructure = MappingInfrastructureFactoryBean.createDirect(db, null);
final Node node = db.createNode();
Relationship relationship = node.createRelationshipTo(node, DynamicRelationshipType.withName("KNOWS"));
relationship.setProperty("foo", "bar");
infrastructure.getEntityRemover().remove(relationship);
relationship = node.createRelationshipTo(node, DynamicRelationshipType.withName("KNOWS"));
relationship.setProperty("foo", "bar");
infrastructure.getGraphDatabase().remove(relationship);
tx.success();
}
}