View a markdown version of this page

向量索引 - Amazon DocumentDB

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

向量索引

向量索引是一種特殊類型的索引,旨在有效率地查詢和管理存放在文件集合中的向量資料。Amazon DocumentDB 支援階層式導航小型世界 (HNSW) 和具有平面壓縮 (IVFFlat) 索引的反轉檔案。

如需詳細資訊,請參閱Amazon DocumentDB 的向量搜尋

向量索引有助於機器學習和生成式 AI 使用案例,例如:

  • 語義搜尋

  • 產品建議

  • 個人化

  • 聊天機器人

  • 詐騙偵測

  • 異常偵測

支援的索引屬性

選項 3.6 4.0 5.0 8.0 彈性叢集
name

建立向量索引

使用 createIndex 命令搭配 runCommand()方法來建立向量索引。語法是:

db.runCommand({ "createIndexes": "<collection>", "indexes": [{ "key": { "<field>": "vector" }, "name": "<name>", "vectorOptions": { "type": "<hnsw> | <ivfflat>", "dimensions": <number of dimensions>, "similarity": "<euclidean>|<cosine>|<dotProduct>", "lists": <number_of_lists> [applicable for IVFFlat], "m": <max number of connections> [applicable for HNSW], "efConstruction": <size of the dynamic list for index build> [applicable for HNSW] } }] })

金鑰參數是 JSON 文件,可指定欄位和向量索引類型:

{ "<field>": "vector" }

如需建立向量索引的範例,請參閱索引屬性