Hello I am unable to convert the following mongoDB query into spring query, i have tried multiple ways, but did not get the result.
db.getCollection('FarmerCropDataLog').aggregate([
{
"$match" :
{
"cropData.crop" : "RICE",
"creationTime" :
{
$lt : 1551447981473.0
}
}
},
{
"$group" :
{
_id : null,
"average" :{
$avg : "$cropData.cropPrice"
},
"max" :{
$max : "$cropData.cropPrice"
},
"min":{
$min : "$cropData.cropPrice"
}
}
}
])
I have written follwing code, but unable to think about next step.
Query query = new Query();
query.addCriteria(Criteria.where(FarmerCropDataLog.Constants.CROP_LOG).elemMatch(Criteria.where(CropData.Constants.CROP).is(getComparisonSheet.getCrop())));
query.addCriteria(Criteria.where(FarmerCropDataLog.Constants.CREATION_TIME).gt(Year * DIFF));

