Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cypher/Neo4J:如何找到相互关联的邻居_Neo4j_Cypher - Fatal编程技术网

Cypher/Neo4J:如何找到相互关联的邻居

Cypher/Neo4J:如何找到相互关联的邻居,neo4j,cypher,Neo4j,Cypher,我正在玩Neo4J,我访问了个人和城市的节点。假设我访问过伦敦,我希望创建一个查询,返回您访问过的城市中不止一个人访问过的所有城市。但是,它一定不是你去过的城市。哇,真是太多了 我已经创建了一个示例案例。在本例中,所涉及的查询将返回巴黎市 把它贴进去玩 创建(Chris:person{name:'Chris'}),(Jeff:person{name:'Jeff'}),(Pete:person{name:'Pete'}),(Alex:person{name:'Alex'}),(John:perso

我正在玩Neo4J,我访问了个人和城市的节点。假设我访问过伦敦,我希望创建一个查询,返回您访问过的城市中不止一个人访问过的所有城市。但是,它一定不是你去过的城市。哇,真是太多了

我已经创建了一个示例案例。在本例中,所涉及的查询将返回巴黎市

把它贴进去玩

创建(Chris:person{name:'Chris'}),(Jeff:person{name:'Jeff'}),(Pete:person{name:'Pete'}),(Alex:person{name:'Alex'}),(John:person{name:'John'}),(伦敦:城市{name:'London'}),(巴黎:城市{name:'Paris'}),(孟贝:城市{名称:'Mumbay'}),(莫斯科:城市{名称:'Moskva'}),(西雅图:城市{名称:'Seattle'>,(Chris name:'Seattle'>-)-(访问过)->(伦敦),[:Jeff)->(伦敦)(约翰)(伦敦)(杰夫)(参观)(巴黎)(约翰)(巴黎)(杰夫)(参观)(西雅图)(伦敦)(克里斯)(伦敦)(参观)(杰夫)(伦敦)(参观)(杰夫)(伦敦)(参观)(约翰)(巴黎)(杰夫)(巴黎)(参观)(约翰)(西雅图)(西雅图)(杰夫)(皮特)(参观)(西雅图)(西雅图)-[拜访者]->(皮特),(克里斯)-[拜访者]->(蒙贝),(蒙贝)-[拜访者]->(克里斯),(亚历克斯)-[拜访者]->(蒙贝),(蒙贝)-[拜访者]->(亚历克斯),(亚历克斯)-[拜访者]->(莫斯科),(莫斯科)-[拜访者]->(亚历克斯),(皮特)-[拜访者]->(莫斯科),(莫斯科)-[拜访者]->(彼得)


有人能帮我吗?

我用你的数据创建了一个图形列表:

假设查询所依据的人是Chris:

MATCH (chris:person { name:'Chris' })-[:VISITED]->(city)<-[:VISITED]-(otherPerson)
MATCH (otherPerson)-[:VISITED]->(otherCity)
WHERE otherCity<>city
WITH otherCity.name AS cityName, collect(otherPerson.name) AS persons
WHERE length(persons)> 1
RETURN cityName
匹配(chris:person{name:'chris'})-[:访问过]>(城市)(其他城市)
其他城市在哪里
使用otherCity.name作为cityName,将(otherPerson.name)收集为persons
其中长度(人)>1
返回城市名称

太好了,谢谢!我也想做一个查询,显示去巴黎的路径(例如,我自己->伦敦->[John,Jeff]->巴黎),只显示这个。你知道怎么做吗?没关系,看起来像是我做的:匹配(chris:person{name:'chris})-[:访问]->(city)(otherCity)和user,otherCity,collect(otherPerson)作为persons WHERE length(persons)>1返回chris,persons,otherCity,length(persons)Great-添加otherCity以消除伦敦