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]]
注意:相同的名称(属性)表示相同的节点。
答案 0 :(得分: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
答案 1 :(得分: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