0
start n=node(22), p=node(1) match n<-[r1:FOLLOWS]-m-[r2:HAS]->k<-[r3:CONTAIN]-p return distinct [k.name]

我试图在这里返回 k 值的名称和重复时间,到目前为止,我无法做到。有没有一种使用密码查询的快速方法?

考虑这个例子:

["Acting","Acting","Acting","Acting","Mongodb","Mongodb","Neo4j","Neo4j","Nursing"]

我试图有类似的东西:

[["Acting",4], ["Mongodb",2], ["Neo4j",2], ["Nursing",1]]

注意:相同的名称(属性)表示相同的节点。

4

2 回答 2

2

找到了!:)

start n=node(22), p=node(1) match n<-[r1:FOLLOWS]-m-[r2:HAS]->k<-[r3:CONTAIN]-p return distinct [k.name] as skill, count(k) as count
于 2013-03-01T03:51:19.373 回答
0

如果您想进一步过滤计数(假设您只想要计数大于 5 的结果,您也可以将其包装在 WITH 语句中。又好又整洁。

    START n=node(22), p=node(1) 
    MATCH n<-[r1:FOLLOWS]-m-[r2:HAS]->k<-[r3:CONTAIN]-p 
    WITH distinct [k.name] as skill, count(k) as count
    WHERE count > 5
    RETURN skill, count
于 2013-03-18T12:12:37.433 回答