下面是我收集的文件MongoDB的错误
[0] => Array
(
[Patent] => Array
(
[allocation] => Array
(
[1] => Array
(
[r_1_a] => 17
)
)
[pn] => US20120101874A1
[id] => 52fb18775f44eaaf0a8b462a
)
)
我试图用$这个查询放松操作:
db.patents.aggregate([{'$unwind':'$allocation'}]);
这是给我的例外:
Error: Printing Stack Trace
at printStackTrace (src/mongo/shell/utils.js:37:15)
at DBCollection.aggregate (src/mongo/shell/collection.js:897:9)
at (shell):1:12
Wed Feb 12 16:31:09.515 aggregate failed: {
"errmsg" : "exception: $unwind: value at end of field path must be an array",
"code" : 15978,
"ok" : 0
} at src/mongo/shell/collection.js:898
帮我解决这个问题,因为我在数组上应用$ unwind。
如果你将文档显示为由mongo shell代替而不是PHP转储,那么这可能会更好。另外,你是否确定**所有**分配元素**都是**数组?这部分是有据可查的。 –
'“分配”:{“1”:{“r_1_a”:17}},'。这里是代表专利收集 – user199354
'分配'不是给你添加在你的评论中的数组。这是一个名为'“1”'的字段的子文档。您的文档保存代码不会保存为数组。 – WiredPrairie