是否可能只返回包含Accessories
输入样本
[
{
"values":[
"Aerial and fa ade cables Accessories",
"LANmark 5 Shielded Cable",
"Market challenges"
],
"doc":"doc1"
},
{
"values":[
"Aerial and fa ade cables ",
"Tools Accessories"
],
"doc":"doc2"
}
]
预期产量
"Aerial and fa ade cables Accessories",
"Tools Accessories"
答案 0 :(得分:2)
此代码段应在此处运行:
Mongo v4.2.3
db.collection.aggregate([
{$unwind: "$values"},
{$match: { values: { $regex: /accessories/i } }},
{$project:{values: 1, _id: 0}}
])