Docs Menu

Docs HomeLaunch & Manage MongoDBMongoDB Atlas

Create an Atlas Vector Search Index

On this page

  • Prerequisites
  • Required Access
  • Supported Clients
  • Procedure
  • Create an Example Index From the Atlas UI

Atlas Search index is a data structure that categorizes data in an easily searchable format. It is a mapping between terms and the documents that contain those terms. Atlas Search indexes enable faster retrieval of documents using certain identifiers. You must configure an Atlas Search index to query data in your Atlas cluster using Atlas Search.

You can create an Atlas Search index on a single field or on multiple fields. We recommend that you index the fields that you regularly use to sort or filter your data in order to quickly retrieve the documents that contain the relevant data at query-time.

You can create an Atlas Vector Search index for all collections that contain vector embeddings less than or equal to 4096 dimensions in width for any kind of data along with other data on your Atlas cluster through the Atlas UI and Atlas Administration API.

To create an Atlas Vector Search index, you must have an Atlas cluster with the following prerequisites:

  • MongoDB version 6.0.11, 7.0.2, or higher

  • A collection for which create the Atlas Vector Search index

You need the Project Data Access Admin or higher role to create and manage Atlas Vector Search indexes.

You can create an Atlas Vector Search index by using one of the following methods:

  • Atlas UI

  • Atlas Administration API Create One Atlas Search Index endpoint

  • Atlas CLI v1.14.3 atlas clusters search indexes create command on both the cloud deployment and local deployment

  • mongosh v2.1.2 or later db.collection.createSearchIndex() method

The following index definition for the sample_mflix.embedded_movies collection indexes the plot_embedding field as the vector type and the genres and year fields as the filter type in an Atlas Vector Search index from the Atlas UI. The plot_embedding field contains embeddings created using OpenAI's text-embedding-ada-002 embeddings model. The index definition specifies 1536 vector dimensions and measures similarity using euclidean.

1
  1. Go to the Atlas Search page.

  2. Click Create Index.

  3. Select Atlas Vector Search Editor.

  4. Click Next.

For detailed instructions, see Procedure.

2
  1. In the Index Name field, enter vector_index as the name for the index.

    Index name must be unique within the namespace, regardless of the index type. If you already have an index named vector_index on this collection, enter a different name for the index.

  2. In the Database and Collection section, find the sample_mflix database, and select the embedded_movies collection.

3
4

If you load the sample data on your cluster and create the preceding Atlas Search indexes for this collection, you can run $vectorSearch queries against this collection. To learn more about the sample queries that you can run, see $vectorSearch Examples.

← How to Index Fields for Vector Search