Hi All

I have a requirement where I must check if there is an already
existing relationship between two nodes (say N1 and N2). Right now,
I'm doing it as follows:

boolean found = false;
final Iterable<Relationship> currentRels =
N1.getRelationships(RelTypes.KNOWS, Direction.OUTGOING);
for (Relationship rel : currentRels) {
    found = rel.getEndNode().equals(N2);
    if (found) {
        do something - like add some property to the existing relationship;
        break;
    }
}
if (!found) {
    create new relationship between N1 and N2;
}

This means, for a high volume of data, all the relations going out of
N1 will be retrieved and checked - and this seems costly. I'm using
the 1.0 API, and wasn't able to find anything that would directly
check whether N1 has an outgoing relationship with N2 - like
N1.hasRelationship(N2, Direction.OUTGOING) - or something similar. I
think there was a similar mail sometime ago. Has there been any
updates lately which allows such checks? Or, is there any other direct
way to do this with the 1.0 API?

Regards
Arijit

-- 
"And when the night is cloudy,
There is still a light that shines on me,
Shine on until tomorrow, let it be."
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to