Path Query in neo4j

牧云@^-^@ 提交于 2019-12-25 10:15:49

问题


This question is based on my earlier post on neo4j

I am trying to find out the names of the person living in city 'X'. I am using 2 nodes: Person and City for this purpose and a relationship exists [LIVES_IN]. I have created 4 nodes and 2 relationships as such:

CREATE (m:Person { name : 'sa', paswrd : 'abc' });
CREATE (n:Person { name : 'ti', paswrd : 'abc' });
CREATE (o:City { name : 'pune' });
CREATE (p:City { name : 'mumbai' });
CREATE (m)-[:LIVES_IN]->(o);
CREATE (n)-[:LIVES_IN]->(o);

Now, to get the persons who are living in 'pune' i try to write this query:

MATCH (x:City)<-[:LIVES_IN]-(y:Person) where x.name='pune' RETURN y.name;

But it returns:

==> +--------+
==> | y.name |
==> +--------+
==> +--------+
==> 0 row
==> 47 ms 

Can you please advise me how to do it, then? For your kind information, I am presently using Neo4j2.0.1


回答1:


It works for me. Are you sure you're running the same code you posted?

http://console.neo4j.org/r/p3cqal



来源:https://stackoverflow.com/questions/22382712/path-query-in-neo4j

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!