AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

reIndex(データベースコマンド)

reIndex

バージョン 6.0 から非推奨。

Attempting to run the reIndex command writes a warning message to the log.

Tip

In mongosh, this command can also be run through the db.collection.reIndex() helper method.

Helper methods are convenient for mongosh users, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.

The reIndex command drops all indexes on a collection and recreates them. This operation may be expensive for collections that have a large amount of data and/or a large number of indexes.

警告

このコマンドは、次の環境でホストされている配置で使用できます。

  • MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン

  • MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン

重要

このコマンドは、MongoDB Atlas クラスターではサポートされていません。すべてのコマンドに対する Atlas のサポートについては、「サポートされていないコマンド」を参照してください。

このコマンドの構文は、次のとおりです。

db.runCommand(
{
reIndex: <collection>
}
)

このコマンドは、次のフィールドを使用します。

フィールド
説明

reIndex

リインデックスするコレクションの名前。

MongoDB5.0 以降の場合、reIndex はスタンドアロンインスタンスでのみ実行できます。

reIndex はコレクションに対して排他的ロック(W)を取得し、完了するまでコレクションに対する他の操作をブロックします。

MongoDB でのロックの詳細については、「FAQ: 同時実行性」を参照してください。

Tip

MongoDB でのインデックス操作の動作の詳細については、「 入力されたコレクションでのインデックス ビルド 」を参照してください。