连接嵌套在嵌套在另一个数组中的数组中的数组
Concatenating arrays nested within arrays nested within another array
先不说我到底是怎么到这里的,谁能帮我在 mongo:
中使用聚合连接这些嵌套数组的内容
串联
{ "missing_users" : [
[
[
"attachment_5089820813-30177-ulr2vz.csv",
"User not found for 201610-EEC-100-A01-31562"
],
[
"attachment_50820160813-30177-ulr2vz.csv",
"User not found for 201610-EEC-001-001-31567"
],
[
"attachment_5089820813-30177-ulr2vz.csv",
"User not found for 201610-EEC-001-001-31547)"
],
],
[
[
"attachment_508160813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33550)"
],
[
"attachment_50520160813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33330)"
],
[
"attachment_50895813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33580)"
],
[
"attachment_50813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33450)"
],
[
"attachment_508916813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33550)"
]
]
]
}
我很乐意在深层嵌套数组中找到一个字符串数组,但我也真的只对最深层嵌套数组的第二个值感兴趣。
这就足够了:
results : ["attachment_5089820813-30177-ulr2vz.csv",
"User not found for 201610-EEC-100-A01-31562",
"attachment_5089820813-30177-ulr2vz.csv",
"User not found for 201610-EEC-100-A01-31562",
"attachment_5089820813-30177-ulr2vz.csv",
"User not found for 201610-EEC-100-A01-31562"]
但我真的只想要这个:
results : ["User not found for 201610-EEC-100-A01-31762",
"User not found for 201610-EEC-100-A01-31862",
"User not found for 201610-EEC-100-A01-35602"]
我正在尝试这个..以下有帮助吗?
s1:PRIMARY> db.ary.aggregate([{"$unwind":"$missing_users"},{"$unwind":"$missing_users"},{"$unwind":"$missing_users"},{"$group":{"_id":"$_id","missing_users":{"$push":"$missing_users"}}}]).pretty();
\输出
{
"_id" : ObjectId("57aead0a4d7aa623b01b5820"),
"missing_users" : [
"attachment_5089820813-30177-ulr2vz.csv",
"User not found for 201610-EEC-100-A01-31562",
"attachment_50820160813-30177-ulr2vz.csv",
"User not found for 201610-EEC-001-001-31567",
"attachment_5089820813-30177-ulr2vz.csv",
"User not found for 201610-EEC-001-001-31547)",
"attachment_508160813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33550)",
"attachment_50520160813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33330)",
"attachment_50895813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33580)",
"attachment_50813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33450)",
"attachment_508916813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33550)"
]
}
s1:PRIMARY>
先不说我到底是怎么到这里的,谁能帮我在 mongo:
中使用聚合连接这些嵌套数组的内容串联
{ "missing_users" : [
[
[
"attachment_5089820813-30177-ulr2vz.csv",
"User not found for 201610-EEC-100-A01-31562"
],
[
"attachment_50820160813-30177-ulr2vz.csv",
"User not found for 201610-EEC-001-001-31567"
],
[
"attachment_5089820813-30177-ulr2vz.csv",
"User not found for 201610-EEC-001-001-31547)"
],
],
[
[
"attachment_508160813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33550)"
],
[
"attachment_50520160813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33330)"
],
[
"attachment_50895813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33580)"
],
[
"attachment_50813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33450)"
],
[
"attachment_508916813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33550)"
]
]
]
}
我很乐意在深层嵌套数组中找到一个字符串数组,但我也真的只对最深层嵌套数组的第二个值感兴趣。
这就足够了:
results : ["attachment_5089820813-30177-ulr2vz.csv",
"User not found for 201610-EEC-100-A01-31562",
"attachment_5089820813-30177-ulr2vz.csv",
"User not found for 201610-EEC-100-A01-31562",
"attachment_5089820813-30177-ulr2vz.csv",
"User not found for 201610-EEC-100-A01-31562"]
但我真的只想要这个:
results : ["User not found for 201610-EEC-100-A01-31762",
"User not found for 201610-EEC-100-A01-31862",
"User not found for 201610-EEC-100-A01-35602"]
我正在尝试这个..以下有帮助吗?
s1:PRIMARY> db.ary.aggregate([{"$unwind":"$missing_users"},{"$unwind":"$missing_users"},{"$unwind":"$missing_users"},{"$group":{"_id":"$_id","missing_users":{"$push":"$missing_users"}}}]).pretty();
\输出
{
"_id" : ObjectId("57aead0a4d7aa623b01b5820"),
"missing_users" : [
"attachment_5089820813-30177-ulr2vz.csv",
"User not found for 201610-EEC-100-A01-31562",
"attachment_50820160813-30177-ulr2vz.csv",
"User not found for 201610-EEC-001-001-31567",
"attachment_5089820813-30177-ulr2vz.csv",
"User not found for 201610-EEC-001-001-31547)",
"attachment_508160813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33550)",
"attachment_50520160813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33330)",
"attachment_50895813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33580)",
"attachment_50813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33450)",
"attachment_508916813-28337-5qpqyb.csv",
"User not found for 201610-ETX-010-001-33550)"
]
}
s1:PRIMARY>