Answer the question
In order to leave comments, you need to log in
How to organize a search through subdocuments with an unknown intermediate node?
There is a structure:
{
"A" : {
"B1" : {
"C" : {
"K1" : {
"x" : NumberLong(12),
"y" : NumberLong(13)
}
}
},
"B2" : {
"C" : {
"K1" : {
"x" : NumberLong(35),
"y" : NumberLong(45)
},
"K2" : {
"x" : NumberLong(1),
"y" : NumberLong(0)
}
}
}
}
}
.aggregate([
{$match:{
"A.B1.C.K1":{
$exists:true
}
}},
{$project:{
"result":"A.B1.C.K1",
"category":"B1",
"_id":false
}}
]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question