【发布时间】:2011-09-22 19:46:16
【问题描述】:
我想查询我的 Mongodb 集合(名称:包装器)并检索所有具有以 '.com' 结尾的字段 'urls' 的文档
我不确定如何查询嵌套文档以及如何使用正则表达式进行查询。
我实际上是用 perl 编码的。但是,在 mongo shell 上运行的查询也可以。
提前致谢!
样本数据:
{ "_id" : ObjectId("4e7a34932cd4b16704000000"), "lastArray" : { "desc" : "google", "url" : "google.com", "data" : [
{
"name" : "1",
"xpath" : [ ],
"nodes" : [ ],
"type" : "Any Text"
},
{
"name" : "2",
"xpath" : [ ],
"nodes" : [ ],
"type" : "Any Text"
}
{ "_id" : ObjectId("4e7a34932cd4b16704000001"), "lastArray" : { "desc" : "yahoo", "url" : "yahoo.com", "data" : [
{
"name" : "1",
"xpath" : [ ],
"nodes" : [ ],
"type" : "Any Text"
},
{
"name" : "2",
"xpath" : [ ],
"nodes" : [ ],
"type" : "Any Text"
}
【问题讨论】: