neo4j中的路径查询 [英] Path Query in neo4j

查看:434
本文介绍了neo4j中的路径查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题是基于我之前在neo4j上发布的 post

This question is based on my earlier post on neo4j

我正试图找出居住在城市"X"中的人的名字.我正在使用2个节点:Person和City,并且存在一个关系[LIVES_IN].我已经创建了4个节点和2个关系,

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;

但是它返回:

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

那么,您能告诉我该怎么做吗?为了您的方便,我目前正在使用Neo4j2.0.1

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

推荐答案

它对我有用.您确定运行的代码与发布的相同吗?

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

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

这篇关于neo4j中的路径查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆