Embeddings interface for generating vector embeddings from text queries, enabling vector-based similarity searches.
Method to add documents to the Elasticsearch database. It first converts the documents to vectors using the embeddings, then adds the vectors to the database.
The documents to add to the database.
Optional
options: { Optional parameter that can contain the IDs for the documents.
Optional
ids?: string[]A promise that resolves with the IDs of the added documents.
Method to add vectors to the Elasticsearch database. It ensures the index exists, then adds the vectors and their corresponding documents to the database.
The vectors to add to the database.
The documents corresponding to the vectors.
Optional
options: { Optional parameter that can contain the IDs for the documents.
Optional
ids?: string[]A promise that resolves with the IDs of the added documents.
Creates a VectorStoreRetriever
instance with flexible configuration options.
Optional
kOrFields: number | Partial<VectorStoreRetrieverInput<ElasticVectorSearch>>If a number is provided, it sets the k
parameter (number of items to retrieve).
Optional
filter: ElasticFilterOptional filter criteria to limit the items retrieved based on the specified filter type.
Optional
callbacks: CallbacksOptional callbacks that may be triggered at specific stages of the retrieval process.
Optional
tags: string[]Tags to categorize or label the VectorStoreRetriever
. Defaults to an empty array if not provided.
Optional
metadata: Record<string, unknown>Additional metadata as key-value pairs to add contextual information for the retrieval process.
Optional
verbose: booleanIf true
, enables detailed logging for the retrieval process. Defaults to false
.
VectorStoreRetriever
instance based on the provided parameters.Optional
maxReturn documents selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to the query AND diversity among selected documents.
Text to look up documents similar to.
Searches for documents similar to a text query by embedding the query and performing a similarity search on the resulting vector.
Text query for finding similar documents.
Optional
k: numberNumber of similar results to return. Defaults to 4.
Optional
filter: ElasticFilterOptional filter based on FilterType
.
Optional
_callbacks: CallbacksOptional callbacks for monitoring search progress
A promise resolving to an array of DocumentInterface
instances representing similar documents.
Method to perform a similarity search in the Elasticsearch database using a vector. It returns the k most similar documents along with their similarity scores.
The query vector.
The number of most similar documents to return.
Optional
filter: ElasticFilterOptional filter to apply to the search.
A promise that resolves with an array of tuples, where each tuple contains a Document and its similarity score.
Searches for documents similar to a text query by embedding the query, and returns results with similarity scores.
Text query for finding similar documents.
Optional
k: numberNumber of similar results to return. Defaults to 4.
Optional
filter: ElasticFilterOptional filter based on FilterType
.
Optional
_callbacks: CallbacksOptional callbacks for monitoring search progress
A promise resolving to an array of tuples, each containing a document and its similarity score.
Static
fromStatic method to create an ElasticVectorSearch instance from Document instances. It adds the documents to the Elasticsearch database, then returns the ElasticVectorSearch instance.
The Document instances to create the ElasticVectorSearch instance from.
The embeddings to use for the documents.
The configuration for the Elasticsearch database.
A promise that resolves with the created ElasticVectorSearch instance.
Static
fromStatic method to create an ElasticVectorSearch instance from an existing index in the Elasticsearch database. It checks if the index exists, then returns the ElasticVectorSearch instance if it does.
The embeddings to use for the documents.
The configuration for the Elasticsearch database.
A promise that resolves with the created ElasticVectorSearch instance if the index exists, otherwise it throws an error.
Static
fromStatic method to create an ElasticVectorSearch instance from texts. It creates Document instances from the texts and their corresponding metadata, then calls the fromDocuments method to create the ElasticVectorSearch instance.
The texts to create the ElasticVectorSearch instance from.
The metadata corresponding to the texts.
The embeddings to use for the documents.
The arguments to create the Elasticsearch client.
A promise that resolves with the created ElasticVectorSearch instance.
Class for interacting with an Elasticsearch database. It extends the VectorStore base class and provides methods for adding documents and vectors to the Elasticsearch database, performing similarity searches, deleting documents, and more.