Mongodb index creation problem

if the collection test has the following document format

{
        "_id" : ObjectId("123456"),
        "name" : "test",
        "body" : [
                {
                        "hash" : "123123123"
                }
        ]
}

how to create an index for the key hash at this time. The value of body is an array. So I"m a little confused

.
Jul.07,2021

db.test.createIndex({"body.hash": 1})
Menu