'why mongorestore restore indexes?

In document, https://www.mongodb.com/docs/database-tools/mongodump/#data-exclusion,There are the following instructions:

mongodump output only captures the documents in the database and does not include index data. mongorestore or mongod must then rebuild the indexes after restoring data.

But there is the output when i run command mongorestore --host=127.0.0.1:27018 --db=%dbname% --dir=%backup_path% --drop --objcheck --writeConcern="{w:1, wtimeout:500}" --stopOnError -vvvvv:

2022-05-05T11:41:24.611+0800    restoring indexes for collection mongodb.FunctionParam from metadata
2022-05-05T11:41:24.611+0800    index: &idx.IndexDocument{Options:primitive.M{"background":true, "name":"id_1", "unique":true, "v":2}, Key:primitive.D{primitive.E{Key:"id", Value:1}}, PartialFilterExpression:primitive.D(nil)}
2022-05-05T11:41:24.612+0800            run create Index command for indexes: id_1


Solution 1:[1]

By default mongorestore rebuild the indexes , if you want by some reason to restore only the data you may add the following option:

 --noIndexRestore

That prevents mongorestore from restoring and building indexes as specified in the corresponding mongodump output.

official monogDB docs

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 R2D2