Database Manual / Reference / Query Language / Aggregation Stages

$vectorSearch (aggregation stage)(聚合阶段)

Definition定义

Important

The $vectorSearch aggregation pipeline stage is only available for collections hosted on MongoDB Atlas cluster tiers running MongoDB version 6.0.11 or later. To learn more, see Vector Search.$vectorSearch聚合管道阶段仅适用于运行MongoDB 6.0.11或更高版本的MongoDB Atlas集群层上托管的集合。要了解更多信息,请参阅矢量搜索。

$vectorSearch

$vectorSearch performs a semantic search on data in your Atlas cluster.对Atlas集群中的数据执行语义搜索。

If you store vector embeddings on your Atlas cluster, you can seamlessly index the vector data along with your other collection data. 如果将向量嵌入存储在Atlas集群上,则可以将向量数据与其他集合数据无缝地索引。You can use the $vectorSearch stage to pre-filter your data and perform semantic search against the indexed fields.您可以使用$vectorSearch阶段预筛选数据,并对索引字段执行语义搜索。

Your vector data must be less than or equal to 4096 dimensions in width.矢量数据的宽度必须小于或等于4096维。

Behavior行为

Starting in MongoDB 8.0, you can use a $vectorSearch stage in a $unionWith stage.从MongoDB 8.0开始,您可以在$unionWith阶段中使用$vectorSearch阶段。

Limitations局限性

You cannot use a $vectorSearch stage in a $facet stage or a $lookup stage.您不能在$facet阶段或$lookup阶段中使用$vectorSearch阶段。

Learn More了解更多