How to Create a nested index in MongoDB?

后端 未结 3 778
暖寄归人
暖寄归人 2020-12-14 05:37

A. How do I index nested and all of it\'s values?

B. How do I index valuetwo?

{
    id: 00000,
    attrs: {
        nested:{
         


        
3条回答
  •  悲&欢浪女
    2020-12-14 06:34

    You'd create them just as if you were creating an index on a top level field:

    db.collection.ensureIndex({"attrs.nested.value": 1})
    

    You do need to explicitly create indexes on each field.

提交回复
热议问题