use of org.neo4j.graphdb.index.RelationshipIndex in project neo4j by neo4j.
the class TestLuceneIndex method testNodeLocalRelationshipIndex.
@Test
public void testNodeLocalRelationshipIndex() {
RelationshipIndex index = relationshipIndex(LuceneIndexImplementation.EXACT_CONFIG);
RelationshipType type = withName("YO");
Node startNode = graphDb.createNode();
Node endNode1 = graphDb.createNode();
Node endNode2 = graphDb.createNode();
Relationship rel1 = startNode.createRelationshipTo(endNode1, type);
Relationship rel2 = startNode.createRelationshipTo(endNode2, type);
index.add(rel1, "name", "something");
index.add(rel2, "name", "something");
for (int i = 0; i < 2; i++) {
assertThat(index.query("name:something"), Contains.contains(rel1, rel2));
assertThat(index.query("name:something", null, endNode1), Contains.contains(rel1));
assertThat(index.query("name:something", startNode, endNode2), Contains.contains(rel2));
assertThat(index.query(null, startNode, endNode1), Contains.contains(rel1));
assertThat(index.get("name", "something", null, endNode1), Contains.contains(rel1));
assertThat(index.get("name", "something", startNode, endNode2), Contains.contains(rel2));
assertThat(index.get(null, null, startNode, endNode1), Contains.contains(rel1));
restartTx();
}
rel2.delete();
rel1.delete();
startNode.delete();
endNode1.delete();
endNode2.delete();
index.delete();
}
Aggregations