Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.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
Neo4j 按关系计数排序_Neo4j_Cypher - Fatal编程技术网

Neo4j 按关系计数排序

Neo4j 按关系计数排序,neo4j,cypher,Neo4j,Cypher,我有一个图表,看起来像这样: User->Friend->Area | (Which area does this friend live in) ------------->Area<-Friend<-Other users (Which area does this user live in) 用户->朋友->区域 |(这位朋友住在哪个地区) ------------->Areaarea如果我正确理解了您的

我有一个图表,看起来像这样:

User->Friend->Area 
|             (Which area does this friend live in)
------------->Area<-Friend<-Other users
              (Which area does this user live in)
用户->朋友->区域
|(这位朋友住在哪个地区)

------------->Areaarea如果我正确理解了您的问题,则返回的区域是正确的,但希望按用户数对其进行组织

在这种情况下,您需要一个子句来获取用户、他们,并需要一个子句来对他们进行排序:

START user=node(reference)
MATCH user-->friend-->area<-[r?:HAVE_A]-friend<--user
WHERE r is null
WITH area 
MATCH area<--users
RETURN area, COUNT(users) as cnt
ORDER BY cnt DESC
START user=node(参考)
匹配用户-->朋友-->区域
START user=node(reference)
MATCH user-->friend-->area<-[r?:HAVE_A]-friend<--user
WHERE r is null
WITH area 
MATCH area<--users
RETURN area, COUNT(users) as cnt
ORDER BY cnt DESC