Skip to main content
Mastra v1 is coming in January 2026. Get ahead by starting new projects with the beta or upgrade your existing project today.

OpenSearch Vector Store

The OpenSearchVector class provides vector search using OpenSearch, a powerful open-source search and analytics engine. It leverages OpenSearch's k-NN capabilities to perform efficient vector similarity search.

Constructor OptionsDirect link to Constructor Options

url:

string
OpenSearch connection URL (e.g., 'http://localhost:9200')

MethodsDirect link to Methods

createIndex()Direct link to createIndex()

Creates a new index with the specified configuration.

indexName:

string
The name of the index to create

dimension:

number
The dimension of the vectors to be stored in the index

metric?:

'cosine' | 'euclidean' | 'dotproduct'
= 'cosine'
The distance metric to use for vector similarity

listIndexes()Direct link to listIndexes()

Lists all indexes in the OpenSearch instance.

Returns: Promise<string[]>

describeIndex()Direct link to describeIndex()

Gets information about an index.

indexName:

string
The name of the index to describe

deleteIndex()Direct link to deleteIndex()

indexName:

string
The name of the index to delete

upsert()Direct link to upsert()

indexName:

string
The name of the index to upsert vectors into

vectors:

number[][]
Array of vector embeddings to insert

metadata?:

Record<string, any>[]
Array of metadata objects corresponding to each vector

ids?:

string[]
Optional array of IDs for the vectors. If not provided, random IDs will be generated

query()Direct link to query()

indexName:

string
The name of the index to query

queryVector:

number[]
The query vector to find similar vectors for

topK?:

number
= 10
The number of results to return

filter?:

VectorFilter
Optional filter to apply to the query (MongoDB-style query syntax)

updateVector()Direct link to updateVector()

Updates a specific vector entry by its ID with new vector data and/or metadata.

indexName:

string
The name of the index to update vectors in

id:

string
The ID of the vector to update

update:

object
Update data containing vector and/or metadata

update.vector?:

number[]
The new vector embedding

update.metadata?:

Record<string, any>
The new metadata

deleteVector()Direct link to deleteVector()

Deletes specific vector entries by their IDs from the index.

indexName:

string
The name of the index to delete vectors from

ids:

string[]
Array of vector IDs to delete