ArangoDb Sort with Return Distinct 跳过正确的结果和错误的顺序

ArangoDb Sort with Return Distinct skip over correct results and in wrong order

我用 ArangoDB 3.0 收集了一个 100k 的文档。他们每个人都有一个非唯一的 "group" 属性,它是一个整数。我想通过以下查询唯一地获取所有这些:

  FOR entry IN Collection
  FILTER entry.group!=null
  SORT entry.group ASC
  RETURN DISTINCT entry.group

结果跳过几组,有时顺序错误

[//Missing 1 here
  2,
  3,
  5,
  ...
  204,
  53,//Wrong order
  205,

以下应该绕过早期版本 ArangoDB 中 RETURN DISTINCT 的限制,并且可能也更有效:

FOR x IN (
    FOR entry IN Collection
      FILTER entry.group
      RETURN DISTINCT entry.group )
  SORT x ASC
  RETURN x

来自手册:

Note: the order of results was undefined for RETURN DISTINCT until before ArangoDB 3.3. Starting with ArangoDB 3.3, RETURN DISTINCT will not change the order of the results it is applied on.