Open
Description
Dmitry Bekrenev opened DATAMONGO-2611 and commented
An example we have next data:
{ "_id" : ObjectId("5f3a61e5145c553d7d463fb9"), "location" : [ 1, 2 ], "userId" : 1 }
{ "_id" : ObjectId("5f3a61eb145c553d7d463fba"), "location" : [ 3, 4 ], "userId" : 5 }
{ "_id" : ObjectId("5f3a61f2145c553d7d463fbb"), "location" : [ 6, 7 ], "userId" : 8 }
and next query:
{$group: {_id: {userId: "$userId", lat: {$arrayElemAt: ["$location", 1]}, lng: {$arrayElemAt: ["$location", 0]}}}}
Problem:
Looks like no way to implement the query by the Aggregation framework.
Expected behavior:
I expect that is will be possible to implement by next code:
val groupByUserIdAndLocation = Aggregation.group("userId")
.and(
ArrayOperators.arrayOf("location")
.elementAt(0)
).as("lng")
.and(ArrayOperators.arrayOf("location")
.elementAt(1)).as("lat")
Affects: 3.0.3 (Neumann SR3)