createIndex(
dimensions: number | undefined = undefined,
indexType: "ivf" | "hnsw" | "diskann" = "ivf",
| Name | Type | Description |
|---|---|---|
dimensions | number | undefined | Default: undefined |
indexType | "ivf" | "hnsw" | "diskann" | Default: "ivf" |
similarity | AzureCosmosDBMongoDBSimilarityType | Default: AzureCosmosDBMongoDBSimilarityType.COS |
Creates an index on the collection with the specified index name during instance construction.
Setting the numLists parameter correctly is important for achieving good accuracy and performance. Since the vector store uses IVF as the indexing strategy, you should create the index only after you have loaded a large enough sample documents to ensure that the centroids for the respective buckets are faily distributed.
We recommend that numLists is set to documentCount/1000 for up to 1 million documents and to sqrt(documentCount) for more than 1 million documents. As the number of items in your database grows, you should tune numLists to be larger in order to achieve good latency performance for vector search.
If you're experimenting with a new scenario or creating a small demo, you can start with numLists set to 1 to perform a brute-force search across all vectors. This should provide you with the most accurate results from the vector search, however be aware that the search speed and latency will be slow. After your initial setup, you should go ahead and tune the numLists parameter using the above guidance.
Number of dimensions for vector similarity. The maximum number of supported dimensions is 2000. If no number is provided, it will be determined automatically by embedding a short text.
Index Type for Mongo vCore index.
Similarity metric to use with the IVF index. Possible options are: