According the documents below :
How do I get all documents that
field driver.vehicle.make = Powell Motors" and this field has the max year in the array ?
(It should return only doc 1 and doc 3)
I would like it will be executed in one query
doc 1 :
"driver": {
"last_name": "McQueen",
"vehicle": [
{
"make": "Powell Motors",
"model": "Canyonero",
"year": 2020
},
{
"make": "Miller-Meteor",
"model": "Ecto-1",
"year": 2005
}
]
}
doc 2 :
"driver": {
"last_name": "McQueen",
"vehicle": [
{
"make": "Powell Motors",
"model": "Canyonero",
"year": 1999
},
{
"make": "Miller-Meteor",
"model": "Ecto-1",
"year": 2018
}
]
}
doc 3 :
"driver": {
"last_name": "McQueen",
"vehicle": [
{
"make": "Powell Motors",
"model": "Canyonero",
"year": 2003
},
{
"make": "Miller-Meteor",
"model": "Ecto-1",
"year": 1998
}
]}