Skip to main content

OpenSearch 向量存储

🌐 OpenSearch Vector Store

OpenSearchVector 类提供使用 OpenSearch 的向量搜索功能,OpenSearch 是一个开源的搜索和分析引擎。它利用 OpenSearch 的 k-NN 功能来执行向量相似性搜索。

🌐 The OpenSearchVector class provides vector search using OpenSearch, an open-source search and analytics engine. It uses OpenSearch's k-NN capabilities to perform vector similarity search.

构造函数选项
Direct link to 构造函数选项

🌐 Constructor Options

构造函数接受所有 OpenSearch ClientOptions 选项,并且需要一个必填的 id 字段。

🌐 The constructor accepts all OpenSearch ClientOptions plus a required id field.

id:

string
Unique identifier for this vector store instance

node:

string | string[] | NodeOptions | NodeOptions[]
OpenSearch node URL(s) (e.g., 'http://localhost:9200')

auth?:

BasicAuth | BearerAuth | AwsSigv4Auth
Authentication configuration

ssl?:

ConnectionOptions
SSL/TLS configuration

compression?:

'gzip'
Enable gzip compression

方法
Direct 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()

列出 OpenSearch 实例中的所有索引。

🌐 Lists all indexes in the OpenSearch instance.

返回:Promise<string[]>

🌐 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()

通过 ID 或元数据过滤器更新单个向量。必须提供 idfilter 中的一个,但不能同时提供两者。

🌐 Update a single vector by ID or by metadata filter. Either id or filter must be provided, but not both.

indexName:

string
The name of the index to update vectors in

id?:

string
The ID of the vector to update (mutually exclusive with filter)

filter?:

Record<string, any>
Metadata filter to identify vector(s) to update (mutually exclusive with id)

update:

{ vector?: number[]; metadata?: Record<string, any>; }
Object containing the vector and/or metadata to update

deleteVector()
Direct link to deleteVector()

根据 ID 从索引中删除单个向量。

🌐 Deletes a single vector by its ID from the index.

indexName:

string
The name of the index to delete the vector from

id:

string
The ID of the vector to delete

deleteVectors()
Direct link to deleteVectors()

通过 ID 或元数据过滤器删除多个向量。必须提供 idsfilter 中的一个,但不能同时提供两者。

🌐 Delete multiple vectors by IDs or by metadata filter. Either ids or filter must be provided, but not both.

indexName:

string
Name of the index containing the vectors to delete

ids?:

string[]
Array of vector IDs to delete (mutually exclusive with filter)

filter?:

Record<string, any>
Metadata filter to identify vectors to delete (mutually exclusive with ids)

🌐 Related