basically
Node pizza =
gdb.findByLabelAndProperty("Thing","name","Pizza").iterator().next();
Node iceCream = gdb.findByLabelAndProperty("Thing","name","Ice
Cream").iterator().next();
for (Relationship rel : pizza.getRelationships(Direction.INCOMING, Type.LIKES) {
Node person = rel.getStartNode();
if (connected(person,iceCream,Type.LIKES) result.add(person);
}
public boolean connected(Node from, Node to, RelationshipType type) {
for (Relationship rel : from.getRelationships(Direction.OUTGOING, type) {
if (rel.getEndNode().equals(to)) return true;
}
return false;
}
2) you can also collect person-nodes from both like's into a Set each and then
use set1.retailAll(set2)
3) you can also iterate over all people and check if the end-nodes of their
likes relationships are pizza AND ice-cream and if both then add them to the
result
Am 18.07.2014 um 14:07 schrieb ems eril <[email protected]>:
> Hi ,
>
> Im very new to Ne4j , I have the following model depicted in the digram
> attached to this message . I like to know how I can get all persons who like
> both pizza and ice cream using the JAVA API . I know how to do this in cypher
> but the traversal API is a bit getting use to and Im not sure how I can say
> using the API give me all person nodes who like both pizza and ice cream.
>
> Thanks in advance
>
> -ems
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.