Reputation: 1553
I have in a collection A 100k documents with ArangoDB 3.0. Each of them have a non-unique "group" properties which is an integer. I want to get all of them uniquely with the following query:
FOR entry IN Collection
FILTER entry.group!=null
SORT entry.group ASC
RETURN DISTINCT entry.group
The results skip over several group and sometimes in wrong order
[//Missing 1 here
2,
3,
5,
...
204,
53,//Wrong order
205,
Upvotes: 1
Views: 99
Reputation: 116870
The following should circumvent the limitations of RETURN DISTINCT in earlier versions of ArangoDB and might also be more efficient:
FOR x IN (
FOR entry IN Collection
FILTER entry.group
RETURN DISTINCT entry.group )
SORT x ASC
RETURN x
Upvotes: 1
Reputation: 116870
From the manual:
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.
Upvotes: 2