vector 型を使用してベクトル埋め込みをインデックスできます。ベクター フィールドには、次のタイプの数値の配列を含める必要があります。
BSON
int32、int64、またはdoubleデータ型BSON
doubleデータ型
You can use the vectorSearch operator, similar to the $vectorSearch stage, in your $search aggregation pipeline to query fields indexed as the vector type.
vector 型の制限
次の制限が適用されます。
オブジェクトの配列を持つフィールド(MongoDB Search
embeddedDocuments型)をvector型としてインデックスすることはできません。vector型を含むインデックス定義では、storedSource をtrueに設定できません。代わりに、includeを使用してmongotに保存するフィールドを指定するか、excludeを使用してvector型のフィールドをストレージから除外してください。You can't use the
$vectorSearchstage to query fields indexed as thevectortype.MongoDB Search プレイグラウンドで、フィールドを
vectorタイプとしてインデックスできます。
vector 型のインデックスを定義する
vector フィールド プロパティを構成する
vector フィールド プロパティを構成する
MongoDB Search vector 型は次のパラメータを取ります。
オプション | タイプ | 必要性 | 説明 |
|---|---|---|---|
|
| 必須 | このフィールド型を識別する、人間が判読できるラベル。値は |
| Int | 必須 | MongoDB Search がインデックス時とクエリ時に強制するベクトルの次元数。このフィールドは 量子化ベクトルまたは BinData のインデックス作成には、次のいずれかの値を指定できます。
The embedding model you choose determines the number of dimensions in your vector embeddings, with some models having multiple options for how many dimensions are output. To learn more, see Choosing a Method to Create Embeddings. |
| 文字列 | 必須 | 上位 K 近傍の検索に使用するベクトル類似度関数。このフィールドは 次のいずれかの値を指定できます。
To learn more, see About the Similarity Functions. |
| 文字列 | 任意 | ベクトルの自動ベクトル量子化のタイプ。埋め込みが 次のいずれかの値を指定できます。
To learn more, see About Quantization. |
| 文字列 | 任意 | ベクトルフィールドのインデックス構造。値は次のとおりです。
If omitted, defaults to If you specify |
| オブジェクト | 任意 | Parameters to use for Hierarchical Navigable Small Worlds graph construction. If omitted, uses the default values for the 重要:これはプレビュー機能として利用可能です。デフォルト値を変更すると、MongoDB Search インデックスとクエリに悪影響を与える可能性があります。 |
| Int | 任意 | Maximum number of edges (or connections) that a node can have in the Hierarchical Navigable Small Worlds graph. Value can be between A higher number improves :recall (accuracy of search results) because the graph is better connected. However, this also increases query and indexing time by increasing the number of neighbors to evaluate per graph node, and requires more memory to store the additional nodes for each connection in the Hierarchical Navigable Small Worlds graph. |
| Int | 任意 | クエリ時の 数値が大きいほど、高品質な接続を持つグラフが提供され、検索品質(リコール)が向上しますが、クエリのレイテンシが増加する可能性もあります。 |
vector 型の例を試す
The following index definition example uses the sample_mflix.embedded_movies collection in the sample data. After you load the collection, you can use the following example to index the plot_embedding_voyage_3_large field as the vector type for running queries using the vectorSearch (MongoDB Search Operator). For a sample query to run against this index, see Examples.
このインデックス定義は、動的にインデックス可能なすべてのフィールドがデフォルトtypeSetを用いて自動的にインデックスされ、さらにplot_embedding_voyage_3_large フィールドが以下の設定で vector 型としてインデックスされます。
2048次元数dotProduct類似関数scalar量子化hnsw(デフォルト)インデックスの作成メソッド