在如下的集合中:
product
{
id:'',
name:'',
model:[
{id,type:1,name:'1',...},{id,type:2,name:'2',...}...
],
...
},...
假设我们要查询所有包含{type:1,name:'1'}的产品记录,为了加快速度,创建如下索引
product.createIndex('idx_product_model',{'model.type':1,'model.name':1});
失败:
(shell):1 uncaught exception: -37
More than one fields are array type
Takes 0.001910s.
请问一下,这个为什么会报错?这个是一个数组【model】上的多个字段组合索引,没有涉及到多个数组啊。
那如果要实现在子文档上创建复合索引,该怎么建立?
期待回复