graph - Find node having two distinct relationship in Cypher -


i newbie in cypher. trying find query returns nodes having more 1 relationship other nodes. please refer http://neo4j.com/docs/snapshot/images/cypher-match-graph.svg structure. trying find person has acted in movie(s) , father. when running below query, giving me 0 records:

start n=node(*) match (n)-[r]->() type(r)="acted_in" , type(r)="father" return n,count(n);  

however, when running below query, return data think not wanted:

start n=node(*) match (n)-[r]->() type(r)="acted_in" or type(r)="father" return n,count(n); 

so basically, need query fetch charlie sheen since acted in wall street movie , father of martin sheen

i have tried follow others saying in cypher query find nodes have 3 relationships or how retrieve nodes multiple relationships using cypher query or cypher query find nodes have 3 relationships not able fathom trick :(

any of appreciation !

the right way query is:

match (p:person)-[:acted_in]->(), (p)-[:father]->() return p 

you're looking :person node having , acted_in relationship , (since p used again) having :father relationship. i'm using anonymous nodes @ other end, since we're not interested in endpoint - fact connected interesting.

an alternative way express that:

match ()<-[:father]-(p:person)-[:acted_in]->() return p 

note shouldn't use start (unless querying manual indexes) more.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -