Docs Menu
Docs Home
/
Atlas
/ /

Atlas Search インデックスの管理

Atlas Search インデックスは、簡単に検索可能な形式でデータを分類するデータ構造であり、タームとタームを含むドキュメントの間をマッピングします。Atlas Search インデックスを使用すると、特定の識別子を使用してドキュメントをすばやく検索できます。Atlas Search を使用して Atlas クラスター内のデータをクエリするには、Atlas Search インデックスを構成する必要があります。

Atlas Search インデックスは、単一または複数のフィールドで作成できます。データのソートやフィルタリングによく使用するフィールドはインデックスを作成して、クエリ時に関連データを含むドキュメントをすばやく取得できるようにすることをお勧めします。

Atlas Search インデックスを作成および管理する際には、次の点を考慮してください。

Atlas Search インデックスを定義したコレクションに変更を加えた場合、クエリですぐに最新データを使用できない場合があります。ただし、mongot が変更ストリームをモニターすることにより、保存済みデータのコピーがアップデート可能になるため、Atlas Search インデックスの一貫性は最終的には維持されます。

インデックス定義を変更すると、mongot はバックグラウンドで新しいインデックスを自動的に再構築し、ダウンタイムがないことを確認するために、古いインデックスでクエリを処理し続けます。これは、mongot プロセスと mongod のプロセスを同じノードに配置する場合、または異なるノードに配置する場合に発生します。また、Atlas は、保管時の暗号化を有効化または無効化すると、インデックスを再構築します。

検索配置のトポロジーを変更すると、Atlas Search は古いノードを削除する前に、新しいノードにインデックスをプロビジョニングして構築し、クエリのダウンタイムを発生させません。

mongod プロセスと mongot プロセスの両方が同じノードで実行されるデプロイメントの場合、Atlas Search がインデックスの再構築を必要とする変更(インデックスの更新が必要な Atlas Search の機能など)を導入した場合、Atlas はインデックスをビルドするために追加のノードを無料で自動的に配置しますが、古いノードは引き続きクエリを処理します。

警告

Atlas Search インデックスが既に存在するコレクションをシャーディングする場合、コレクションがシャードに表示され始めるときにクエリのダウンタイムが短時間発生することがあります。また、シャードを Atlas Search インデックスなどのシャーディングされたコレクションに追加する場合、追加されたシャードで最初の同期プロセスが完了するまで、そのコレクションに対する検索クエリは失敗します。詳しくは、「最初の同期プロセス」を参照してください。

重要

$out 集計ステージを使用して既存の Atlas Search インデックスを持つコレクションを変更する場合は、その検索インデックスを削除して再作成する必要があります。可能であれば、$out の代わりに $merge を使用することを検討してください。

専用の検索ノードをデプロイすることにより、パフォーマンス、スケーラビリティ、およびリソース分離を向上できます。検索ノードをデプロイした場合、次の点を考慮してください。

  • シャードを追加、調整すると、Atlas Search インデックスの再構築がトリガーされます。 インデックスの再構築中、データは最新でない場合があります。 そのため、追加、調整されたシャードのデータにクエリを実行すると、失敗したり不正確な結果が返されることがあります。

  • Atlas Search インデックスでコレクションを再シャーディングする と、再シャーディング操作の完了時にコレクションの Atlas Search インデックスを使用できなくなります。 Atlas Search インデックスは、操作が完了してから 手動で 再ビルドする必要があります。

  • データベースのプライマリシャードを変更するためにコマンドを発行する場合、操作の完了時にこのデータベースにあるシャーディングされていないコレクションで Atlas Search インデックスを使用できなくなります。movePrimary操作が完了したら、Atlas Search インデックスを削除して新しい Atlas Search インデックスを作成し直す必要があります。

Atlas Search ノードアーキテクチャの詳細については、「Atlas Search 配置オプション」を参照してください。

Atlas Search に保存されるデータは、Atlas クラスターにあるコレクションのデータとまったく同じコピーではありませんが、ディスク領域とメモリをある程度必要とします。文字列の値を含むフィールドで store オプションを有効にするか、インデックスで保存済みソース フィールドを構成する場合、Atlas Search はディスクの特定フィールドと同一のコピーを保存し、ディスク領域を使用する可能性があります。

注意

コレクションに 16MB 以上のドキュメントが含まれている場合、Atlas Search はデータのインデックス作成に失敗します。この問題は、大きなドキュメントの更新操作によって変更ストリームイベントが 16MB の BSON 制限を超えた場合にも発生する可能性があります。これを回避するために、次のベストプラクティスを検討してください。

  • サブドキュメントや配列のサイズを最小限に抑えるように、ドキュメントを構造化してください。

  • 大規模なフィールド、サブドキュメント、または配列を更新または置換する操作は避けてください。

詳細については、「Change Streams 運用に関する推奨事項」および「大きなドキュメントのサイズを縮小する」を参照してください。

インデックス作成の同時実行数やその他のインデックス管理操作リクエストが多すぎる場合、Atlas Search は次のエラーを返します。

Too many concurrent requests. Please try again later.

一定時間が経過した後に再度試すことをお勧めします。

Atlas Search インデックスは、Atlas UI、Atlas Search API、Atlas CLI、 mongosh 、MongoDB Compass、 MongoDB ドライバーから作成、管理できます。


➤ ページの言語を選択ドロップダウン メニューを使用して、このページの手順のクライアントを設定します。


Atlas CLI を使用して Atlas Search インデックスを作成および管理するには、Atlas クラスターで MongoDB 6.0+ または 7.0+ を実行する必要があります。

を使用して Atlas Searchmongosh インデックスを作成および管理するには、Atlas クラスターでMongoDB6.0 + または7.0 + が実行されている必要があります。

Compass を使用して Atlas Search インデックスを作成および管理するには、Atlas クラスターでMongoDB7.0 + を実行する必要があります。

任意のクラスター層で Atlas Search インデックスをプログラムで作成および管理するには、次のMongoDBドライバー のいずれかを使用できます。

MongoDB ドライバー
ドライバーのバージョン

1.25.0 以上

3.9.0 以上

2.21.0 以上

1.13.0 以上

4.11.0 以上

9.0 以上

3.3.0 以上

5.2.0 以上

5.6.0 以上

1.17.0 以上

4.5 以上

2.19.2 以上

2.8.0 以上

5.2.0 以上

プロジェクトユーザー ロールまたはデータベースユーザー ロールを割り当てて、このガイドで説明されている Atlas Search インデックス アクションを実行するために必要なユーザー権限へのアクセスを付与できます。

次の表は、指定された Atlas Search アクションに対して、以下のプロジェクト ロールがサポートするアクセス モードを示しています。

ロール
Atlas Search アクション
Atlas UI
Atlas CLI
Atlas API [1]

Project Data Access Read Only またはそれ以上

Atlas Search インデックスとアナライザーを表示します。

Project Data Access Admin またはそれ以上

Atlas Search インデックスとアナライザーを作成、表示、更新、および削除します。

Atlas Search インデックスを作成、表示、更新、および削除するため。

[1] 各ロールは、Atlas Administration API で Atlas Search API エンドポイントのサブセットまたはフルセットを呼び出す権限を付与します。各ロールがアクセスを許可する API エンドポイントの説明については、Atlas Search アクション列を参照してください。

次の MongoDB データベース ロールは、指定された Atlas Search インデックス権限アクションをサポートします。

アクションの説明
データベース ロール
Atlas Search インデックスの権限アクション

Atlas Search インデックスを表示

Atlas Search インデックスを作成

Atlas Search インデックスを編集

Atlas Search インデックスを削除する

詳しくは、ロールと特権の概要 または 組み込みのロールと特権 を参照してください。

次のチュートリアルでは、選択した方法を使用して Atlas Search インデックスを作成する方法について説明します。

sample_mflix.movies コレクションのインデックスを作成する例のチュートリアルについては、「Atlas Search クイックスタート」を参照してください。クエリの設定に合わせてインデックスを定義する方法の概念的な概要については、「インデックスの定義」を参照してください。

Atlas Search は、Atlas CLI を使用して作成したローカル Atlas 配置で使用することもできます。 詳細については、「 Atlas 配置のローカル配置の作成 」を参照してください。

Atlas Search APIを使用して Atlas Searchインデックスを作成するには、次の手順に従います。

1

POST リクエストを search/indexes エンドポイントに送信します。

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--include \
--request POST "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/indexes" \
--data '
{
"collectionName": "<collection-name>",
"database": "<database-name>",
"name": "<index-name>",
"type": "search",
"definition":
{
"analyzer": "<analyzer-name>",
"searchAnalyzer": "<analyzer-name>",
"mappings": {
"dynamic": <boolean>,
"fields": { <field-definition> }
},
"numPartitions": <integer>,
"analyzers": [ {
<custom-analyzer-definition>
}
],
"storedSource": <boolean> | {
<stored-source-definition>
},
"synonyms": [
{
<synonym-mapping-definition>
}
]
}
}'

このエンドポイントの構文とパラメータについて詳しくは、「作成」を参照してください。

2

注意

Atlas ではコレクションが存在しない場合はインデックスを作成しませんが、その場合も 200 ステータスを返します。

Atlas CLI を使用して Atlas Search インデックスを作成するには、以下の手順に従います。

Atlas CLI を使用してクラスターの検索インデックスを作成するには、次のコマンドを実行します。

atlas clusters search indexes create [indexName] [options]

コマンド構文とパラメーターの詳細については、Atlas CLI ドキュメントの「atlas clusters search indexes create」を参照してください。

Atlas CLI を使用して指定したデプロイの検索インデックスを作成するには、次のコマンドを実行します。

atlas deployments search indexes create [indexName] [options]

コマンド構文とパラメーターの詳細については、Atlas CLI ドキュメントの「atlas deployments search indexes create」を参照してください。

Atlas CLI を使用してローカル Atlas 配置を作成する方法の詳細については、「ローカル Atlas 配置の作成」を参照してください。

Tip

参照: 関連リンク

次の例は、 atlas clustersまたはatlas deploymentsコマンドを使用して、構成ファイルを使用して非対話型モードで Atlas Search インデックスを作成する方法を示しています。

1
{
"collectionName": "movies",
"database": "sample_mflix",
"definition": {
"mappings": {
"dynamic": true
},
},
"name": "searchIndex"
}
2
  1. 次のいずれかのコマンドを実行します。

    クラウド配置

    atlas clusters search indexes create --file indexDef.json

    ローカル配置:

    atlas deployments search indexes create --file indexDef.json
  2. 配置を指定し、Enter キーを押します。

Atlas UI を使用して Atlas Search インデックスを作成するには、以下の手順を行います。

1

警告

ナビゲーションの改善が進行中

現在、新しく改善されたナビゲーション エクスペリエンスを展開しています。次の手順が Atlas UIのビューと一致しない場合は、プレビュー ドキュメントを参照してください。

  1. まだ表示されていない場合は、希望するプロジェクトを含む組織を選択しますナビゲーション バーのOrganizationsメニュー

  2. まだ表示されていない場合は、ナビゲーション バーのProjectsメニューから目的のプロジェクトを選択します。

  3. まだ表示されていない場合は、サイドバーの [Clusters] をクリックします。

    [ Clusters (クラスター) ] ページが表示されます。

2

GoAtlas Searchページには、サイドバー、Data Explorer 、またはクラスターの詳細ページから できます。

  1. サイドバーで、 Services見出しの下のAtlas Searchをクリックします。

    クラスターがない場合は、Create clusterをクリックしてクラスターを作成してください。詳細については、「 クラスターの作成 」を参照してください。

  2. プロジェクトに複数のクラスターがある場合は、Select cluster ドロップダウンから使用するクラスターを選択し、[Go to Atlas Search] をクリックします。

    Atlas Searchページが表示されます。

  1. クラスターの [Browse Collections] ボタンをクリックします。

  2. データベースを展開し、コレクションを選択します。

  3. コレクションのSearch Indexesタブをクリックします。

    Atlas Searchページが表示されます。

  1. クラスタの名前をクリックします。

  2. [Atlas Search] タブをクリックします。

    Atlas Searchページが表示されます。

3
4

ページで次の選択を行い、Next をクリックしてください。

Search Type

Atlas Search インデックス タイプを選択します。

Index Name and Data Source

以下の情報を指定してください。

  • Index Name: default

  • Database and Collection:

    • データベースの名前

    • コレクションの名前

Configuration Method

For a guided experience, select Visual Editor.

To edit the raw index definition, select JSON Editor.

注意

Atlas Search インデックスのデフォルト名は「default」です。この名前を変更しない場合、Atlas Search クエリのデフォルトの検索インデックスが使用され、その演算子では別の index オプションは指定されません。複数のインデックスを作成する場合は、インデックス全体で一貫性があり、内容がわかる命名規則を維持することをお勧めします。

5

デフォルトのインデックス定義は、ドキュメント内のフィールドを動的にマッピングしたもので、どのコレクションでも機能します。

インデックス定義をカスタマイズするには、次のインデックス構成を検討してください。

ビジュアル エディター フィールド
説明
必要性

Index Analyzer

コレクションのデータのインデックス作成に使用するアナライザを指定します。デフォルトでは、Atlas Search は標準アナライザ(lucene.standard)を使用します。

analyzer JSON 設定に対応します。

任意

Search Analyzer

テキストを検索する前にクエリ テキストに適用するアナライザを指定します。このフィールドを省略した場合、インデックスはデフォルトで以下の順序でアナライザを継承します。

  1. このフィールドのanalyzerオプション(指定されている場合)。

  2. インデックスsearchAnalyzerオプション(指定されている場合)。

  3. インデックスanalyzerオプション(指定されている場合)。

  4. lucene.standardアナライザ。

searchAnalyzer JSON 設定に対応します。

任意

Dynamic Mapping

フィールドの動的マッピングまたは静的マッピングを指定します。

デフォルトでは、動的マッピングは有効になっています。動的マッピングを無効にするには、dynamicOff に設定します。動的マッピングを無効にする場合は、インデックスを作成するフィールドを指定する必要があります。

動的および静的マッピングの詳細については、「フィールド マッピングの定義」をご覧ください。

mappings.dynamic JSON 設定に対応します。

必須

フィールド名
説明
必要性

analyzer

コレクションのデータのインデックス作成に使用するアナライザを指定します。デフォルトでは、Atlas Search は標準アナライザ(lucene.standard)を使用します。

任意

searchAnalyzer

テキストを検索する前にクエリ テキストに適用するアナライザを指定します。このフィールドを省略した場合、インデックスはデフォルトで以下の順序でアナライザを継承します。

  1. このフィールドのanalyzerオプション(指定されている場合)。

  2. インデックスsearchAnalyzerオプション(指定されている場合)。

  3. インデックスanalyzerオプション(指定されている場合)。

  4. lucene.standardアナライザ。

任意

mappings.dynamic

フィールドの動的マッピングまたは静的マッピングを指定します。動的マッピングを無効にするには、"dynamic":false に設定します。デフォルトでは、動的マッピングは有効になっています。動的マッピングを無効にする場合は、インデックスを作成するフィールドを指定する必要があります。動的マッピングと静的マッピングの詳細については、「インデックスの作成に関する参照」を参照してください。

必須

これらのインデックス定義設定の詳細については、「インデックスの作成に関する参照」を参照してください。

デフォルト設定に問題がなければ、先に進みます。Atlas Search インデックスを再定義する場合は、次の手順に進みます。

6
  1. 以下の設定のいずれかを変更するには [Refine Your Index] をクリックします。

    フィールド名
    説明
    必要性

    Field Mappings

    Index Configurations セクションの Dynamic Mapping が無効になっている場合は必須です。

    インデックスを作成するフィールドを指定します。

    1. Add Field MappingをクリックするとAdd Field Mappingウィンドウが開きます。

    2. フィールドに関する次の情報を指定します。

      • Field name - インデックスを作成するフィールドの名前。

      • Data Type - フィールドのデータ型。サポートされているデータ型とそのオプションについて詳しくは、「データ型」を参照してください。

    3. (任意)追加のプロパティを指定します。

      Add Field Mapping ウィンドウに追加の設定オプションの表が表示されます。これらのプロパティは、最後の手順で選択したデータ型によって異なります。

      サポートされているデータ型とそのオプションについて詳しくは、「データ型」を参照してください。

    4. (任意)マルチフィールドを追加します。

      Add Multi Field をクリックして、フィールドをインデックス化するための代替フィールドアナライザを設定します。詳しくは、「マルチアナライザ」を参照してください。

    5. [Add] をクリックしてフィールドを追加します。

      Actions 列のフィールドの省略記号(...)アイコンをクリックして、次の操作を実行できます。

      • Edit をクリックして、設定を変更します。

      • フィールドに追加のデータ型を設定するには、Add Data Type をクリックします。

      • Delete をクリックして、インデックスからフィールドを削除します。

    フィールドマッピングの定義の詳細については、「インデックスの作成に関する参照」を参照してください。

    mappings.fields JSON 設定に対応します。

    条件付き

    Stored Source Fields

    クエリ時の検索のために Atlas Search に保存するフィールドを指定します。Atlas Search では、サポートされているすべてのデータ型のフィールドをストアできます。

    フィールドの保存の詳細については、「Atlas Search インデックスに保存されたソース フィールドの定義」を参照してください。

    storedSource JSON 設定に対応します。

    任意

    Synonyms Mappings

    インデックスで使用するシノニム マッピングを指定します。

    シノニム マッピングを使用すると、同じアナライザで分析されたフィールドのみをクエリすることができます。

    シノニム マッピングの詳細については、「Atlas Searchインデックスでのシノニム マッピングの定義」を参照してください。

    synonyms JSON 設定に対応します。

    任意。

    Index Partitions

    フィールドオブジェクトが 2.1 00 億を超える場合に使用するパーティションの数。

    numPartitions JSON 設定に対応します。

    任意。

  2. [Save Changes] をクリックします。

  1. 次のいずれかの設定をインデックスに追加します。

    フィールド名
    説明
    必要性

    mappings.fields

    mappings.dynamicfalseの場合は必須です。

    インデックスを作成するフィールドを指定します。詳しくは「フィールドマッピングの定義」を参照してください。

    条件付き

    storedSource

    クエリ時の検索のために Atlas Search に保存するフィールドを指定します。Atlas Search では、サポートされているすべてのデータ型のフィールドをストアできます。

    フィールドの保存の詳細については、「Atlas Search インデックスに保存されたソース フィールドの定義」を参照してください。

    任意

    synonyms

    インデックスで使用するシノニム マッピングを指定します。

    シノニム マッピングを使用すると、同じアナライザで分析されたフィールドのみをクエリすることができます。

    シノニム マッピングの詳細については、「Atlas Searchインデックスでのシノニム マッピングの定義」を参照してください。

    任意

    numPartitions

    フィールドオブジェクトが 2.1 00 億を超える場合に使用するパーティションの数。

    任意。

    これらのインデックス定義設定の詳細については、「インデックスの作成に関する参照」を参照してください。

  2. [Next] をクリックします。

7

注意

デフォルトのインデックス定義 を下書きとして保存することはできません。Visual Editor を使用しており、インデックス定義に静的マッピングが含まれている場合は、インデックス定義をドラフトとして保存できます。

  1. [Cancel] をクリックします。

  2. [Save Draft] または [Delete Draft] をクリックします。

    重要

    保留中のインデックス ドラフトがある場合は、インデックスを新規作成できません。

    詳しくは、「Atlas Search インデックス ドラフトの再開または削除」を参照してください。

8

Atlas はインデックスが構築中であることを知らせるトースト(短時間の非インタラクティブ通知)を表示します。

9

新規作成したインデックスは Atlas Search タブに表示されます。インデックスを作成する間、Status フィールドには Build in Progress と表示されます。インデックスの作成が完了すると、Status フィールドの表示は Active になります。

注意

コレクションが大きいほど、インデックスの作成に時間がかかります。インデックスの作成が完了すると、メール通知が届きます。

mongosh を使用して Atlas Search インデックスを作成するには以下の手順に従います。

1

詳しくは、「 mongosh経由で接続 」を参照してください。

2

db.collection.createSearchIndex() メソッドを使用します。

このコマンドの構文は、次のとおりです。インデックス名を省略すると、Atlas Search はインデックスに default という名前を付けます。詳細については、「インデックスの作成に関する参照」を参照してください。

db.<collection>.createSearchIndex(
"<index-name>",
{
/* search index definition */
}
)

example-index という名前のインデックスを作成し、movies コレクションのフィールドに動的にインデックスするには、次のコマンドを実行します。

db.movies.createSearchIndex(
"example-index",
{ mappings: { dynamic: true } }
)
example-index

MongoDB Compass を使用して Atlas Search インデックスを作成するには以下の手順に従います。

1

Compass を開き、Atlas クラスターに接続します。詳細な手順については、「Compass 経由での接続」を参照してください。

2

Database 画面で、データベースの名前をクリックし、コレクションの名前をクリックします。

3
  1. [ Indexesタブをクリックし、[ ] を選択します。Search Indexes

  2. [ Create Indexをクリックして、インデックス作成ダイアログボックスを開きます。

  3. インデックスの名前を指定します。

    Atlas Search インデックスのデフォルト名は「default」です。この名前を変更しない場合、Atlas Search クエリのデフォルトの検索インデックスが使用され、その演算子では別の index オプションは指定されません。複数のインデックスを作成する場合は、インデックス全体で一貫性があり、内容がわかる命名規則を維持することをお勧めします。

  4. JSON Atlas Search インデックス定義を指定します。

    1{
    2 "analyzer": "<analyzer-for-index>",
    3 "searchAnalyzer": "<analyzer-for-query>",
    4 "mappings": {
    5 "dynamic": <boolean>,
    6 "fields": { <field-definition> }
    7 },
    8 "numPartitions": <integer>,
    9 "analyzers": [ <custom-analyzer> ],
    10 "storedSource": <boolean> | {
    11 <stored-source-definition>
    12 },
    13 "synonyms": [
    14 {
    15 <synonym-mapping-definition>
    16 }
    17 ]
    18}
    19
  5. [Create Search Index] をクリックします。

C ドライバーを使用して Atlas Search インデックスを作成するには、アプリケーションで検索インデックスを定義し、mongoc_collection_command_simple() メソッドを呼び出します。

注意

Atlas Search インデックス マネジメントのメソッドは非同期で実行されます。ドライバー メソッドは、正常に実行されたことを確認する前に戻ることができます。検索インデックスの現在のステータスを判別するには、$listSearchIndexes パイプライン ステージで集計操作を実行します。

1
2

次のサンプル アプリケーションでは、createSearchIndexes コマンドを指定して検索インデックスを定義します。次に、アプリケーションはコマンドと検索インデックス情報を BSON に変換し、この情報を mongoc_collection_command_simple() メソッドに渡して検索インデックスを作成します。詳細については、「インデックスの作成に関する参照」を参照してください。

#include <mongoc/mongoc.h>
#include <stdlib.h>
int main (void)
{
mongoc_client_t *client = NULL;
mongoc_collection_t *collection = NULL;
mongoc_database_t *database = NULL;
bson_error_t error;
bson_t cmd = BSON_INITIALIZER;
bool ok = true;
mongoc_init();
// Connect to your Atlas deployment
client = mongoc_client_new("<connectionString>");
if (!client) {
fprintf(stderr, "Failed to create a MongoDB client.\n");
ok = false;
goto cleanup;
}
// Access your database and collection
database = mongoc_client_get_database(client, "<databaseName>");
collection = mongoc_database_get_collection(database, "<collectionName>");
// Specify the command and the new index
const char *cmd_str = BSON_STR({
"createSearchIndexes" : "<collectionName>",
"indexes" : [ {
"name" : "<indexName>",
"definition" : {
"analyzer": "<indexAnalyzer>",
"searchAnalyzer": "<queryAnalyzer>",
"mappings": {
"dynamic": <boolean>,
"fields": { <fieldDefinition> }
},
"numPartitions": <integer>,
"analyzers": [ <customAnalyzer> ],
"storedSource": <boolean> | {
<storedSourceDefinition>
},
"synonyms": [
{
<synonymMappingDefinition>
}
]
}
} ]
});
// Convert your command to BSON
if (!bson_init_from_json(&cmd, cmd_str, -1, &error)) {
fprintf(stderr, "Failed to parse command: %s\n", error.message);
ok = false;
goto cleanup;
}
// Create the Atlas search index by running the command
if (!mongoc_collection_command_simple (collection, &cmd, NULL, NULL, &error)) {
fprintf(stderr, "Failed to run createSearchIndexes: %s\n", error.message);
ok = false;
goto cleanup;
}
printf ("Index created!\n");
cleanup:
mongoc_collection_destroy (collection);
mongoc_client_destroy (client);
mongoc_database_destroy (database);
bson_destroy (&cmd);
mongoc_cleanup ();
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}

次のサンプル アプリケーションでは、createSearchIndexes コマンドを使用して複数の検索インデックスを定義します。次に、アプリケーションはコマンドと検索インデックス情報を BSON に変換し、この情報を mongoc_collection_command_simple() メソッドに渡して検索インデックスを作成します。詳細については、「インデックスの作成に関する参照」を参照してください。

#include <mongoc/mongoc.h>
#include <stdlib.h>
int main (void)
{
mongoc_client_t *client = NULL;
mongoc_collection_t *collection = NULL;
mongoc_database_t *database = NULL;
bson_error_t error;
bson_t cmd = BSON_INITIALIZER;
bool ok = true;
mongoc_init();
// Connect to your Atlas deployment
client = mongoc_client_new("<connectionString>");
if (!client) {
fprintf(stderr, "Failed to create a MongoDB client.\n");
ok = false;
goto cleanup;
}
// Access your database and collection
database = mongoc_client_get_database(client, "<databaseName>");
collection = mongoc_database_get_collection(database, "<collectionName>");
// Specify the command and the new indexes
const char *cmd_str = BSON_STR({
"createSearchIndexes" : "<collectionName>",
"indexes" : [{
// Add your search index definition fields here
"name" : "<firstIndexName>"
},
{
// Add your search index definition fields here
"name" : "<secondIndexName>"
}]
});
// Convert your command to BSON
if (!bson_init_from_json(&cmd, cmd_str, -1, &error)) {
fprintf(stderr, "Failed to parse command: %s\n", error.message);
ok = false;
goto cleanup;
}
// Create the Atlas search indexes by running the command
if (!mongoc_collection_command_simple (collection, &cmd, NULL, NULL, &error)) {
fprintf(stderr, "Failed to run createSearchIndexes: %s\n", error.message);
ok = false;
goto cleanup;
}
printf ("Indexes created!\n");
cleanup:
mongoc_collection_destroy (collection);
mongoc_client_destroy (client);
mongoc_database_destroy (database);
bson_destroy (&cmd);
mongoc_cleanup ();
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
3
  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • インデックスを作成するデータベースとコレクション。

  • インデックスの名前。インデックス名を省略すると、Atlas Search はインデックスに default という名前を付けます。

  • 検索インデックスの定義。詳細については、「インデックスの作成に関する参照」を参照してください。

4
gcc -o create-index create-index.c $(pkg-config --libs --cflags libmongoc-1.0)
./create-index

C++ ドライバーを使用して Atlas Search インデックスを作成するには、アプリケーションで検索インデックスを定義し、create_one() メソッドを呼び出します。

注意

Atlas Search インデックスマネジメントのメソッドは非同期で実行されます。ドライバーメソッドは、正常に実行されたことを確認する前に戻ることができます。検索インデックスの現在の状態を確認するには、検索インデックスビューのインスタンスで list() メソッドを呼び出します。

1
2

次のサンプル アプリケーションでは、検索インデックスの名前と定義を search_index_model() メソッドに渡して、コレクション内のフィールドに動的にインデックスを付けます。次に、アプリケーションは検索インデックスの仕様を create_one() メソッドに渡して検索インデックスを作成します。詳細については、「インデックスの作成に関する参照」を参照してください。

#include <bsoncxx/builder/basic/document.hpp>
#include <bsoncxx/builder/basic/kvp.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/search_index_view.hpp>
using bsoncxx::builder::basic::kvp;
using bsoncxx::builder::basic::make_document;
using namespace mongocxx;
int main()
{
try
{
// Connect to your Atlas deployment
mongocxx::instance instance{};
mongocxx::uri uri("<connectionString>");
mongocxx::client client(uri);
// Access your database and collection
auto db = client["<databaseName>"];
auto collection = db["<collectionName>"];
// Create an index model with your index name and definition
auto siv = collection.search_indexes();
auto name = "<indexName>";
auto definition = make_document(kvp("mappings", make_document(kvp("dynamic", true))));
auto model = search_index_model(name, definition.view());
// Create the search index
siv.create_one(model);
std::cout << "Index created!" << std::endl;
}
catch (const std::exception& e)
{
std::cout<< "Exception: " << e.what() << std::endl;
}
return 0;
}

一度に複数の Atlas Search インデックスを作成することもできます。作成する検索インデックスごとに、検索インデックスの仕様を search_index_model() メソッドに渡します。次に、各検索インデックスをベクトルに追加し、そのベクトルを create_many() メソッドに渡して検索インデックスを作成します。

#include <bsoncxx/builder/basic/document.hpp>
#include <bsoncxx/builder/basic/kvp.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/search_index_view.hpp>
using bsoncxx::builder::basic::kvp;
using bsoncxx::builder::basic::make_document;
using namespace mongocxx;
int main()
{
try
{
// Connect to your Atlas deployment
mongocxx::instance instance{};
mongocxx::uri uri("<connectionString>");
mongocxx::client client(uri);
// Access your database and collection
auto db = client["<databaseName>"];
auto collection = db["<collectionName>"];
// Create index models and add them to a vector
auto siv = collection.search_indexes();
std::vector<search_index_model> models;
auto name1 = "<firstIndexName>";
auto definition1 = make_document(/* Add search index definition fields here */);
auto model1 = search_index_model(name1, definition1.view());
models.push_back(model1);
auto name2 = "<secondIndexName>";
auto definition2 = make_document(/* Add search index definition fields here */);
auto model2 = search_index_model(name2, definition2.view());
models.push_back(model2);
// Create the search indexes
siv.create_many(models);
std::cout << "Indexes created!" << std::endl;
}
catch (const std::exception& e)
{
std::cout<< "Exception: " << e.what() << std::endl;
}
return 0;
}
3
  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • インデックスを作成するデータベースとコレクション。

  • インデックスの名前。インデックス名を省略すると、Atlas Search はインデックスに default という名前を付けます。

4
g++ -o create-index create-index.cpp $(pkg-config --cflags --libs libmongocxx)
./create-index

.NET/C# ドライバーを使用して MongoDB Atlas Search 検索インデックスを作成するには、次の手順を行います。

  1. インデックスを定義する BsonDocument を構築します。

  2. BsonDocumentCreateOne() またはCreateOneAsync() メソッドに渡します。

1
  1. 以下のコマンドを実行して、csharp-create-index という新しいディレクトリを作成します。

    mkdir csharp-create-index
  2. 以下のコマンドを実行して、新しいディレクトリに変更します。

    cd csharp-create-index
  3. 以下のコマンドを実行して、プロジェクトを初期化します。

    dotnet new console
2

次のコマンドを実行します:

dotnet add package MongoDB.Driver
3

次のサンプル アプリケーションのプレースホルダー値を置き換えます。このサンプル アプリケーションは SearchIndexes.CreateOne コマンドを使用して Atlas Search インデックスを定義します。

説明

<connection-string>

Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

<databaseName>

インデックスを作成するデータベース。

<collectionName>

インデックスを作成するコレクション。

<IndexName>

インデックスの名前。インデックス名を省略すると、Atlas Search はインデックスに default という名前を付けます。

<IndexDefinition>

インデックスの定義。インデックス定義の構文については、「インデックスの作成に関する参照」を参照してください。

1using MongoDB.Bson;
2using MongoDB.Driver;
3
4// connect to your Atlas deployment
5var uri = "<connection-string>";
6
7var client = new MongoClient(uri);
8
9var db = client.GetDatabase("<databaseName>");
10var collection = db.GetCollection<BsonDocument>("<collectionName>");
11
12// define your Atlas Search index
13var index = new BsonDocument
14{
15 { "mappings", new BsonDocument
16 {
17 { "dynamic", true }
18 }
19 }
20};
21
22var result = collection.SearchIndexes.CreateOne(index, "<indexName>");
23Console.WriteLine(result);

次のサンプル アプリケーションのプレースホルダー値を置き換えます。このサンプル アプリケーションは SearchIndexes.CreateMany コマンドを使用して Atlas Search インデックスを定義します。

説明

<connection-string>

Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

<databaseName>

インデックスを作成するデータベース。

<collectionName>

インデックスを作成するコレクション。

<firstIndexName>

最初のインデックスの名前。

<lastIndexName>

最後のインデックスの名前。

<IndexDefinition>

インデックスの定義。インデックス定義の構文については、「インデックスの作成に関する参照」を参照してください。

1using MongoDB.Bson;
2using MongoDB.Driver;
3
4// connect to your Atlas deployment
5var uri = "<connection-string>";
6
7var client = new MongoClient(uri);
8
9var db = client.GetDatabase("<databaseName>");
10var collection = db.GetCollection<BsonDocument>("<collectionName>");
11
12// define your Atlas Search indexes
13var indexes = new List<CreateSearchIndexModel>
14{
15 new CreateSearchIndexModel(
16 "<firstIndexName>",
17 new BsonDocument
18 {
19 <IndexDefinition>// search index definition fields
20 }
21 ),
22 ...
23 new CreateSearchIndexModel(
24 "<lastIndexName>",
25 new BsonDocument
26 {
27 <IndexDefinition> // search index definition fields
28 }
29 )
30};
31
32var result = collection.SearchIndexes.CreateMany(indexes);
4

以下のコマンドを使用して、プロジェクトを実行します。

dotnet run csharp-create-index.csproj
default

Tip

API ドキュメント

このページのメソッドについて詳しくは、.NET/C# ドライバー用の APIドキュメント を参照してください。

Java ドライバーを使用して Atlas Search インデックスを作成するには、検索インデックスを定義するドキュメントを作成し、そのドキュメントを createSearchIndex() または createSearchIndexes() メソッドに渡します。

注意

Atlas Search インデックス マネジメントのメソッドは非同期で実行されます。ドライバー メソッドは、正常に実行されたことを確認する前に戻ることができます。インデックスの現在のステータスを確認するには、listSearchIndexes() メソッドを呼び出します。

1
2

次のサンプル アプリケーションでは、コレクション内のフィールドに動的インデックスを付ける検索インデックスを定義し、createSearchIndex() メソッドを実行してインデックスを作成します。詳細については、「インデックスの作成に関する参照」を参照してください。

import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
public class CreateIndex {
public static void main(String[] args) {
// connect to your Atlas cluster
String uri = "<connection-string>";
try (MongoClient mongoClient = MongoClients.create(uri)) {
// set namespace
MongoDatabase database = mongoClient.getDatabase("<databaseName>");
MongoCollection<Document> collection = database.getCollection("<collectionName>");
Document index = new Document("mappings",
new Document("dynamic", true));
collection.createSearchIndex("<index-name>", index);
}
}
}

次のサンプルアプリケーションを使用して、一度に複数の Atlas Search インデックスを作成できます。そのためには、作成する検索インデックスごとにドキュメントを作成し、そのドキュメントを配列として createSearchIndexes() メソッドに渡します。

import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.SearchIndexModel;
import org.bson.Document;
import java.util.Arrays;
public class CreateIndex {
public static void main(String[] args) {
// connect to your Atlas cluster
String uri = "<connection-string>";
try (MongoClient mongoClient = MongoClients.create(uri)) {
// set namespace
MongoDatabase database = mongoClient.getDatabase("<databaseName>");
MongoCollection<Document> collection = database.getCollection("<collectionName>");
SearchIndexModel indexOne = new SearchIndexModel("<first-index-name>",
new Document(
// search index definition fields
));
SearchIndexModel indexTwo = new SearchIndexModel("<second-index-name>",
new Document(
// search index definition fields
));
collection.createSearchIndexes(Arrays.asList(indexOne, indexTwo));
}
}
}
3
  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • インデックスを作成するデータベースとコレクション。

  • インデックスの名前。インデックス名を省略すると、Atlas Search はインデックスに default という名前を付けます。

4
javac CreateIndex.java
java CreateIndex

ノード ドライバーを使用して Atlas Search インデックスを作成する方法

  1. アプリケーションから検索インデックスを定義します。

  2. createSearchIndex または createSearchIndexes ヘルパー メソッドを実行します。

1
2

次のサンプル アプリケーション create-index.js のプレースホルダー値を置き換えます。このサンプル アプリケーションは createSearchIndex コマンドを使用して Atlas Search インデックスを定義します。

説明

<connectionString>

Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

<databaseName>

インデックスを作成するデータベース。

<collectionName>

インデックスを作成するコレクション。

<indexName>

インデックスの名前。 インデックス名を省略すると、Atlas Search はインデックスにdefaultという名前を付けます。

<IndexDefinition>

インデックスの定義。インデックス定義の構文については、「インデックスの作成に関する参照」を参照してください。

create-index.js
import { MongoClient } from "mongodb";
// connect to your Atlas deployment
const uri = "<connectionString>";
const client = new MongoClient(uri);
async function run() {
try {
const database = client.db("<databaseName>");
const collection = database.collection("<collectionName>");
// define your Atlas Search index
const index = {
name: "<indexName>",
definition: {
/* search index definition fields */
<indexDefinition>
}
}
// run the helper method
const result = await collection.createSearchIndex(index);
console.log(result);
} finally {
await client.close();
}
}
run().catch(console.dir);
説明

<connectionString>

Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

<databaseName>

インデックスを作成するデータベース。

<collectionName>

インデックスを作成するコレクション。

<indexName>

インデックスの名前。 インデックス名を省略すると、Atlas Search はインデックスにdefaultという名前を付けます。

<IndexDefinition>

インデックスの定義。インデックス定義の構文については、「インデックスの作成に関する参照」を参照してください。

次のサンプル アプリケーション create-index.js のプレースホルダー値を置き換えます。このサンプル アプリケーションは createSearchIndexes コマンドを使用して Atlas Search インデックスを定義します。

create-index.js
import { MongoClient } from "mongodb";
// connect to your Atlas deployment
const uri = "<connection-string>";
const client = new MongoClient(uri);
async function run() {
try {
const database = client.db("<databaseName>");
const collection = database.collection("<collectionName>");
// define an array of Atlas Search indexes
const indexes = [
{
name: "<first-index-name>",
definition: {
/* search index definition fields */
}
},
...
{
name: "<last-index-name>",
definition: {
/* search index definition fields */
}
}
]
// run the helper method
const result = await collection.createSearchIndexes(indexes);
console.log(result);
} finally {
await client.close();
}
}
run().catch(console.dir);
3

以下のコマンドを使用します。

node create-index.js
<index-name>

Python ドライバーを使用して Atlas Search インデックスを作成するには、アプリケーションから検索インデックスを定義し、create_search_index() メソッドを呼び出します。

注意

Atlas Search インデックス マネジメントのメソッドは非同期で実行されます。ドライバー メソッドは、正常に実行されたことを確認する前に戻ることができます。検索インデックスの現在のステータスを確認するには、コレクションで list_search_indexes() メソッドを呼び出します。

1
2

次のサンプル アプリケーションでは、コレクション内のフィールドに動的にインデックスを付ける検索インデックスを定義します。次に、アプリケーションはコレクションの create_search_index() メソッドを呼び出して検索インデックスを作成します。詳細については、「インデックスの作成に関する参照」を参照してください。

from pymongo.mongo_client import MongoClient
from pymongo.operations import SearchIndexModel
def create_index():
# Connect to your Atlas deployment
uri = "<connectionString>"
client = MongoClient(uri)
# Access your database and collection
database = client["<databaseName>"]
collection = database["<collectionName>"]
# Create your index model, then create the search index
search_index_model = SearchIndexModel(
definition={
"mappings": {
"dynamic": True
},
},
name="<indexName>",
)
result = collection.create_search_index(model=search_index_model)
print(result)

一度に複数の Atlas Search インデックスを作成することもできます。アプリケーションで、検索インデックスの配列を定義します。そして、その配列を create_search_indexes() メソッドのパラメーターとして渡します。

from pymongo.mongo_client import MongoClient
from pymongo.operations import SearchIndexModel
def create_indexes():
# Connect to your Atlas deployment
uri = "<connectionString>"
client = MongoClient(uri)
# Access your database and collection
database = client["<databaseName>"]
collection = database["<collectionName>"]
# Create your index models and add them to an array
first_model = SearchIndexModel(
definition={
# Add search index definition fields here
},
name="<firstIndexName>",
)
second_model = SearchIndexModel(
definition={
# Add search index definition fields here
},
name="<secondIndexName>",
)
idx_models = [first_model, second_model]
# Create the search indexes
result = collection.create_search_indexes(models=idx_models)
print(result)
3
  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • インデックスを作成するデータベースとコレクション。

  • インデックスの名前。インデックス名を省略すると、Atlas Search はインデックスに default という名前を付けます。

4
python create_index.py

Atlas Search インデックスを作成すると、Atlas Search ページに Atlas Search インデックスに関する情報が表示されます。Status 列には、クラスターのプライマリノードにおけるインデックスの現在の状態が表示されます。詳細については、「インデックス ステータスの確認」を参照してください。

警告

Atlas Search インデックスが既に存在するコレクションをシャーディングする場合、コレクションがシャードに表示され始めるときにクエリのダウンタイムが短時間発生することがあります。また、シャードを Atlas Search インデックスなどのシャーディングされたコレクションに追加する場合、追加されたシャードで最初の同期プロセスが完了するまで、そのコレクションに対する検索クエリは失敗します。詳しくは、「最初の同期プロセス」を参照してください。


➤ [言語の選択] ドロップダウン メニューを使用して、このセクションの手順の言語を設定します。


Atlas Search API を使用して Atlas Search インデックスを取得するには、以下の手順に従います。

1

取得する Atlas Search インデックスの一意の ID または名前を指定して、 GETリクエストをsearch/indexes/エンドポイントに送信します。

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \ --header "Accept: application/json" \
--include \
--request GET "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/indexes/{indexId}"

どちらのエンドポイントの構文とパラメータの詳細についても、「名前1 つ取得 」および「 ID を使用して 1 つの取得 」を参照してください。

2

コレクションのすべての Atlas Search インデックスを取得するには:

1

インデックスを取得するコレクションの名前を指定して、 search/indexes/エンドポイントGETリクエストを送信します。

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \ --header "Accept: application/json" \
--include \
--request GET "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/indexes/{databaseName}/{collectionName}"
2

クラスターのすべての Atlas Search インデックスを取得するには:

1

検索対象のインデックスを持つクラスターの名前を指定して、 search/indexes/エンドポイントGETリクエストを送信します。

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \ --header "Accept: application/json" \
--include \
--request GET "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/indexes"
2

Atlas CLI を使用してクラスターのすべての検索インデックスを一覧表示するには、次のコマンドを実行します。

atlas clusters search indexes list [options]

Atlas CLI を使用して、指定した検索インデックスの詳細を返すには、次のコマンドを実行します。

atlas clusters search indexes describe <indexId> [options]

前のコマンドの構文とパラメーターの詳細については、Atlas CLI ドキュメントのAtlas クラスター検索インデックス リストおよびAtlas クラスター検索インデックスの説明を参照してください。

Atlas CLI を使用して指定した配置の指定された検索インデックスを記述するには、次のコマンドを実行します。

atlas deployments search indexes describe [indexId] [options]

Atlas CLI を使用して、指定したデプロイのすべての検索インデックスを一覧表示するには、次のコマンドを実行します。

atlas deployments search indexes list [options]

前のコマンドの構文とパラメータの詳細については、Atlas CLI ドキュメントの「Atlas配置Atlas Searchインデックスの説明」および「Atlas配置Atlas Searchインデックス リスト」を参照してください。

Atlas UI Atlas Search ページを表示するには、以下の手順に従います。

1

警告

ナビゲーションの改善が進行中

現在、新しく改良されたナビゲーション エクスペリエンスを導入中です。次の手順が Atlas UI の表示と一致しない場合は、プレビュー ドキュメントを参照してください。

  1. まだ表示されていない場合は、希望するプロジェクトを含む組織を選択しますナビゲーション バーのOrganizationsメニュー

  2. まだ表示されていない場合は、ナビゲーション バーのProjectsメニューから目的のプロジェクトを選択します。

  3. まだ表示されていない場合は、サイドバーの [Clusters] をクリックします。

    [ Clusters (クラスター) ] ページが表示されます。

2

GoAtlas Searchページには、サイドバー、Data Explorer 、またはクラスターの詳細ページから できます。

  1. サイドバーで、 Services見出しの下のAtlas Searchをクリックします。

    クラスターがない場合は、Create clusterをクリックしてクラスターを作成してください。詳細については、「 クラスターの作成 」を参照してください。

  2. プロジェクトに複数のクラスターがある場合は、Select cluster ドロップダウンから使用するクラスターを選択し、[Go to Atlas Search] をクリックします。

    Atlas Searchページが表示されます。

  1. クラスターの [Browse Collections] ボタンをクリックします。

  2. データベースを展開し、コレクションを選択します。

  3. コレクションのSearch Indexesタブをクリックします。

    Atlas Searchページが表示されます。

  1. クラスタの名前をクリックします。

  2. [Atlas Search] タブをクリックします。

    Atlas Searchページが表示されます。

Atlas Search ページには、プロジェクト内の既存の Atlas Search 検索インデックスを以下の列に記述する表があります。

コラム
説明

Database

コレクションを含むデータベースの名前。

Collection

インデックス作成されたコレクションの名前。

Index Name

インデックスの名前。

Status

クラスターのプライマリ ノード上のインデックスのステータス。詳しくは「Atlas Search インデックスのステータス」を参照してください。

Queryable

インデックスを使用してコレクションがクエリできるかどうかを識別するアイコン。値は次のいずれかのアイコンにすることができます。

  • - コレクションをクエリするために使用できるインデックスの場合。

  • X - コレクションをクエリするために使用できないインデックスの場合。

Type

インデックスのタイプ。値は、次のいずれかのタイプのインデックスです。

Index Fields

インデックス作成されたフィールド。動的マッピングを有効にした場合、値は dynamic です。静的マッピングの場合、列にはインデックス作成されたすべてのフィールドが表示されます。

Documents

クラスタ上のプライマリノードまたは検索ノードでのインデックス構築中および構築後の、コレクション内のドキュメント総数に占めるインデックス作成されたドキュメントのおおよその数と割合。

Size

インデックスのサイズ。

Required Memory

クエリの実行に必要なメモリの概算。Atlas ベクトル検索インデックスにのみ適用されます。

Actions

インデックスに対して実行できるアクション:

  • Query をクリックすると、コレクションをクエリするための Search Tester に移動します。

  • をクリックして、インデックスに対して実行する次のアクションのいずれかを選択します。

デフォルトでは、Atlas はインデックスを最初にデータベース名、次にコレクション名の順にソートします。複数の列でソートするには、Shift を押して、インデックスのリストをマルチソートしたい順序で列名をクリックします。

この表から次のセクションに移動して、各インデックスの詳細を確認できます。

Atlas Search ページから Index Overview ページに移動するには、Index Name 列で表示したいインデックスの名前をクリックします。各インデックスについて、Index Overview 名前空間ページにはインデックスの名前空間とインデックス定義で指定された次の構成が表示されます。

説明

インデックスアナライザ

検索インデックスを構築する際にテキストの処理とトークン化を指定する選択されたテキストアナライザー。

searchAnalyzer

検索クエリのテキストがどのように処理され、トークン化されるかを指定する選択されたテキストアナライザー。

ダイナミックマッピング

フィールドマッピングで動的または静的マッピングを有効にしたかどうかを示すブール値

フィールド マッピング

フィールド名、データ型、個々のフィールドで動的マッピングが有効かどうかなど、指定されたすべてのフィールドマッピング

保存済みソース フィールド

同義語マッピング

同等の単語に対して定義されたシノニム マッピング

mongoshを通じて Atlas Search インデックスを検索するには、 db.collection.getSearchIndexes()メソッドを使用します。

このコマンドの構文は、次のとおりです。 インデックス名を省略すると、Atlas Search はコレクションのすべてのインデックスを返します。

db.<collection>.getSearchIndexes("<index-name>")

次のコマンドは、 moviesコレクションからdefaultという名前の検索インデックスを検索します。 結果は出力例のようになります。

db.movies.getSearchIndexes("default")
[
{
id: '648b4ad4d697b73bf9d2e5e0',
name: 'default',
status: 'READY',
queryable: true,
latestDefinition: { mappings: { dynamic: true } }
}
]
1

Compass を開き、Atlas クラスターに接続します。詳細な手順については、「Compass 経由での接続」を参照してください。

2

Database 画面で、データベースの名前をクリックし、コレクションの名前をクリックします。

3

このページには、次の内容が表示されます。

列名
説明

Name and Fields

インデックスの名前とインデックス化されたフィールドの名前。

Type

インデックスのタイプ。値は Search または Vector Search になります。

Status

インデックスのステータス。詳細については、「インデックス ステータスの確認」を参照してください。

アクション

インデックスにカーソルを合わせたときに実行できるアクション。次のアクションを実行できます。

  • 集計 - Aggregations タブに切り替え、インデックスを使用してクエリを実行します。

  • - 未加工の JSON 形式でインデックスを編集します。

  • - インデックスを削除します。

C ドライバーを使用して Atlas Search インデックスを取得するには、 mongoc_collection_aggregate()メソッドを使用して、 $listSearchIndexesステージを含む集計パイプラインを作成します。

1
2

次のサンプル アプリケーションでは、 集計パイプライン の$listSearchIndexesステージを指定します。 次に、アプリケーションはパイプラインとターゲット コレクションをmongoc_collection_aggregate()メソッドに渡します。 このメソッドは、コードが各 Atlas Search インデックスにアクセスして出力するカーソルを返します。

#include <mongoc/mongoc.h>
#include <stdlib.h>
int main (void)
{
mongoc_client_t *client = NULL;
mongoc_collection_t *collection = NULL;
mongoc_database_t *database = NULL;
bson_error_t error;
bson_t cmd = BSON_INITIALIZER;
bool ok = true;
bson_t pipeline = BSON_INITIALIZER;
mongoc_cursor_t *cursor = NULL;
mongoc_init();
// Connect to your Atlas deployment
client = mongoc_client_new("<connectionString>");
if (!client) {
fprintf(stderr, "Failed to create a MongoDB client.\n");
ok = false;
goto cleanup;
}
// Access your database and collection
database = mongoc_client_get_database(client, "<databaseName>");
collection = mongoc_database_get_collection(database, "<collectionName>");
// Create an aggregation pipeline with the $listSearchIndexes stage
const char *pipeline_str =
BSON_STR ({"pipeline" : [ {"$listSearchIndexes" : {}} ]});
// Convert your aggregation pipeline to BSON
if (!bson_init_from_json(&pipeline, pipeline_str, -1, &error)) {
fprintf(stderr, "Failed to parse command: %s\n", error.message);
ok = false;
goto cleanup;
}
// Run the aggregation operation and iterate through the indexes returned
cursor = mongoc_collection_aggregate (collection,
MONGOC_QUERY_NONE,
&pipeline,
NULL,
NULL);
const bson_t *got;
char *str;
while (mongoc_cursor_next (cursor, &got)) {
str = bson_as_canonical_extended_json (got, NULL);
printf ("%s\n", str);
bson_free (str);
}
if (mongoc_cursor_error (cursor, &error)) {
fprintf (stderr, "Failed to iterate all documents: %s\n", error.message);
ok = false;
goto cleanup;
}
cleanup:
mongoc_cursor_destroy(cursor);
mongoc_collection_destroy(collection);
mongoc_database_destroy(database);
mongoc_client_destroy(client);
bson_destroy(&pipeline);
bson_destroy(&cmd);
mongoc_cleanup ();
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
3
  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • インデックスを取得するデータベースとコレクション。

4
gcc -o view-index view-index.c $(pkg-config --libs --cflags libmongoc-1.0)
./view-index

C++ ドライバーを使用して Atlas Search インデックスを取得するには、検索インデックス ビューでlist()メソッドを呼び出します。

1
2

次のサンプル アプリケーションでは、ターゲット コレクションのsearch_indexes()メソッドを使用して検索インデックス ビューをインスタンス化します。 次に、アプリケーションはビューでlist()メソッドを呼び出します。 このメソッドは、コードが各 Atlas Search インデックスにアクセスして出力するカーソルを返します。

#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/search_index_view.hpp>
using namespace mongocxx;
int main()
{
mongocxx::instance instance{};
try
{
// Connect to your Atlas deployment
mongocxx::uri uri("<connectionString>");
mongocxx::client client(uri);
// Access your database and collection
auto db = client["<databaseName>"];
auto collection = db["<collectionName>"];
// Access and print the indexes in your collection
auto siv = collection.search_indexes();
auto cursor = siv.list();
for (auto&& doc : cursor) {
std::cout << bsoncxx::to_json(doc) << std::endl;
};
}
catch (const std::exception& e)
{
std::cout<< "Exception: " << e.what() << std::endl;
}
return 0;
}
3
  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • インデックスを取得するデータベースとコレクション。

4
g++ -o view-index view-index.cpp $(pkg-config --cflags --libs libmongocxx)
./view-index

.NET/C# ドライバー を使用して Atlas Search インデックスを取得するには、 メソッドまたはList() ListAsync()メソッドを使用します。

次のサンプル アプリケーションは、 コレクションのインデックスを返します。 次の値を指定します。

  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • 検索対象の検索インデックスを含むデータベースとコレクション。

注意

List()メソッドは、インデックス自体ではなくカーソルを返します。 インデックスにアクセスするには、 MoveNext()メソッドなどのカーソル パラダイムを使用します。

Program.cs
using MongoDB.Bson;
using MongoDB.Driver;
// connect to your Atlas deployment
var uri = "<connection-string>";
var client = new MongoClient(uri);
var db = client.GetDatabase("<databaseName>");
var collection = db.GetCollection<BsonDocument>("<collectionName>");
// list your Atlas Search indexes
var result = collection.SearchIndexes.List().ToList();
foreach (var index in result)
{
Console.WriteLine(index);
}

サンプル アプリケーションを実行するには、csharp-list-indexes という名前の新しい .NET コンソール プロジェクトを作成し、前のサンプル コードを Program.cs ファイルにコピーします。次に、以下のコマンドを使ってプロジェクトを実行します。

dotnet run csharp-list-indexes.csproj
<indexes for this collection>

Tip

API ドキュメント

このページのメソッドについて詳しくは、.NET/C# ドライバー用の APIドキュメント を参照してください。

Java ドライバーを使用してコレクションの Atlas Search インデックスを検索するには、 listSearchIndexes()メソッドを使用します。 Java ドライバーv 4.11.0以上が必要です。

1
2

次のサンプルアプリケーションは、特定のコレクションのすべての Atlas Search インデックスを検索します。

1import com.mongodb.client.MongoClient;
2import com.mongodb.client.MongoClients;
3import com.mongodb.client.MongoCollection;
4import com.mongodb.client.MongoCursor;
5import com.mongodb.client.MongoDatabase;
6import org.bson.Document;
7public class ViewIndex {
8 public static void main(String[] args) {
9 // connect to your Atlas cluster
10 String uri = "<connection-string>";
11 try (MongoClient mongoClient = MongoClients.create(uri)) {
12 // set namespace
13 MongoDatabase database = mongoClient.getDatabase("<database-name>");
14 MongoCollection<Document> collection = database.getCollection("<collection-name>");
15 // retrieve indexes
16 try (MongoCursor<Document> resultsCursor = collection.listSearchIndexes().iterator()) {
17 while (resultsCursor.hasNext()) {
18 System.out.println(resultsCursor.next());
19 }
20 }
21 }
22 }
23}
3
  • <connection-string> - Atlas接続文字列。 詳しくは、「ドライバーによる接続 」を参照してください。

  • <database-name> - コレクションを含むデータベースの名前。

  • <collection-name> - インデックスを検索するコレクションの名前。

4
javac ViewIndex.java
java ViewIndex

Node Driverを通じて Atlas Search インデックスを検索するには、 listSearchIndexesヘルパー メソッドを使用します。

コレクションのインデックスを返すには、 list-indexes.jsという名前の次のサンプル アプリケーションを使用します。 次の値を指定します。

  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • 検索対象の検索インデックスを含むデータベースとコレクション。

  • 特定のインデックスを検索する場合は、インデックス名。 コレクションのすべてのインデックスを返すには、この値を省略します。

注意

listSearchIndexesコマンドはカーソルを返します。 その結果、 コマンドに一致するインデックスはすぐに返されません。 結果にアクセスするには、 toArray()メソッドなどのカーソル パラダイムを使用します。 詳細については、「カーソルからデータにアクセスする 」を参照してください。

list-indexes.js
import { MongoClient } from "mongodb";
// connect to your Atlas deployment
const uri = "<connection-string>";
const client = new MongoClient(uri);
async function run() {
try {
const database = client.db("<databaseName>");
const collection = database.collection("<collectionName>");
// run the helper method
const result = await collection.listSearchIndexes("<index-name>").toArray();
console.log(result);
} finally {
await client.close();
}
}
run().catch(console.dir);

サンプル アプリケーションを実行するには、次のコマンドを使用します。 結果は出力例のようになります。

node list-indexes.js
[
{
id: '648b4ad4d697b73bf9d2e5e0',
name: 'default',
status: 'READY',
queryable: true,
latestDefinition: { mappings: { dynamic: true } }
},
{
id: '648b4ad4d697b73bf9d2e5e1',
name: 'example-index',
status: 'PENDING',
queryable: false,
latestDefinition: {
mappings: { dynamic: false, fields: { text: { type: 'string' } } }
}
}
]

Python ドライバーを使用して Atlas Search インデックスを取得するには、コレクションでlist_search_indexes()メソッドを呼び出します。

1
2

次のサンプル アプリケーションでは、コレクションでlist_search_indexes()メソッドを呼び出します。 このメソッドは、コードが各 Atlas Search インデックスにアクセスして出力するカーソルを返します。

from pymongo.mongo_client import MongoClient
def view_index():
# Connect to your Atlas deployment
uri = "<connectionString>"
client = MongoClient(uri)
# Access your database and collection
database = client["<databaseName>"]
collection = database["<collectionName>"]
# Get a list of the collection's search indexes and print them
cursor = collection.list_search_indexes()
for index in cursor:
print(index)
3
  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • インデックスを取得するデータベースとコレクション。

4
python view_index.py

Atlas UI でドラフトとして保存したインデックス定義を再開または削除するには以下の手順に従います。

重要

保留中のインデックス ドラフトがある場合は、インデックスを新規作成できません。

1

警告

ナビゲーションの改善が進行中

現在、新しく改良されたナビゲーション エクスペリエンスを導入中です。次の手順が Atlas UI の表示と一致しない場合は、プレビュー ドキュメントを参照してください。

  1. まだ表示されていない場合は、希望するプロジェクトを含む組織を選択しますナビゲーション バーのOrganizationsメニュー

  2. まだ表示されていない場合は、ナビゲーション バーのProjectsメニューから目的のプロジェクトを選択します。

  3. まだ表示されていない場合は、サイドバーの [Clusters] をクリックします。

    [ Clusters (クラスター) ] ページが表示されます。

2

GoAtlas Searchページには、サイドバー、Data Explorer 、またはクラスターの詳細ページから できます。

  1. サイドバーで、 Services見出しの下のAtlas Searchをクリックします。

    クラスターがない場合は、Create clusterをクリックしてクラスターを作成してください。詳細については、「 クラスターの作成 」を参照してください。

  2. プロジェクトに複数のクラスターがある場合は、Select cluster ドロップダウンから使用するクラスターを選択し、[Go to Atlas Search] をクリックします。

    Atlas Searchページが表示されます。

  1. クラスターの [Browse Collections] ボタンをクリックします。

  2. データベースを展開し、コレクションを選択します。

  3. コレクションのSearch Indexesタブをクリックします。

    Atlas Searchページが表示されます。

  1. クラスタの名前をクリックします。

  2. [Atlas Search] タブをクリックします。

    Atlas Searchページが表示されます。

3
4
  1. [Cancel] をクリックします。

  2. [Save Draft] または [Delete Draft] をクリックします。

5
  1. インデックス構成を変更するには、Refine Your Index をクリックします。

  2. [Save Changes] をクリックします。

6

Atlas はインデックスが構築中であることを知らせるトースト(短時間の非インタラクティブ通知)を表示します。

7

新規作成したインデックスは Atlas Search タブに表示されます。インデックスを作成する間、Status フィールドには Build in Progress と表示されます。インデックスの作成が完了すると、Status フィールドの表示は Active になります。

注意

コレクションが大きいほど、インデックスの作成に時間がかかります。インデックスの作成が完了すると、メール通知が届きます。

既存の Atlas Search インデックスのインデックス定義を変更できます。 インデックスの名前は変更できません。インデックスの名前を変更する必要がある場合は、新しいインデックスを作成し、古いインデックスを削除する必要があります。

Atlas Search インデックスを編集するには、Atlas UI を使用します。また、mongosh、Atlas CLI、API のいずれかを使用するか、任意の言語でサポート対象の MongoDB ドライバーを使用してプログラム的にも編集できます。


➤ [言語の選択] ドロップダウン メニューを使用して、このセクションの手順の言語を設定します。


APIを通じて Atlas Search インデックスを編集するには、次の手順に従います。

1

変更する Atlas Search インデックスの一意の ID または名前を指定して、 PATCHリクエストをsearch/indexes/エンドポイントに送信します。

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--include \
--request PATCH "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/indexes/{indexId}" \
--data '
{
"definition":
{
"analyzer": "lucene.<analyzer>",
"analyzers": [
{
"charFilters": [ ... ],
"name": "string",
"tokenFilters": [ ... ],
"tokenizer": { ... }
}
],
"mappings": {
"dynamic": true | false,
"fields": {
"property1": {},
...
}
},
"searchAnalyzer": "<analyzer-name>",
"storedSource": {
"include | exclude": [...]
},
"synonyms": [
{
<synonym-mapping-definition>
}
}
]
}
}'

どちらのエンドポイントの構文とパラメータの詳細についても、「名前を使用して1 つの更新 」および「 ID を使用して 1 つの更新 」を参照してください。

2

Atlas CLI を使用してクラスターの検索インデックスを更新するには、次のコマンドを実行します。

atlas clusters search indexes update <indexId> [options]

コマンド構文とパラメーターについて詳しくは、「Atlas クラスター検索インデックス更新」の Atlas CLI ドキュメントを参照してください。

1

警告

ナビゲーションの改善が進行中

現在、新しく改良されたナビゲーション エクスペリエンスを導入中です。次の手順が Atlas UI の表示と一致しない場合は、プレビュー ドキュメントを参照してください。

  1. まだ表示されていない場合は、希望するプロジェクトを含む組織を選択しますナビゲーション バーのOrganizationsメニュー

  2. まだ表示されていない場合は、ナビゲーション バーのProjectsメニューから目的のプロジェクトを選択します。

  3. まだ表示されていない場合は、サイドバーの [Clusters] をクリックします。

    [ Clusters (クラスター) ] ページが表示されます。

2

GoAtlas Searchページには、サイドバー、Data Explorer 、またはクラスターの詳細ページから できます。

  1. サイドバーで、 Services見出しの下のAtlas Searchをクリックします。

    クラスターがない場合は、Create clusterをクリックしてクラスターを作成してください。詳細については、「 クラスターの作成 」を参照してください。

  2. プロジェクトに複数のクラスターがある場合は、Select cluster ドロップダウンから使用するクラスターを選択し、[Go to Atlas Search] をクリックします。

    Atlas Searchページが表示されます。

  1. クラスターの [Browse Collections] ボタンをクリックします。

  2. データベースを展開し、コレクションを選択します。

  3. コレクションのSearch Indexesタブをクリックします。

    Atlas Searchページが表示されます。

  1. クラスタの名前をクリックします。

  2. [Atlas Search] タブをクリックします。

    Atlas Searchページが表示されます。

3
  • Edit With Visual Editor ガイドを利用したエクスペリエンスが必要です。

  • Edit With JSON Editor 未加工のインデックス定義を編集する。

4

次のインデックス構成設定を確認します。

ビジュアル エディター フィールド
説明
必要性

Index Analyzer

コレクションのデータのインデックス作成に使用するアナライザを指定します。デフォルトでは、Atlas Search は標準アナライザ(lucene.standard)を使用します。

analyzer JSON 設定に対応します。

任意

Search Analyzer

テキストを検索する前にクエリ テキストに適用するアナライザを指定します。このフィールドを省略した場合、インデックスはデフォルトで以下の順序でアナライザを継承します。

  1. このフィールドのanalyzerオプション(指定されている場合)。

  2. インデックスsearchAnalyzerオプション(指定されている場合)。

  3. インデックスanalyzerオプション(指定されている場合)。

  4. lucene.standardアナライザ。

searchAnalyzer JSON 設定に対応します。

任意

Dynamic Mapping

フィールドの動的マッピングまたは静的マッピングを指定します。

デフォルトでは、動的マッピングは有効になっています。動的マッピングを無効にするには、dynamicOff に設定します。動的マッピングを無効にする場合は、インデックスを作成するフィールドを指定する必要があります。

動的および静的マッピングの詳細については、「フィールド マッピングの定義」をご覧ください。

mappings.dynamic JSON 設定に対応します。

必須

次の詳細構成設定を確認します。

フィールド名
説明
必要性

Field Mappings

Index Configurations セクションの Dynamic Mapping が無効になっている場合は必須です。

インデックスを作成するフィールドを指定します。

  1. Add Field MappingをクリックするとAdd Field Mappingウィンドウが開きます。

  2. フィールドに関する次の情報を指定します。

    • Field name - インデックスを作成するフィールドの名前。

    • Data Type - フィールドのデータ型。サポートされているデータ型とそのオプションについて詳しくは、「データ型」を参照してください。

  3. (任意)追加のプロパティを指定します。

    Add Field Mapping ウィンドウに追加の設定オプションの表が表示されます。これらのプロパティは、最後の手順で選択したデータ型によって異なります。

    サポートされているデータ型とそのオプションについて詳しくは、「データ型」を参照してください。

  4. (任意)マルチフィールドを追加します。

    Add Multi Field をクリックして、フィールドをインデックス化するための代替フィールドアナライザを設定します。詳しくは、「マルチアナライザ」を参照してください。

  5. [Add] をクリックしてフィールドを追加します。

    Actions 列のフィールドの省略記号(...)アイコンをクリックして、次の操作を実行できます。

    • Edit をクリックして、設定を変更します。

    • フィールドに追加のデータ型を設定するには、Add Data Type をクリックします。

    • Delete をクリックして、インデックスからフィールドを削除します。

フィールドマッピングの定義の詳細については、「インデックスの作成に関する参照」を参照してください。

mappings.fields JSON 設定に対応します。

条件付き

Stored Source Fields

クエリ時の検索のために Atlas Search に保存するフィールドを指定します。Atlas Search では、サポートされているすべてのデータ型のフィールドをストアできます。

フィールドの保存の詳細については、「Atlas Search インデックスに保存されたソース フィールドの定義」を参照してください。

storedSource JSON 設定に対応します。

任意

Synonyms Mappings

インデックスで使用するシノニム マッピングを指定します。

シノニム マッピングを使用すると、同じアナライザで分析されたフィールドのみをクエリすることができます。

シノニム マッピングの詳細については、「Atlas Searchインデックスでのシノニム マッピングの定義」を参照してください。

synonyms JSON 設定に対応します。

任意。

Index Partitions

フィールドオブジェクトが 2.1 00 億を超える場合に使用するパーティションの数。

numPartitions JSON 設定に対応します。

任意。

次のインデックス構成設定を確認します。

フィールド名
説明
必要性

analyzer

コレクションのデータのインデックス作成に使用するアナライザを指定します。デフォルトでは、Atlas Search は標準アナライザ(lucene.standard)を使用します。

任意

searchAnalyzer

テキストを検索する前にクエリ テキストに適用するアナライザを指定します。このフィールドを省略した場合、インデックスはデフォルトで以下の順序でアナライザを継承します。

  1. このフィールドのanalyzerオプション(指定されている場合)。

  2. インデックスsearchAnalyzerオプション(指定されている場合)。

  3. インデックスanalyzerオプション(指定されている場合)。

  4. lucene.standardアナライザ。

任意

mappings.dynamic

フィールドの動的マッピングまたは静的マッピングを指定します。動的マッピングを無効にするには、"dynamic":false に設定します。デフォルトでは、動的マッピングは有効になっています。動的マッピングを無効にする場合は、インデックスを作成するフィールドを指定する必要があります。動的マッピングと静的マッピングの詳細については、「インデックスの作成に関する参照」を参照してください。

必須

次の詳細構成設定を確認します。

フィールド名
説明
必要性

mappings.fields

mappings.dynamicfalseの場合は必須です。

インデックスを作成するフィールドを指定します。詳しくは「フィールドマッピングの定義」を参照してください。

条件付き

storedSource

クエリ時の検索のために Atlas Search に保存するフィールドを指定します。Atlas Search では、サポートされているすべてのデータ型のフィールドをストアできます。

フィールドの保存の詳細については、「Atlas Search インデックスに保存されたソース フィールドの定義」を参照してください。

任意

synonyms

インデックスで使用するシノニム マッピングを指定します。

シノニム マッピングを使用すると、同じアナライザで分析されたフィールドのみをクエリすることができます。

シノニム マッピングの詳細については、「Atlas Searchインデックスでのシノニム マッピングの定義」を参照してください。

任意

numPartitions

フィールドオブジェクトが 2.1 00 億を超える場合に使用するパーティションの数。

任意。

これらのインデックス定義設定の詳細については、「インデックスの作成に関する参照」を参照してください。

5

インデックスのステータスがActiveからBuildingに変わります。 この状態では、更新されたインデックスが使用可能になるまで、Atlas Search が古いインデックスを削除しないため、古いインデックスを使用し続けることができます。 ステータスがActiveに戻ったら、変更されたインデックスは使用可能になります。

mongoshを通じて Atlas Search インデックスを編集するには、 db.collection.updateSearchIndex()メソッドを使用します。

このコマンドの構文は、次のとおりです。編集するインデックスの名前を指定し、新しいインデックス定義を定義します。この定義は、インデックスの既存の定義を置き換えます。詳細については、「インデックスの作成に関する参照」を参照してください。

db.<collection>.updateSearchIndex(
"<index-name>",
/* updated search index definition */
)

次のコマンドは、静的マッピングを使用するように、 moviesコレクションからdefaultという名前の検索インデックスを更新します。

db.movies.updateSearchIndex(
"default",
{
"mappings": {
"dynamic": false,
"fields": {
"<field-name>": {
"type": "<field-type>"
}
}
}
)

注意

db.collection.updateSearchIndex() コマンドは出力を返しません。Atlas UI を使用してインデックスのステータスを確認できます。

MongoDB Compass を使用して Atlas Search インデックスを編集するには以下の手順に従います。

1
2
3
4

C ドライバーを使用して Atlas Search インデックスを編集するには、アプリケーション内の更新されたインデックス情報を指定し、 mongoc_collection_command_simple()メソッドを呼び出します。

1
2

次のサンプル アプリケーションでは、 updateSearchIndexコマンド、更新されたインデックス定義、既存のインデックス名を指定します。 次に、アプリケーションはコマンドと更新されたインデックス情報をBSONに変換し、この情報をmongoc_collection_command_simple()メソッドに渡して検索インデックスを編集します。

#include <mongoc/mongoc.h>
#include <stdlib.h>
int main (void)
{
mongoc_client_t *client = NULL;
mongoc_collection_t *collection = NULL;
mongoc_database_t *database = NULL;
bson_error_t error;
bson_t cmd = BSON_INITIALIZER;
bool ok = true;
mongoc_init();
// Connect to your Atlas deployment
client = mongoc_client_new("<connectionString>");
if (!client) {
fprintf(stderr, "Failed to create a MongoDB client.\n");
ok = false;
goto cleanup;
}
// Access your database and collection
database = mongoc_client_get_database(client, "<databaseName>");
collection = mongoc_database_get_collection(database, "<collectionName>");
// Specify the command and the updated index definition
const char *cmd_str = BSON_STR({
"updateSearchIndex" : "<collectionName>",
"definition" : {"mappings" : {"dynamic" : true}},
"name" : "<indexName>"
});
// Convert your command to BSON
if (!bson_init_from_json(&cmd, cmd_str, -1, &error)) {
fprintf(stderr, "Failed to parse command: %s\n", error.message);
ok = false;
goto cleanup;
}
// Update the Atlas search index by running the command
if (!mongoc_collection_command_simple (collection, &cmd, NULL, NULL, &error)) {
fprintf(stderr, "Failed to run updateSearchIndex: %s\n", error.message);
ok = false;
goto cleanup;
}
printf ("Index updated!\n");
cleanup:
mongoc_collection_destroy (collection);
mongoc_database_destroy (database);
mongoc_client_destroy (client);
bson_destroy (&cmd);
mongoc_cleanup ();
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
3
  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • インデックスを更新するデータベースとコレクション。

  • 更新するインデックスの名前。

  • 検索インデックスを再定義するフィールド。詳細については、「インデックスの作成に関する参照」を参照してください。

4
gcc -o edit-index edit-index.c $(pkg-config --libs --cflags libmongoc-1.0)
./edit-index

C++ ドライバーを使用して Atlas Search インデックスを編集するには、検索インデックス ビューでupdate_one()メソッドを呼び出します。

1
2

次のサンプルアプリケーションでは、検索インデックスビューをインスタンス化し、新しいAtlas Search インデックス定義を指定します。 次に、アプリケーションはこの定義と既存のインデックス名をupdate_one()メソッドに渡します。これにより、新しい定義ドキュメントを反映するように既存のインデックスがアップデートされます。

#include <bsoncxx/builder/basic/document.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/search_index_view.hpp>
using namespace mongocxx;
using bsoncxx::builder::basic::make_document;
int main()
{
mongocxx::instance instance{};
try
{
// Connect to your Atlas deployment
mongocxx::uri uri("<connectionString>");
mongocxx::client client(uri);
// Access your database and collection
auto db = client["<databaseName>"];
auto collection = db["<collectionName>"];
// Access the indexes in your collection
auto siv = collection.search_indexes();
// Specify a new definiton and update your search index
auto newDefinition = make_document(kvp("mappings", make_document(kvp("dynamic", true))));
siv.update_one("<indexName>", newDefinition.view());
}
catch (const std::exception& e)
{
std::cout<< "Exception: " << e.what() << std::endl;
}
return 0;
}
3
  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • インデックスを更新するデータベースとコレクション。

  • 更新するインデックスの名前。

  • 検索インデックスを再定義するフィールド。詳細については、「インデックスの作成に関する参照」を参照してください。

4
g++ -o edit-index edit-index.cpp $(pkg-config --cflags --libs libmongocxx)
./edit-index

.NET/C# ドライバー を使用して Atlas Search インデックスを編集するには、 メソッドまたはUpdate() UpdateAsync()メソッドを使用します。

次のサンプルアプリケーションでは、既存のインデックス定義をアップデートします。 次の値を指定します。

  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • 検索インデックスを作成したデータベースとコレクション。

  • 既存の定義を置き換える新しいインデックス定義。この例では、静的マッピングを使用するようにインデックスを更新しています。この定義は、特定のインデックス ニーズに合わせて変更できます。詳細については、「インデックスの作成に関する参照」を参照してください。

  • 更新するインデックスの名前。

Program.cs
using MongoDB.Bson;
using MongoDB.Driver;
// connect to your Atlas deployment
var uri = "<connection-string>";
var client = new MongoClient(uri);
var db = client.GetDatabase("<databaseName>");
var collection = db.GetCollection<BsonDocument>("<collectionName>");
// define your Atlas Search index
var index = new BsonDocument
{
// updated search index definition
{ "mappings", new BsonDocument
{
{ "dynamic", false },
{ "fields", new BsonDocument
{
{ "<field-name>", new BsonDocument
{
{ "type", "<field-type>" }
}
}
}
}
}
}
};
collection.SearchIndexes.Update("<index-name>", index);

サンプル アプリケーションを実行するには、csharp-update-index という名前の新しい .NET コンソール プロジェクトを作成し、前のサンプル コードを Program.cs ファイルにコピーします。次に、以下のコマンドを使ってプロジェクトを実行します。

dotnet run csharp-update-index.csproj

注意

Update() メソッドは出力を返しません。Atlas UI を使用してインデックスのステータスを確認できます。

Tip

API ドキュメント

このページのメソッドについて詳しくは、.NET/C# ドライバー用の APIドキュメント を参照してください。

Java ドライバーを使用してコレクションの Atlas Search インデックスを編集するには、検索インデックス設定を変更するドキュメントを作成し、そのドキュメントをupdateSearchIndex()メソッドに渡します。 Java ドライバーv 4.11.0以上が必要です。

1
2
1import com.mongodb.client.MongoClient;
2import com.mongodb.client.MongoClients;
3import com.mongodb.client.MongoCollection;
4import com.mongodb.client.MongoDatabase;
5import org.bson.Document;
6
7public class EditIndex {
8 public static void main(String[] args) {
9 // connect to your Atlas cluster
10 String uri = "<connection-string>";
11
12 try (MongoClient mongoClient = MongoClients.create(uri)) {
13 // set namespace
14 MongoDatabase database = mongoClient.getDatabase("<document-name>");
15 MongoCollection<Document> collection = database.getCollection("<collection-name>");
16 // define field mappings
17 Document index = new Document("analyzer", "<analyzer-name>").append(
18 "mappings", new Document("dynamic", <true|false>)
19 .append("fields", new Document("<field-name>",
20 new Document("type", "<field-type>"))));
21 // run the updateSearchIndex() method
22 collection.updateSearchIndex("<index-name>", index);
23 }
24 }
25}
3
  • <connection-string> - Atlas接続文字列。 詳しくは、「ドライバーによる接続 」を参照してください。

    注意

    接続文字列には、 writeConcern設定を含めないでください。

  • <database-name> - コレクションを含むデータベースの名前。

  • <collection-name> - インデックスを検索するコレクションの名前。

  • <analyzer-name> -アナライザの名前。

  • dynamic - フィールドを自動的にインデックス化するかどうかを示すフラグ。

  • <field-name> - インデックスを作成するフィールドの名前。

  • <field-type> - フィールドのデータ型。

  • <index-name> - インデックスの名前。

4
javac EditIndex.java
java EditIndex

updateSearchIndex() メソッドは非同期で実行されます。listSearchIndexes() メソッドを使用して、変更がインデックスに適用されたかどうかを確認します。Atlas Search インデックスの取得の詳細については、「Atlas Search インデックスを表示」を参照してください。

Node Driverを通じて Atlas Search インデックスを編集するには、 updateSearchIndexヘルパー メソッドを使用します。

既存のインデックス定義を更新するには、 update-index.jsという名前の次のサンプル アプリケーションを使用します。 次の値を指定します。

  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • 検索インデックスを作成したデータベースとコレクション。

  • 既存の定義を置き換える新しいインデックス定義。この例では、静的マッピングを使用するようにインデックスを更新しています。この定義は、特定のインデックス ニーズに合わせて変更できます。詳細については、「インデックスの作成に関する参照」を参照してください。

  • 更新するインデックスの名前。

update-index.js
import { MongoClient } from "mongodb";
// connect to your Atlas deployment
const uri = "<connection-string>";
const client = new MongoClient(uri);
async function run() {
try {
const database = client.db("<databaseName>");
const collection = database.collection("<collectionName>");
// define your Atlas Search index
const index = {
/* updated search index definition */
"mappings": {
"dynamic": false,
"fields": {
"<field-name>": {
"type": "<field-type>"
}
}
}
}
// run the helper method
await collection.updateSearchIndex("<index-name>", index);
} finally {
await client.close();
}
}
run().catch(console.dir);

サンプル アプリケーションを実行するには、次のコマンドを使用します。

node update-index.js

注意

updateSearchIndex メソッドは出力を返しません。Atlas UI を使用してインデックスのステータスを確認できます。

Python ドライバーを使用して Atlas Search インデックスを更新するには、コレクションでupdate_search_index()メソッドを呼び出します。

1
2

次のサンプル アプリケーションでは、新しい Atlas Search インデックス定義を指定します。 次に、アプリケーションはこの定義と既存のインデックス名をupdate_search_index()メソッドに渡します。これにより、新しい定義ドキュメントを反映するように既存のインデックスがアップデートされます。

from pymongo.mongo_client import MongoClient
def edit_index():
# Connect to your Atlas deployment
uri = "<connectionString>"
client = MongoClient(uri)
# Access your database and collection
database = client["<databaseName>"]
collection = database["<collectionName>"]
# Specify a new index definition
definition = {
"mappings": {
"dynamic": True
},
}
# Update your search index
collection.update_search_index("<indexName>", definition)
3
  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • インデックスを更新するデータベースとコレクション。

  • 更新するインデックスの名前。

  • 検索インデックスを再定義するフィールド。詳細については、「インデックスの作成に関する参照」を参照してください。

4
python edit_index.py

注意

更新されたインデックスが作成されている間、さまざまなノードがそれぞれ異なる速度で更新されることがあります。この間、新しいインデックス定義と以前のインデックス定義の両方を反映して、クエリの結果が混ざることがあります。クエリを処理しているインデックスは、インデックスのステータス詳細ページで見ることができます。

一部の Atlas Search 機能では、インデックスを更新する必要があります。 インデックスを更新するには、次のいずれかのアクションを実行します。

  • Atlas Search インデックスの編集」を参照して、インデックス定義を編集します。

  • Atlas UI でインデックスの更新をオプトインするには、次の手順を実行します。

重要

Atlas Search インデックスの更新プロセスには時間とリソースが必要です。 インデックスの更新を正常に完了するには、現在のインデックスのディスク容量の125 % と等しい空きディスク容量を割り当てます。

1

警告

ナビゲーションの改善が進行中

現在、新しく改良されたナビゲーション エクスペリエンスを導入中です。次の手順が Atlas UI の表示と一致しない場合は、プレビュー ドキュメントを参照してください。

  1. まだ表示されていない場合は、希望するプロジェクトを含む組織を選択しますナビゲーション バーのOrganizationsメニュー

  2. まだ表示されていない場合は、ナビゲーション バーのProjectsメニューから目的のプロジェクトを選択します。

  3. まだ表示されていない場合は、サイドバーの [Clusters] をクリックします。

    [ Clusters (クラスター) ] ページが表示されます。

2

GoAtlas Searchページには、サイドバー、Data Explorer 、またはクラスターの詳細ページから できます。

  1. サイドバーで、 Services見出しの下のAtlas Searchをクリックします。

    クラスターがない場合は、Create clusterをクリックしてクラスターを作成してください。詳細については、「 クラスターの作成 」を参照してください。

  2. プロジェクトに複数のクラスターがある場合は、Select cluster ドロップダウンから使用するクラスターを選択し、[Go to Atlas Search] をクリックします。

    Atlas Searchページが表示されます。

  1. クラスターの [Browse Collections] ボタンをクリックします。

  2. データベースを展開し、コレクションを選択します。

  3. コレクションのSearch Indexesタブをクリックします。

    Atlas Searchページが表示されます。

  1. クラスタの名前をクリックします。

  2. [Atlas Search] タブをクリックします。

    Atlas Searchページが表示されます。

3

Tip

新しい機能を有効にするためにインデックスを更新する必要がある場合、Atlas UI ではインデックス名の横に警告アイコンが表示されます。

4
  1. Index Overviewページで、バナーのUpdateをクリックします。

  2. 確認ウィンドウで [ Update Indexをクリックします。

    インデックスが更新されている間も、以前のインデックスを使用してコレクションをクエリできます。

Atlas Search インデックスを削除するには、Atlas UI を使用します。また、mongosh、Atlas CLI、API のいずれかを使用するか、任意の言語でサポート対象の MongoDB ドライバーを使用してプログラム的にも削除できます。


➤ [言語の選択] ドロップダウン メニューを使用して、このセクションの手順の言語を設定します。


APIを使用して Atlas Search インデックスを削除するには、次の手順に従います。

1

削除する Atlas Search インデックスの一意の ID または名前を指定して、 DELETEリクエストをsearch/indexes/エンドポイントに送信します。

curl --user "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \ --header "Accept: application/json" \
--include \
--request DELETE "https://cloud.mongodb.com/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/indexes/{indexId}"

どちらのエンドポイントの構文とパラメータの詳細についても、「名前1 つ削除 」および「 ID を使用して 1 つの削除 」を参照してください。

2

Atlas CLI を使用してクラスターから検索インデックスを削除するには、次のコマンドを実行します。

atlas clusters search indexes delete <indexId> [options]

コマンド構文とパラメーターについて詳しくは、「Atlasクラスター検索インデックスの削除」の Atlas CLIドキュメントを参照してください。

Atlas CLI を使用して指定したデプロイの指定した検索インデックスを削除するには、次のコマンドを実行します。

atlas deployments search indexes delete <indexId> [options]

コマンド構文とパラメーターの詳細については、Atlas CLI ドキュメントの「atlas deployments search indexes delete」を参照してください。

1

警告

ナビゲーションの改善が進行中

現在、新しく改良されたナビゲーション エクスペリエンスを導入中です。次の手順が Atlas UI の表示と一致しない場合は、プレビュー ドキュメントを参照してください。

  1. まだ表示されていない場合は、希望するプロジェクトを含む組織を選択しますナビゲーション バーのOrganizationsメニュー

  2. まだ表示されていない場合は、ナビゲーション バーのProjectsメニューから目的のプロジェクトを選択します。

  3. まだ表示されていない場合は、サイドバーの [Clusters] をクリックします。

    [ Clusters (クラスター) ] ページが表示されます。

2

GoAtlas Searchページには、サイドバー、Data Explorer 、またはクラスターの詳細ページから できます。

  1. サイドバーで、 Services見出しの下のAtlas Searchをクリックします。

    クラスターがない場合は、Create clusterをクリックしてクラスターを作成してください。詳細については、「 クラスターの作成 」を参照してください。

  2. プロジェクトに複数のクラスターがある場合は、Select cluster ドロップダウンから使用するクラスターを選択し、[Go to Atlas Search] をクリックします。

    Atlas Searchページが表示されます。

  1. クラスターの [Browse Collections] ボタンをクリックします。

  2. データベースを展開し、コレクションを選択します。

  3. コレクションのSearch Indexesタブをクリックします。

    Atlas Searchページが表示されます。

  1. クラスタの名前をクリックします。

  2. [Atlas Search] タブをクリックします。

    Atlas Searchページが表示されます。

3

[ ellipsis ] ボタンはパネルの右側にあります。 目的のインデックスの横にある ボタンをクリックし、[ Delete Index ] を選択します。

4

mongoshを通じて Atlas Search インデックスを削除するには、 db.collection.dropSearchIndex()メソッドを使用します。

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

db.<collection>.dropSearchIndex("<index-name>")

次のコマンドは、 moviesコレクションからdefaultという名前の検索インデックスを削除します。

db.movies.dropSearchIndex("default")

注意

db.collection.dropSearchIndex() コマンドは出力を返しません。Atlas UI を使用してインデックスのステータスを確認できます。

MongoDB Compass を使用して Atlas Search インデックスを削除するには以下の手順に従います。

1
2
3
4

C ドライバーを使用して Atlas Search インデックスを削除するには、コレクションと drop コマンドをmongoc_collection_command_simple()メソッドに渡します。

1
2

次のサンプル アプリケーションでは、 dropSearchIndexコマンドと既存のインデックス名を指定します。 次に、アプリケーションはコマンドとインデックス情報をBSONに変換し、この情報をmongoc_collection_command_simple()メソッドに渡して検索インデックスを削除します。

#include <mongoc/mongoc.h>
#include <stdlib.h>
int main (void)
{
mongoc_client_t *client = NULL;
mongoc_collection_t *collection = NULL;
mongoc_database_t *database = NULL;
bson_error_t error;
bson_t cmd = BSON_INITIALIZER;
bool ok = true;
mongoc_init();
// Connect to your Atlas deployment
client = mongoc_client_new("<connectionString>");
if (!client) {
fprintf(stderr, "Failed to create a MongoDB client.\n");
ok = false;
goto cleanup;
}
// Access your database and collection
database = mongoc_client_get_database(client, "<databaseName>");
collection = mongoc_database_get_collection(database, "<collectionName>");
// Specify the command and the index name
const char *cmd_str =
BSON_STR ({"dropSearchIndex" : "<collectionName>", "name" : "<indexName>"});
// Convert your command to BSON
if (!bson_init_from_json(&cmd, cmd_str, -1, &error)) {
fprintf(stderr, "Failed to parse command: %s\n", error.message);
ok = false;
goto cleanup;
}
// Run the command to drop the search index
if (!mongoc_collection_command_simple (collection, &cmd, NULL, NULL, &error)) {
fprintf(stderr, "Failed to run dropSearchIndex: %s\n", error.message);
ok = false;
goto cleanup;
}
printf ("Index dropped!\n");
cleanup:
mongoc_collection_destroy(collection);
mongoc_database_destroy(database);
mongoc_client_destroy(client);
bson_destroy(&cmd);
mongoc_cleanup ();
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
}
3
  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • インデックスを削除するデータベースとコレクション。

  • 削除するインデックスの名前。

4
gcc -o delete-index delete-index.c $(pkg-config --libs --cflags libmongoc-1.0)
./delete-index

C++ ドライバーを使用して Atlas Search インデックスを削除するには、検索インデックス ビューでdrop_one()メソッドを呼び出します。

1
2

次のサンプル アプリケーションでは、ターゲット コレクションのsearch_indexes()メソッドを使用して検索インデックス ビューをインスタンス化します。 次に、アプリケーションはビューでdrop_one()メソッドを呼び出し、インデックスを削除するためのパラメーターとして Atlas Search インデックス名を渡します。

#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/search_index_view.hpp>
using namespace mongocxx;
int main()
{
mongocxx::instance instance{};
try
{
// Connect to your Atlas deployment
mongocxx::uri uri("<connectionString>");
mongocxx::client client(uri);
// Access your database and collection
auto db = client["<databaseName>"];
auto collection = db["<collectionName>"];
// Access the indexes in your collection
auto siv = collection.search_indexes();
// Delete your search index
auto name = "<indexName>";
siv.drop_one(name);
}
catch (const std::exception& e)
{
std::cout<< "Exception: " << e.what() << std::endl;
}
return 0;
}
3
  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • インデックスを取得するデータベースとコレクション。

  • 削除するインデックスの名前。

4
g++ -o delete-index delete-index.cpp $(pkg-config --cflags --libs libmongocxx)
./delete-index

.NET/C# ドライバー を使用して Atlas Search インデックスを削除するには、 メソッドまたはDropOne() DropOneAsync()メソッドを使用します。

次のサンプル アプリケーションは、コレクションからインデックスを削除します。 次の値を指定します。

  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • 削除する検索インデックスを含むデータベースとコレクション。

  • 削除する検索インデックスの名前。

Program.cs
using MongoDB.Bson;
using MongoDB.Driver;
// connect to your Atlas deployment
var uri = "<connection-string>";
var client = new MongoClient(uri);
var db = client.GetDatabase("<databaseName>");
var collection = db.GetCollection<BsonDocument>("<collectionName>");
// drop your Atlas Search index
collection.SearchIndexes.DropOne("<index name>");

サンプル アプリケーションを実行するには、csharp-delete-index という名前の新しい .NET コンソール プロジェクトを作成し、前のサンプル コードを Program.cs ファイルにコピーします。次に、以下のコマンドを使ってプロジェクトを実行します。

dotnet run csharp-delete-index.csproj

注意

DropOne() メソッドは出力を返しません。Atlas UI を使用してインデックスのステータスを確認できます。

Tip

API ドキュメント

このページのメソッドについて詳しくは、.NET/C# ドライバー用の APIドキュメント を参照してください。

Java ドライバーを使用してコレクション上の Atlas Search インデックスを削除するには、 dropSearchIndex()メソッドを使用します。 Java ドライバーv 4.11.0以上が必要です。

1
2

次のサンプル アプリケーションは、指定されたコレクション上の指定された Atlas Search インデックスを削除します。

1import com.mongodb.client.MongoClient;
2import com.mongodb.client.MongoClients;
3import com.mongodb.client.MongoCollection;
4import com.mongodb.client.MongoDatabase;
5import org.bson.Document;
6
7public class DeleteIndex {
8 public static void main(String[] args) {
9 // connect to your Atlas cluster
10 String uri = "<connection-string>";
11
12 try (MongoClient mongoClient = MongoClients.create(uri)) {
13 // set namespace
14 MongoDatabase database = mongoClient.getDatabase("<database-name>");
15 MongoCollection<Document> collection = database.getCollection("<collection>");
16 // delete the index
17 collection.dropSearchIndex("<index-name>");
18 }
19 }
20}
3
  • <connection-string> - Atlas接続文字列。 詳しくは、「ドライバーによる接続 」を参照してください。

    注意

    接続文字列には、 writeConcern設定を含めないでください。

  • <database-name> - コレクションを含むデータベースの名前。

  • <collection-name> - インデックスを検索するコレクションの名前。

  • <index-name> - 削除するインデックスの名前。

4
javac DeleteIndex.java
java DeleteIndex

Node Driverを通じて Atlas Search インデックスを削除するには、 dropSearchIndexヘルパー メソッドを使用します。

drop-index.jsという名前の次のサンプル アプリケーションを使用して、コレクションのインデックスを削除できます。 次の値を指定します。

  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • 検索インデックスを作成したデータベースとコレクション。

  • 削除するインデックスの名前。

drop-index.js
// connect to your Atlas deployment
const uri = "<connection-string>";
const client = new MongoClient(uri);
async function run() {
try {
const database = client.db("<databaseName>");
const collection = database.collection("<collectionName>");
// run the helper method
await collection.dropSearchIndex("<index-name>");
} finally {
await client.close();
}
}
run().catch(console.dir);

サンプル アプリケーションを実行するには、次のコマンドを使用します。

node drop-index.js

注意

dropSearchIndex メソッドは出力を返しません。Atlas UI を使用してインデックスのステータスを確認できます。

Python ドライバーを使用して Atlas Search インデックスを削除するには、コレクションでdrop_search_index()メソッドを呼び出します。

1
2

次のサンプル アプリケーションでは、Atlas Search インデックス名をdrop_search_index()メソッドに渡してインデックスを削除します。

from pymongo.mongo_client import MongoClient
def delete_index():
# Connect to your Atlas deployment
uri = "<connectionString>"
client = MongoClient(uri)
# Access your database and collection
database = client["<databaseName>"]
collection = database["<collectionName>"]
# Delete your search index
collection.drop_search_index("<indexName>")
3
  • Atlas 接続文字列。詳しくは、「ドライバーによる接続」を参照してください。

  • インデックスを削除するデータベースとコレクション。

  • 削除するインデックスの名前。

4
python delete_index.py

mongot プロセスはインデックスされたフィールドと _id フィールドをディスクに保存するため、インデックスを構築する前にそのサイズを調整することをお勧めします。Atlas Search インデックスの全体のサイズを見積もるには、コレクションのサブセットにインデックスを作成し、次の式を使用してデータの総サイズに基づいてサンプル データ インデックスのサイズをスケーリングします。

estimated-index-size = ( subset-data-index-size / subset-data-size ) x total-collection-data-size

例えば、sample_mflix データベースの movies コレクションのインデックスのサイズを見積もる場合は、mongosh で次の手順を実行します。

  1. $sample を実行して、データのランダムサンプルを使用して sample_data という新しいコレクションを作成します。

    use sample_mflix
    db.movies.aggregate([
    { $sample: { size: 10 } },
    { $out: "sample_data" }
    ])
    [
    {
    _id: ObjectId('573a13bbf29313caabd53f9c'),
    plot: "Three years ago, in real-life, Hama Ali, a charismatic actor from Iraq famous locally for his performance as Iraq's version of Superman, met Ayca on a film-set. He and Ayca, a fiery actress...",
    genres: [ 'Drama', 'Romance', 'War' ],
    runtime: 93,
    cast: [
    'Ayèa Damgaci',
    'Hama Ali Kahn',
    'Cengiz Bozkurt',
    'Nesrin Cavadzade'
    ],
    num_mflix_comments: 1,
    poster: 'https://m.media-amazon.com/images/M/MV5BMjA1OTI1MjI4OV5BMl5BanBnXkFtZTgwODk1MTA2MDE@._V1_SY1000_SX677_AL_.jpg',
    title: 'Gitmek: My Marlon and Brando',
    fullplot: "Three years ago, in real-life, Hama Ali, a charismatic actor from Iraq famous locally for his performance as Iraq's version of Superman, met Ayca on a film-set. He and Ayca, a fiery actress from Turkey, had a passionate love affair before returning to their respective homes. From his Kurdish village, Hama Ali sends Ayca video love letters which he has filmed on his handycam. She watches them from her sofa in Istanbul, with her cat for company. The video love letters capture the hellish violence engulfing Iraq, the goats and uncles populating his rural area, and also his tender affection towards her. Feeling suffocated by her own city and angered by the indifference towards the war that surrounds her, Ayca decides to make the journey eastwards to Iraq to be reunited with her lover. GITMEK, a dramatic feature film, is based on the true story of Ayca's departure from Istanbul and her extraordinary journey to the Iraqi border. At a time when many people were fleeing from East to West in search of safety, Ayca makes the opposite journey, in search of love. She is helped by immigrant artists who live in the slums of Istanbul and the mothers of long distance truck drivers who she meets at various border towns. The journey takes her through breathtaking landscapes, strange encounters and terrifying times.",
    languages: [ 'English', 'Kurdish', 'Turkish' ],
    released: ISODate('2008-11-14T00:00:00.000Z'),
    directors: [ 'Huseyin Karabey' ],
    writers: [ 'Ayèa Damgaci', 'Huseyin Karabey' ],
    awards: { wins: 12, nominations: 4, text: '12 wins & 4 nominations.' },
    lastupdated: '2015-07-04 00:20:59.083000000',
    year: 2008,
    imdb: { rating: 6.6, votes: 628, id: 920460 },
    countries: [ 'Turkey' ],
    type: 'movie',
    tomatoes: {
    viewer: { rating: 3.7, numReviews: 181, meter: 79 },
    lastUpdated: ISODate('2015-07-16T18:10:38.000Z')
    }
    },
    {
    _id: ObjectId('573a139af29313caabcefb6a'),
    plot: '48 hours of intersecting lives and crimes in Los Angeles.',
    genres: [ 'Comedy', 'Crime', 'Drama' ],
    runtime: 104,
    rated: 'R',
    cast: [
    'Danny Aiello',
    'Greg Cruttwell',
    'Jeff Daniels',
    'Teri Hatcher'
    ],
    num_mflix_comments: 1,
    poster: 'https://m.media-amazon.com/images/M/MV5BZDI0ZmFmYTgtMTQ5OS00MTVmLTgwNWYtNzIyY2Y5NjYxNzgyXkEyXkFqcGdeQXVyNzc5MjA3OA@@._V1_SY1000_SX677_AL_.jpg',
    title: '2 Days in the Valley',
    fullplot: 'John Herzfeld deftly welds together a multitude of subplots-- a loser hitman and a cool assassin involved in an insurance scam; a washed-up director, turned suicidal, if only he had someone to care for his beloved dog; a snooty art dealer, wracked by kidney stones, cared for by his devoted assistant; a grungy deranged vice cop, now partnered with a fresh-faced rookie; and two beautiful and jealous women entangled in their deadly scheme--into a spoof of the crime thriller genre.',
    languages: [ 'English', 'Vietnamese' ],
    released: ISODate('1996-09-27T00:00:00.000Z'),
    directors: [ 'John Herzfeld' ],
    writers: [ 'John Herzfeld' ],
    awards: { wins: 0, nominations: 1, text: '1 nomination.' },
    lastupdated: '2015-09-11 00:42:22.520000000',
    year: 1996,
    imdb: { rating: 6.5, votes: 15019, id: 115438 },
    countries: [ 'USA' ],
    type: 'movie',
    tomatoes: {
    viewer: { rating: 3, numReviews: 14630, meter: 55 },
    dvd: ISODate('2001-08-07T00:00:00.000Z'),
    critic: { rating: 6, numReviews: 53, meter: 60 },
    lastUpdated: ISODate('2015-08-19T18:25:36.000Z'),
    consensus: 'A labyrinthine thriller with a host of memorable characters, 2 Days in the Valley is an uneven but intriguing thriller/black comedy.',
    rotten: 21,
    production: 'HBO Video',
    fresh: 32
    }
    },
    {
    _id: ObjectId('573a13bdf29313caabd5943e'),
    fullplot: "When Emily Parris exposes a secret society of teenage girls who have slipped out of the world of social media and into another world they've discovered in the woods at night. When she accuses the girls of committing sexually deviant activities, Emily sends the small American town into a atmosphere of hysteria and the national media spotlight. The mystery deepens when each of the accused girls upholds a vow of silence.",
    imdb: { rating: 6.2, votes: 861, id: 1015471 },
    year: 2014,
    plot: "When a teenage girl says she's the victim of a secret network called The Sisterhood of Night, a quiet suburban town becomes the backdrop for a modern-day Salem witch trial.",
    genres: [ 'Drama', 'Mystery', 'Thriller' ],
    rated: 'PG-13',
    metacritic: 60,
    title: 'The Sisterhood of Night',
    lastupdated: '2015-09-10 17:22:16.113000000',
    languages: [ 'English' ],
    writers: [ 'Marilyn Fu (screenplay)', 'Steven Millhauser (short story)' ],
    type: 'movie',
    tomatoes: {
    website: 'http://www.thesisterhoodofnight-movie.com/',
    viewer: { rating: 3.6, numReviews: 382, meter: 65 },
    dvd: ISODate('2015-06-09T00:00:00.000Z'),
    critic: { rating: 6.6, numReviews: 19, meter: 79 },
    boxOffice: '$5.3k',
    rotten: 4,
    production: 'Cine Mosaic',
    lastUpdated: ISODate('2015-09-13T17:24:37.000Z'),
    fresh: 15
    },
    poster: 'https://m.media-amazon.com/images/M/MV5BODg3MjE0MDM4N15BMl5BanBnXkFtZTgwOTY0MjE5NDE@._V1_SY1000_SX677_AL_.jpg',
    num_mflix_comments: 1,
    released: ISODate('2014-10-18T00:00:00.000Z'),
    awards: { wins: 2, nominations: 3, text: '2 wins & 3 nominations.' },
    countries: [ 'USA' ],
    cast: [
    'Georgie Henley',
    'Kara Hayward',
    'Willa Cuthrell',
    'Olivia DeJonge'
    ],
    directors: [ 'Caryn Waechter' ],
    runtime: 104
    },
    {
    _id: ObjectId('573a13c4f29313caabd6d7bf'),
    plot: 'A film producer struggles with suicidal despair.',
    genres: [ 'Drama' ],
    runtime: 110,
    metacritic: 76,
    cast: [
    'Louis-Do de Lencquesaing',
    'Chiara Caselli',
    'Alice de Lencquesaing',
    'Alice Gautier'
    ],
    num_mflix_comments: 0,
    poster: 'https://m.media-amazon.com/images/M/MV5BMTUxODczODA2NV5BMl5BanBnXkFtZTcwNzExMjQ1Mw@@._V1_SY1000_SX677_AL_.jpg',
    title: 'Father of My Children',
    fullplot: "In the first half, Gregoire, a movie producer of great charm, owner of Moon Films, plays with his younger daughters, talks with his wife and his eldest daughter, and keeps his studio going while one project hemorrhages money and creditors circle. In the second half, Sylvia, his Italian wife, tries to hold the family together as she looks fully into Moon Films' troubles. She meets with a banker, a temperamental Swede, Russian TV magnates, a film lab exec, and Moon's lawyer. Clèmence, the oldest daughter, goes on her own search. Debt can crush; how does a family pick up the pieces?",
    languages: [ 'French' ],
    released: ISODate('2009-12-16T00:00:00.000Z'),
    directors: [ 'Mia Hansen-Lève' ],
    writers: [ 'Mia Hansen-Lève (screenplay)' ],
    awards: { wins: 2, nominations: 3, text: '2 wins & 3 nominations.' },
    lastupdated: '2015-09-02 00:01:22.897000000',
    year: 2009,
    imdb: { rating: 6.7, votes: 1820, id: 1356928 },
    countries: [ 'France', 'Germany', 'Belgium' ],
    type: 'movie',
    tomatoes: {
    website: 'http://www.filmsdulosange.fr/fr/fr_peredemesenfants.html',
    viewer: { rating: 3.3, numReviews: 1232, meter: 60 },
    dvd: ISODate('2010-06-21T00:00:00.000Z'),
    critic: { rating: 7.4, numReviews: 55, meter: 91 },
    lastUpdated: ISODate('2015-09-11T18:38:12.000Z'),
    consensus: 'A tragedy gracefully lifted by tender empathy and moments of joy, Father of My Children is a quiet triumph for writer-director Mia Hansen-Love.',
    rotten: 5,
    production: 'IFC Films',
    fresh: 50
    }
    },
    {
    _id: ObjectId('573a13a5f29313caabd15cc1'),
    plot: 'After a 13-year imprisonment in Hong Kong, a kickboxer challenges the current champion in order to restore his honor.',
    genres: [ 'Drama', 'Romance', 'Sport' ],
    runtime: 105,
    cast: [
    'Andy Lau',
    'Takako Tokiwa',
    'Inthira Charoenpura',
    'Apichaya Thanatthanapong'
    ],
    title: 'Ah Fu',
    lastupdated: '2015-09-14 12:56:13.823000000',
    languages: [ 'Cantonese' ],
    released: ISODate('2000-11-21T00:00:00.000Z'),
    directors: [ 'Daniel Lee' ],
    writers: [ 'Chi-Sing Cheung', 'Daniel Lee' ],
    awards: { wins: 1, nominations: 3, text: '1 win & 3 nominations.' },
    year: 2000,
    imdb: { rating: 6.6, votes: 350, id: 277558 },
    countries: [ 'Hong Kong' ],
    type: 'movie',
    tomatoes: {
    viewer: { rating: 3.3, numReviews: 644, meter: 57 },
    lastUpdated: ISODate('2015-04-25T18:41:33.000Z')
    },
    num_mflix_comments: 0
    },
    {
    _id: ObjectId('573a13bef29313caabd5ce2b'),
    plot: 'Johann Sebastian Bach llega con su familia a Leipzig para ocupar el puesto de cantor en la Escuela de Santo Tomès...',
    genres: [ 'Musical' ],
    runtime: 102,
    metacritic: 70,
    cast: [
    'Christian Atanasiu',
    'Fèodor Atkine',
    'George-Christoph Biller',
    'Christian Brembeck'
    ],
    title: 'The Silence Before Bach',
    lastupdated: '2015-05-25 00:50:52.210000000',
    languages: [ 'Spanish', 'German', 'Catalan' ],
    released: ISODate('2007-12-21T00:00:00.000Z'),
    directors: [ 'Pere Portabella' ],
    writers: [ 'Xavier Albertè', 'Pere Portabella', 'Carles Santos' ],
    awards: { wins: 3, nominations: 3, text: '3 wins & 3 nominations.' },
    year: 2007,
    imdb: { rating: 6.8, votes: 329, id: 1079450 },
    countries: [ 'Spain' ],
    type: 'movie',
    tomatoes: {
    website: 'http://www.pereportabella.com/eng/fla/die/home_eng.html',
    viewer: { rating: 3.5, numReviews: 391, meter: 64 },
    critic: { rating: 6.6, numReviews: 16, meter: 81 },
    lastUpdated: ISODate('2015-08-11T19:15:49.000Z'),
    rotten: 3,
    production: 'Film Forum',
    fresh: 13
    },
    num_mflix_comments: 0
    },
    {
    _id: ObjectId('573a13ccf29313caabd83260'),
    plot: 'A woman subject to mental, physical, and sexual abuse on a remote island seeks a way out.',
    genres: [ 'Crime', 'Drama', 'Horror' ],
    runtime: 115,
    cast: [ 'Yeong-hie Seo', 'Seong-won Ji', 'Min-ho Hwang', 'Min Je' ],
    num_mflix_comments: 0,
    poster: 'https://m.media-amazon.com/images/M/MV5BMjAyNDEwMDgzMl5BMl5BanBnXkFtZTcwNzMyMTYwNQ@@._V1_SY1000_SX677_AL_.jpg',
    title: 'Bedevilled',
    fullplot: "Hae-won is a beautiful single woman in her thirties who works at a bank in the Seoul city. She leads a busy life until she becomes a witness to an attempted murder case, and at the same time, things get complicated at work. When things get out of hand she is forced to take a vacation so she heads for 'Moodo', a small undeveloped island, where she had once visited to see her grandparents. And where she had befriended a girl named Bok-nam who stills writes to Hae-won asking her to visit despite the fact that Hae-won never bothered to reply. Upon arriving at the island, Hae-won is shocked to see everyone treating Bok-nam like a slave. As practically the only young woman on the island, she is a plaything for all the men and a free laborer for the women. Sick of all the inhumane treatment, Bok-nam had tried to escape the island several times in the past but had failed each time. She begs Hae-won to help her escape the place, but Hae-won remains indifferent not wanting to be involved in complicated situations. When Bok-nam realizes that her own daughter will follow her footsteps, she tries to escape the island with her daughter.",
    languages: [ 'Korean' ],
    released: ISODate('2010-09-02T00:00:00.000Z'),
    directors: [ 'Cheol-soo Jang' ],
    writers: [ 'Kwang-young Choi' ],
    awards: { wins: 10, nominations: 5, text: '10 wins & 5 nominations.' },
    lastupdated: '2015-09-01 01:18:02.960000000',
    year: 2010,
    imdb: { rating: 7.3, votes: 7983, id: 1646959 },
    countries: [ 'South Korea' ],
    type: 'movie'
    },
    {
    _id: ObjectId('573a13c7f29313caabd746fe'),
    plot: 'A Californian family inherits a castle in Romania. This is especially exciting to the son, who is obsessed with monsters. And he is not disappointed.',
    genres: [ 'Comedy', 'Family' ],
    runtime: 83,
    rated: 'TV-G',
    cast: [
    'Victoria Justice',
    'Chase Ellison',
    'Anna Galvin',
    'Matt Winston'
    ],
    num_mflix_comments: 0,
    poster: 'https://m.media-amazon.com/images/M/MV5BMjU1MmJlMTctY2FiMC00MmU1LWI5NmYtMDc5OWM0NjEzMmI2XkEyXkFqcGdeQXVyNDgyODgxNjE@._V1_SY1000_SX677_AL_.jpg',
    title: 'The Boy Who Cried Werewolf',
    fullplot: 'A Californian family inherits a castle in Romania. This is especially exciting to the son, who is obsessed with monsters. And he is not disappointed.',
    languages: [ 'English' ],
    released: ISODate('2010-10-22T00:00:00.000Z'),
    directors: [ 'Eric Bross' ],
    writers: [ 'Art Edler Brown', 'Douglas Sloan' ],
    awards: { wins: 1, nominations: 2, text: '1 win & 2 nominations.' },
    lastupdated: '2015-08-20 00:01:59.673000000',
    year: 2010,
    imdb: { rating: 6.3, votes: 1582, id: 1451423 },
    countries: [ 'USA', 'Canada' ],
    type: 'movie',
    tomatoes: {
    viewer: { rating: 3.7, numReviews: 762, meter: 66 },
    lastUpdated: ISODate('2015-09-12T17:30:20.000Z')
    }
    },
    {
    _id: ObjectId('573a13b4f29313caabd3f473'),
    genres: [ 'Documentary' ],
    runtime: 85,
    title: 'Zero Degrees of Separation',
    countries: [ 'Canada' ],
    lastupdated: '2015-08-09 00:30:38.977000000',
    languages: [ 'Arabic', 'English', 'Hebrew' ],
    released: ISODate('2005-06-22T00:00:00.000Z'),
    directors: [ 'Elle Flanders' ],
    writers: [ 'Elle Flanders' ],
    awards: { wins: 1, nominations: 0, text: '1 win.' },
    year: 2005,
    imdb: { rating: 6.6, votes: 90, id: 454990 },
    type: 'movie',
    tomatoes: {
    viewer: { rating: 3.5, numReviews: 5, meter: 100 },
    fresh: 1,
    critic: { numReviews: 2 },
    rotten: 1,
    lastUpdated: ISODate('2015-01-04T23:25:58.000Z')
    },
    num_mflix_comments: 0
    },
    {
    _id: ObjectId('573a13bff29313caabd5f070'),
    plot: 'This hilarious genre-bending comedy follows Gary Brewer, along with girlfriend Holly Brewer (no relation), and best friend Trevor Morehouse as Gary quests to reign supreme at the 2006 Rock, Paper, Scissors World Championships.',
    genres: [ 'Comedy' ],
    runtime: 85,
    cast: [ 'Tim Doiron', 'April Mullen', 'Ryan Tilley', 'Peter Pasyk' ],
    num_mflix_comments: 0,
    poster: 'https://m.media-amazon.com/images/M/MV5BMTI5MzIwMjA2Ml5BMl5BanBnXkFtZTcwOTcyOTA4MQ@@._V1_SY1000_SX677_AL_.jpg',
    title: 'Rock, Paper, Scissors: The Way of the Tosser',
    fullplot: 'This hilarious genre-bending comedy follows Gary Brewer, along with girlfriend Holly Brewer (no relation), and best friend Trevor Morehouse as Gary quests to reign supreme at the 2006 Rock, Paper, Scissors World Championships.',
    languages: [ 'English' ],
    released: ISODate('2007-07-06T00:00:00.000Z'),
    directors: [ 'Tim Doiron', 'April Mullen' ],
    writers: [ 'Tim Doiron (creator)', 'April Mullen (creator)', 'Tim Doiron' ],
    awards: { wins: 2, nominations: 0, text: '2 wins.' },
    lastupdated: '2015-08-12 00:01:33.813000000',
    year: 2007,
    imdb: { rating: 6.2, votes: 316, id: 1121964 },
    countries: [ 'Canada' ],
    type: 'movie'
    }
    ]
  2. コレクション全体に使用したいインデックス定義を使用して、サンプルデータを含むコレクションに検索インデックスを作成します。

    db.sample_data.createSearchIndex(
    "sample-index",
    { mappings: { dynamic: true } }
    )
    sample-index
  3. サンプルデータのサイズをコレクション全体のサイズでスケールします。例えば、sample-index インデックスのサイズが 44.88 の場合、Atlas UI インデックスの概要ページに従い、次のコマンドを使用してインデックスの合計サイズを計算できます。

    let sampleSize = db.sample_data.totalSize()
    let totalSize = db.movies.totalSize()
    let totalIndexSize = ( 44.88 / sampleSize ) * totalSize; totalIndexSize
    45864.28

Atlas UI では、Atlas Search ページのStatus 列に、クラスターのプライマリノード上のインデックスの現在のステータスが表示されます。次の表では、考えられるインデックスのステータスについて説明します。

ステータス
説明

支払い待ち

Atlas によるインデックスの構築は開始されていません。

構築

Atlas はインデックスを構築中、または編集したインデックスを再構築中です。インデックスがこの状態のとき、次の状況が発生します。

  • 新しいインデックスの場合、Atlas Search はインデックス構築が完了するまでクエリを処理しません。

  • 既存のインデックスの場合、インデックスの再構築が完了するまで、ユーザーは古いインデックスを引き続き使用して既存のクエリと新しいクエリを処理できます。

Ready

インデックスをいつでも使用できます。

Stale

次のいずれかの理由でインデックスが古くなっています。

  • ディスク使用率が高くなっていたため、レプリケーションが停止した。

    レプリケーションの一時停止のしきい値は 90% で、レプリケーション再開のしきい値は 85% のディスク使用率です。

  • レプリケーションが長時間停止すると、Atlas Search mongot プロセスは oplog から削除されます。

    この状態は通常、現在のレプリケーション ポイントが mongod oplog で使用できなくなった場合に発生します。Atlas は、mongot プロセスが oplog から削除された場合、インデックスを再構築します。

  • インデックスが 20 億ドキュメントの制限に達しました。

  • エラーが発生したため、レプリケーションに失敗しました。

既存のインデックスをクエリすることはできます。ただし、古いインデックスに対するクエリの結果には古いデータが含まれる場合があります。検索ノードをアップスケールしてディスク容量を増やしたり、既存のインデックスを削除してディスク容量を解放したりできます。または、View status details モーダルウィンドウのエラーを使用して問題のトラブルシューティングを行います。詳しくは、「Atlas Search の問題の修正」を参照してください。

失敗

Atlas によるインデックスの構築は失敗しました。View status details モーダル ウィンドウのエラーを使用して、問題のトラブルシューティングを行います。詳しくは、「Atlas Search の問題の修正」を参照してください。

削除

Atlas はクラスター ノードからインデックスを削除しています。

Does not Exist

インデックスのコレクションが存在しないため、インデックスは無効です。このインデックスに対応するコレクションがないため、このインデックスに対してクエリを実行することはできません。Atlas は最終的にインデックスを削除します。

Status Details ページで次のいずれかの方法で詳細なステータス情報を表示することができます。

  • Status 列のView status details リンクをクリックします。

  • Index Name 列の名前をクリックし、Index Overview の左側にあるメニューから Status Details を選択します。

Status Details ページには、次のセクションが含まれています。

このセクションには、クエリを処理するために使用されているインデックスが表示されます。

コレクションにこの名前のインデックスのバージョンが 1 つしかない場合は、そのセクションに Index Overview へのリンクがあり、使用されているインデックスのインデックス定義を確認できます。

コレクションに同じ名前のインデックスが他にもある場合、セクションには最新のインデックス定義が表示され、別のタブにコピーできる以前の有効なインデックスも表示されます。

インデックスを更新すると、ノードによって更新の適用速度が異なります。したがって、最新バージョンを使用するノードと、以前のバージョンを使用するノードがある可能性があります。Atlas は、変更がすべてのノードに適用されるまで、インデックスの両方のバージョンを表示します。

無効なインデックス定義でインデックスの更新を試みると、インデックス構築は失敗し、Atlas は以前の有効なインデックス定義のみを表示します。

このセクションには、クラスターの各ノードにおけるインデックスのステータスが表示されます。各ノードのインデックスに関する次の詳細を確認できます。

Shard

シャード名。

Node

ノードの情報。

Status

シャード内のノード上のインデックスのステータス。

Queryable

インデックスがクエリを処理できるかどうかを示すアイコン。

Message

インデックスのステータスの理由。Stale または Failed 状態のインデックスの場合、インデックスが古い理由またはインデックス構築が失敗した理由が表示されます。

Node Type

ノードのタイプ。値は次のいずれかのタイプにできます。

  • 原発

  • セカンダリ

  • 検索ノード

Region

ノードのリージョン。

Size

ノード上のインデックスのサイズ。

Documents

インデックス作成されたドキュメントの数と割合。

Actions

ノードのインデックスに対して実行できるアクション。 をクリックし、以下のオプションのいずれかを選択できます。

このセクションでは、該当する場合、Atlas Search および Atlas Vector Search インデックスの検索ノードへの進行中の移行のステータスが表示されます。このセクションは、現在検索ノードに移行している場合にのみ表示されます。

検索ノードへのインデックスの移行の進捗状況(ノードごと)の詳細については、Index Status by Search Node セクションの情報バナーにある View Migration Progress リンクをクリックしてください。

Atlas UI には、クラスター上の各インデックスに対して次の列が表示されます。

コラム
説明

Database

コレクションを含むデータベースの名前。

Collection

インデックス作成されたコレクションの名前。

Index Name

インデックスの名前。

Index Fields

インデックス作成されたフィールド。動的マッピングを有効にした場合、値は dynamic です。静的マッピングの場合、列にはインデックス作成されたすべてのフィールドが表示されます。

Type

インデックスのタイプ。値は、次のいずれかのタイプのインデックスです。

Status

移行のステータス。 詳細については、「 検索ノードへの移行 」を参照してください。

Size

インデックスのサイズ。

Documents

クラスター上の検索ノードでの移行中および移行後のコレクション内のドキュメントの総数に対するインデックス付きドキュメントの数と割合。

ステータス列には、検索ノード上のインデックスの次のいずれかのステータスが表示されます。

ステータス
説明

構築

インデックスは現在、検索ノード上に構築されています。新しいインデックスの構築中も、クエリでは既存のインデックスを引き続き使用できます。

On Deck

インデックスは検索ノード上に正常に構築されましたが、移行はまだ完了していません。Atlas が検索ノード上のすべてのインデックスを正常に構築した場合にのみ移行が完了することに注意してください。

Ready

検索ノードのインデックスは、クエリで使用する準備が整いました。これは、Atlas が検索ノードへの移行を正常に完了した場合にのみ表示されます。

失敗

インデックスの構築に失敗し、別の検索ノードへの移行が停止しました。クエリでは既存のインデックスを引き続き使用できます。Atlas はインデックスの再構築を試みますが、7 日後にタイムアウトします。

正常にインデックスするには、 ノードMessage 列またはStatus Details ページ でインデックスのエラー メッセージを確認し、検索ノードでインデックス構築が失敗する原因となっている問題に対処してください。

新しいインデックスが検索ノードに構築されている間も、クエリでは既存のインデックスを引き続き使用できます。検索ノードへの移行は、Atlas が検索ノード上のすべてのインデックスを正常に構築した場合にのみ完了します。その後、クエリは検索ノードのインデックスを使用するように自動的にルーティングされます。

Atlas Search クエリのニーズを満たすために Atlas Search インデックスを定義する方法については「クエリの定義」を参照してください。

Atlas Search インデックスの作成方法については、「Atlas Search インデックスを作成する」を参照してください。

このチュートリアルで説明されている Atlas Search のインデックス構成について詳しく学ぶには、以下の参照ページをご覧ください。

サンプルデータセット用の Atlas Search 検索インデックスを作成し、インデックスされたデータに対して Atlas Search 検索クエリを実行する実践的な経験を得るには、「Atlas Search クイックスタート」をお試しください。

このビデオ チュートリアルでは、複雑度がさまざまに異なる Atlas Search インデックスの作成方法を紹介します。

所要時間: 15 分

戻る

クエリ & インデックス