我有以下查询
neo4j-sh (?)$
$start n=node(*) match p=n-[r:LIKES]->items return n,collect(r.w),collect(items.name);
==> +------------------------------------------------------------------------------------------------------------------+
==> | n | collect(r.w) | collect(items.name) |
==> +------------------------------------------------------------------------------------------------------------------+
==> | Node[249]{name:"u1"} | [0,0.93] | ["f5","f2"] |
==> | Node[248]{name:"u2"} | [0,-0.76,1,-0.66] | ["f4","f3","f2","f1"] |
==> +------------------------------------------------------------------------------------------------------------------+
我想根据r.w的排序值重新排序项目,如下所示
==> +------------------------------------------------------------------------------------------------------------------+
==> | n | collect(r.w) | collect(items.name) |
==> +------------------------------------------------------------------------------------------------------------------+
==> | Node[249]{name:"u1"} | [0.93,0] | ["f2","f5"] |
==> | Node[248]{name:"u2"} | [1,0,-0.66,-0.76] | ["f2","f4","f1","f3"] |
==> +------------------------------------------------------------------------------------------------------------------+
如何根据collect(r.w)的排序值重新安排collect(items.name)的元素?
答案 0 :(得分:4)
我认为可能就像这样
START n=node(*)
MATCH p=n-[r:LIKES]->items
WITH n,r,items
ORDER BY r.w DESC, items.name DESC
RETURN n,collect(r.w),collect(items.name);
答案 1 :(得分:0)
通过WITH
管道您的搜索结果,然后对其进行排序。然后照常通过RETURN
进行聚合。
START n=node(*)
MATCH p=n-[r:LIKES]->items
WITH n,r,items
ORDER BY r.w DESC
RETURN n,collect(r.w),collect(items.name);