所以我目前有一个neo4j cypher查询匹配某些值,在它返回数据之前我按照一个名为tid的属性进行排序
cql片段(我添加了可能有误的评论,但这是我认为它正在做的。如果我错了,请纠正我。):
// Neo will order by the attribute tid within the node box in ascending order
order by box.tid
// Neo will then collect each nodes values and set it eql to their respective collections
with user, mission, task, collect(box) as box
with user, mission, {task:collect(task), box:box} as task
with user, {mission:collect(mission), tasks:task} as mission
// Neo will return the values
return {user:user, mission:collect(mission)}
我遇到的问题是如何将返回的结果保存在box.tid
的排序位置但也是由mission.wid第二次再次订购?
我试过了:
order by box.tid
with user, mission, task, collect(box) as box
with user, mission, {task:collect(task), box:box} as task
with user, {mission:collect(mission), tasks:task} as mission
order by mission.wid
return {user:user, mission:collect(mission)}
但它只是不起作用,返回的结果仍然没有按mission.wid排序,但它似乎保留了上一个查询的顺序。
任何线索? 感谢。
答案 0 :(得分:0)
旁白:在您的第二个代码段中,我认为arsort( $scores );
$topScores = array_slice( $scores, 0, 3 );
行实际上是$topScoresStr = implode( ', ', array_keys( $topScores ) );
,我会相应地继续。
以下子代码段(来自您的第二个代码段)中的mission.wid
子句毫无意义。
ORDER BY mission.wid
它尝试按ORDER BY mission.wid
属性对WITH user, {mission:collect(mission), tasks:task} AS mission
ORDER BY mission.wid
对象进行排序,但该对象没有这样的属性(它只有mission
和wid
属性)。因此,它不会改变顺序。