For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

$vectorSearch (aggregation stage)

$vectorSearch

$vectorSearch performs a semantic search on data in your Atlas cluster.

If you store vector embeddings on your Atlas cluster, you can seamlessly index the vector data along with your other collection data. You can use the $vectorSearch stage to pre-filter your data and perform semantic search against the indexed fields.

Your vector data must be less than or equal to 8192 dimensions in width.

The $vectorSearch aggregation pipeline stage is available in the following environments:

To learn more, see MongoDB Vector Search.

Starting in MongoDB 8.0, you can use a $vectorSearch stage in a $unionWith stage.

You cannot use a $vectorSearch stage in a $facet stage or a $lookup stage.