-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
in: aggregation-frameworkAggregation framework supportAggregation framework supporttype: bugA general bugA general bug
Description
itzvarman opened DATAMONGO-2546 and commented
I have data set after projecting project("name")
which gave you following data
{ "_id": 1, "name":"Maths" },
{ "_id": 1, "name":"Maths" },
{ "_id": 2, "name":"Science" },
{ "_id": 2, "name":"Science" }
I try to group using
group("_id").first("name").as("name")
It throws Invalid reference _id
error. But when I do like following its working fine
aggregationOperationContext -> {
return new Document("$group",
new Document("_id", "$_id").append("name", new Document("$first", "$name")));
}
Finally I projected the _id
field also, then group("_id").first("name").as("name")
working fine.
In my document class, I have private ObjectId _id;
Reference URL: https://stackoverflow.com/questions/61745356/group-by-id-doesnt-work-in-spring-data-mongodb?noredirect=1#comment109225421_61745356
Metadata
Metadata
Assignees
Labels
in: aggregation-frameworkAggregation framework supportAggregation framework supporttype: bugA general bugA general bug