Database

[{product:"Banana",timestamp:1672992000,price:5,},{product:"Banana",timestamp:1672992001,price:6,},{product:"Pineapple",timestamp:1672992000,price:9,},{product:"Pineapple",timestamp:1672992001,price:8,},{product:"Melon",timestamp:1672992005,price:15,},]

Query

db.collection.aggregate([{"$setWindowFields":{"partitionBy":"$product","sortBy":{timestamp:1},"output":{"lPrice":{$max:"$price","window":{"documents":[1,1]}}}}},{$match:{$expr:{$gt:["$lPrice","$price"]}}}])

Result