Arangodb Aql SORT不适用于边缘迭代

时间:2014-11-28 20:35:22

标签: arangodb aql

我尝试用'beginAt'属性对边迭代的结果进行排序,但它对我不起作用 遵循aql代码:

FOR f IN TRAVERSAL(client, careerEdges, "client/100", "outbound", {paths:true})

            let sorted = (
                FOR e IN f.path.edges
                    FILTER e.order <= 3
            SORT e.beginAt DESC
            RETURN e)

RETURN sorted

和'order'属性相同。始终返回相同的序列:

    [
  [],
  [
    {
      "_id": "careerEdges/240469605275",
      "_rev": "240469605275",
      "_key": "240469605275",
      "_from": "client/100",
      "_to": "careers/iniAlt",
      "order": 2,
      "$label": "noLonger",
      "beginAt": "2014-05-10 13:48:00",
      "endAt": "2014-07-20 13:48:00"
    }
  ],
  [
    {
      "_id": "careerEdges/240470064027",
      "_rev": "240470064027",
      "_key": "240470064027",
      "_from": "client/100",
      "_to": "careers/lidGru",
      "order": 3,
      "$label": "noLonger",
      "beginAt": "2014-07-20 13:48:00",
      "endAt": "2014-08-20 13:48:00"
    }
  ],
  [
    {
      "_id": "careerEdges/240469867419",
      "_rev": "240469867419",
      "_key": "240469867419",
      "_from": "client/100",
      "_to": "careers/iniEst",
      "endAt": null,
      "order": 1,
      "$label": "noLonger",
      "beginAt": "2014-06-10 13:48:00"
    }
  ]
]

我的查询是否正确?

1 个答案:

答案 0 :(得分:2)

您的查询正在生成列表列表。内部列表将按beginAt排序,但不是整体结果。

如果您想要返回一个平面列表并按某种标准对其进行排序,请改为尝试:

FOR f IN TRAVERSAL(client, careerEdges, "client/100", "outbound", {paths:true})
  FOR e IN f.path.edges
    FILTER e.order <= 3
    SORT e.beginAt DESC
    RETURN e