class ElasticVectorSearchElasticsearch vector store supporting vector and hybrid search.
Hybrid search combines kNN vector search with BM25 full-text search
using RRF. Enable by passing a HybridRetrievalStrategy to the constructor.
Embeddings interface for generating vector embeddings from text queries, enabling vector-based similarity searches.
Returns a string representing the type of vector store, which subclasses must implement to identify their specific vector storage type.
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.
Method to add vectors to the Elasticsearch database. It ensures the index exists, then adds the vectors and their corresponding documents to the database.
Creates a VectorStoreRetriever instance with flexible configuration options.
Method to delete documents from the Elasticsearch database.
Method to delete an index from the Elasticsearch database if it exists.
Method to check if an index exists in the Elasticsearch database.
Return documents selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to the query AND diversity among selected documents.
Searches for documents similar to a text query by embedding the query and performing a similarity search on the resulting vector.
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.
Searches for documents similar to a text query by embedding the query, and returns results with similarity scores.
Static method to create an ElasticVectorSearch instance from Document instances. It adds the documents to the Elasticsearch database, then returns the ElasticVectorSearch instance.
Static 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.
Static 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 name of the serializable. Override to provide an alias or to preserve the serialized module name in minified environments.
Implemented as a static method to support loading logic.
// Vector search (default)
const vectorStore = new ElasticVectorSearch(embeddings, { client, indexName });
// Hybrid search
const hybridStore = new ElasticVectorSearch(embeddings, {
client,
indexName,
strategy: new HybridRetrievalStrategy()
});