1

我有以下查询

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"] |
==> +------------------------------------------------------------------------------------------------------------------+

我想根据 rw 的排序值重新排序项目,如下所示

==> +------------------------------------------------------------------------------------------------------------------+
==> | 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(rw) 的排序值重新排列 collect(items.name) 的元素?

4

2 回答 2

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);
于 2013-06-12T09:14:20.043 回答
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);
于 2013-06-12T02:46:39.583 回答