I have following documents. Note that the top level document has ID and attribute1 in common with subDocument.
{
"ID": "1",
"attribute1": "123",
"subDocument": [
{
"ID": "2",
"attribute1": "456",
},
{
"ID": "3",
"attribute1": "567",
}
]
},
{
"ID": "4",
"attribute1": "123",
"subDocument": [
{
"ID": "5",
"attribute1": "456",
}
]
}
Now I need to have a query that can search based on ID and attribute1. If I give ID =1,attribute1="123", it should return the first top level document like following:
{
"ID": "1",
"attribute1": "123"
}
If I give ID =2,attribute1="456", it should return the item of subDocument like following:
{
"ID": "2",
"attribute1": "456",
}
How can I do that? playground