import type { CreateIndexParams, DeleteIndexParams, DeleteVectorParams, DescribeIndexParams, IndexStats, QueryResult, QueryVectorParams, UpdateVectorParams, UpsertVectorParams, DeleteVectorsParams } from '@mastra/core/vector'; import { MastraVector } from '@mastra/core/vector'; import type { ClientOptions } from '@opensearch-project/opensearch'; import type { OpenSearchVectorFilter } from './filter.js'; /** * Configuration for OpenSearchVector. * * Extends the OpenSearch ClientOptions with a required id. * All OpenSearch client options are supported (node, auth, ssl, compression, etc.). * * @example * ```typescript * // Simple URL config * const vector = new OpenSearchVector({ * id: 'my-vector', * node: 'http://localhost:9200', * }); * * // With authentication * const vector = new OpenSearchVector({ * id: 'my-vector', * node: 'https://my-opensearch-cluster.com', * auth: { username: 'admin', password: 'secret' }, * ssl: { rejectUnauthorized: false }, * }); * ``` */ export type OpenSearchVectorConfig = ClientOptions & { id: string; }; type OpenSearchVectorParams = QueryVectorParams; export declare class OpenSearchVector extends MastraVector { private client; /** * Creates a new OpenSearchVector client. * * @param config - OpenSearch client configuration options plus a required id. * @see OpenSearchVectorConfig for all available options. */ constructor({ id, ...clientOptions }: OpenSearchVectorConfig); /** * Creates a new collection with the specified configuration. * * @param {string} indexName - The name of the collection to create. * @param {number} dimension - The dimension of the vectors to be stored in the collection. * @param {'cosine' | 'euclidean' | 'dotproduct'} [metric=cosine] - The metric to use to sort vectors in the collection. * @returns {Promise} A promise that resolves when the collection is created. */ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise; /** * Lists all indexes. * * @returns {Promise} A promise that resolves to an array of indexes. */ listIndexes(): Promise; /** * Retrieves statistics about a vector index. * * @param {string} indexName - The name of the index to describe * @returns A promise that resolves to the index statistics including dimension, count and metric */ describeIndex({ indexName }: DescribeIndexParams): Promise; /** * Deletes the specified index. * * @param {string} indexName - The name of the index to delete. * @returns {Promise} A promise that resolves when the index is deleted. */ deleteIndex({ indexName }: DeleteIndexParams): Promise; /** * Inserts or updates vectors in the specified collection. * * @param {string} indexName - The name of the collection to upsert into. * @param {number[][]} vectors - An array of vectors to upsert. * @param {Record[]} [metadata] - An optional array of metadata objects corresponding to each vector. * @param {string[]} [ids] - An optional array of IDs corresponding to each vector. If not provided, new IDs will be generated. * @returns {Promise} A promise that resolves to an array of IDs of the upserted vectors. */ upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise; /** * Queries the specified collection using a vector and optional filter. * * @param {string} indexName - The name of the collection to query. * @param {number[]} queryVector - The vector to query with. * @param {number} [topK] - The maximum number of results to return. * @param {Record} [filter] - An optional filter to apply to the query. For more on filters in OpenSearch, see the filtering reference: https://opensearch.org/docs/latest/query-dsl/ * @param {boolean} [includeVectors=false] - Whether to include the vectors in the response. * @returns {Promise} A promise that resolves to an array of query results. */ query({ indexName, queryVector, filter, topK, includeVector, }: OpenSearchVectorParams): Promise; /** * Validates the dimensions of the vectors. * * @param {number[][]} vectors - The vectors to validate. * @param {number} dimension - The dimension of the vectors. * @returns {void} */ private validateVectorDimensions; /** * Transforms the filter to the OpenSearch DSL. * * @param {OpenSearchVectorFilter} filter - The filter to transform. * @returns {Record} The transformed filter. */ private transformFilter; /** * Updates vectors by ID or filter with the provided vector and/or metadata. * @param params - Parameters containing either id or filter for targeting vectors to update * @param params.indexName - The name of the index containing the vector(s). * @param params.id - The ID of a single vector to update (mutually exclusive with filter). * @param params.filter - A filter to match multiple vectors to update (mutually exclusive with id). * @param params.update - An object containing the vector and/or metadata to update. * @returns A promise that resolves when the update is complete. * @throws Will throw an error if no updates are provided or if the update operation fails. */ updateVector(params: UpdateVectorParams): Promise; /** * Updates a single vector by its ID. */ private updateVectorById; /** * Updates multiple vectors matching a filter. */ private updateVectorsByFilter; /** * Deletes a vector by its ID. * @param indexName - The name of the index containing the vector. * @param id - The ID of the vector to delete. * @returns A promise that resolves when the deletion is complete. * @throws Will throw an error if the deletion operation fails. */ deleteVector({ indexName, id }: DeleteVectorParams): Promise; deleteVectors({ indexName, filter, ids }: DeleteVectorsParams): Promise; } export {}; //# sourceMappingURL=index.d.ts.map