Docs Home → Launch & Manage MongoDB → MongoDB Atlas
Create an Atlas Vector Search Index
On this page
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.
Prerequisites
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 higherA collection for which create the Atlas Vector Search index
Required Access
You need the Project Data Access Admin
or higher role to create
and manage Atlas Vector Search indexes.
Supported Clients
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 laterdb.collection.createSearchIndex()
method
Procedure
Create an Example Index From the Atlas UI
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
.
Go the Create Vector Search Index page:
Go to the Atlas Search page.
Click Create Index.
Select Atlas Vector Search Editor.
Click Next.
For detailed instructions, see Procedure.
Enter the Index Name, and set the Database and Collection.
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.
In the Database and Collection section, find the
sample_mflix
database, and select theembedded_movies
collection.
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.