View a markdown version of this page

$listSearchIndexes - Amazon DocumentDB

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

$listSearchIndexes

バージョン 8.0.1 から新規。

Amazon DocumentDB の$listSearchIndexes集約ステージは、コレクション上の既存の検索インデックスに関する情報を返します。集約パイプラインの最初のステージである必要があります。

パラメータ

  • name: (オプション) 情報を返す検索インデックスの名前。省略すると、コレクション上のすべての検索インデックスが返されます。

出力フィールド

返される各ドキュメントには、次のフィールドが含まれます。

  • name: 検索インデックスの名前。

  • status: インデックスのビルド状態。READY (ビルド済みで有効)、 BUILDING (同時ビルドが進行中)、または FAILED (インデックスビルドが正常に完了しなかった) のいずれか。

  • queryable: インデックスを現在クエリの処理に使用できるかどうかを示すブール値。これはfalse、非表示のインデックス ( のままREADY) とFAILEDインデックス用です。非表示インデックスは、 が READYstatusが の場合queryableですfalse

  • latestDefinitionVersion: version (インデックス形式バージョン) と createdAt (インデックスが作成された時刻) を含むドキュメント。

[Syntax] (構文)

db.collection.aggregate([ { $listSearchIndexes: {} } ]) // Or filter by name: db.collection.aggregate([ { $listSearchIndexes: { name: "mySearchIndex" } } ])

例 (MongoDB シェル)

次の例は、 $listSearchIndexesステージを使用してコレクション上のすべての検索インデックスを一覧表示する方法を示しています。

クエリの例

db.movies.aggregate([ { $listSearchIndexes: {} } ]);

出力

[ { "name": "default", "status": "READY", "queryable": true, "latestDefinitionVersion": { "version": 2, "createdAt": ISODate("2026-05-11T21:12:57.974Z") } } ]

非表示のインデックスは残りREADYますが、 が報告されます。これはqueryable: false、非表示になっている間はクエリの処理に使用できないためです。

[ { "name": "myHiddenIndex", "status": "READY", "queryable": false, "latestDefinitionVersion": { "version": 2, "createdAt": ISODate("2026-05-11T21:12:57.974Z") } } ]

特定のインデックス名でフィルタリングするには:

db.movies.aggregate([ { $listSearchIndexes: { name: "default" } } ]);

コードの例

$listSearchIndexes ステージを使用するためのコード例を表示するには、使用する言語のタブを選択します。

Node.js
const { MongoClient } = require('mongodb'); async function example() { const client = new MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false'); try { await client.connect(); const db = client.db('test'); const collection = db.collection('movies'); // List all search indexes const allIndexes = await collection.aggregate([ { $listSearchIndexes: {} } ]).toArray(); console.log('All search indexes:', allIndexes); // List a specific search index by name const namedIndex = await collection.aggregate([ { $listSearchIndexes: { name: "default" } } ]).toArray(); console.log('Named index:', namedIndex); } finally { await client.close(); } } example();
Python
from pymongo import MongoClient def example(): client = MongoClient('mongodb://<username>:<password>@<cluster-endpoint>:27017/?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false') try: db = client['test'] collection = db['movies'] # List all search indexes all_indexes = list(collection.aggregate([ { '$listSearchIndexes': {} } ])) print('All search indexes:', all_indexes) # List a specific search index by name named_index = list(collection.aggregate([ { '$listSearchIndexes': { 'name': 'default' } } ])) print('Named index:', named_index) finally: client.close() example()