I have a query like this (simplified):
db.report.aggregate([{
$match: {
main_id: ObjectId("58f0f67f50c6af16709fd2c7")
}
}, {
$group: {
_id: "$name",
count: {
$sum: 1
},
sum: {
$sum: {
$add: ["$P31", "$P32"]
}
}
}
}
])
I do this query from java, and I want to map it on my class, but I don't want '_id' to be mapped on 'name' field. Because if I do something like this:
@JsonProperty("_id")
private String name;
then when I save this data back to mongo (after some modification) the data is saved with name as '_id' while I want a real Id to be generated.
So, how can I rename '_id' after $group operation?