View a markdown version of this page

向量索引 - Amazon DocumentDB
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

向量索引

矢量索引是一种特殊类型的索引,旨在有效地查询和管理存储在文档集合中的矢量数据。Amazon DocumentDB 支持分层可导航小世界 (HNSW) 和带平面压缩的倒置文件 (ivfFLat) 索引。

有关更多信息,请参阅 Amazon DocumentDB 向量搜索

向量索引有利于机器学习和生成式 AI 用例,例如:

  • 语义搜索

  • 产品推荐

  • 个性化

  • 聊天机器人

  • 欺诈检测

  • 异常检测

支持的索引属性

Option 3.6 4.0 5.0 8.0 弹性集群
name

创建向量索引

使用带有runCommand()方法的 createIndex 命令来创建向量索引。语法如下:

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" }

有关创建矢量索引的示例,请参阅索引属性