ElasticVectorSearch
features and configurations head to the API reference.
Overview
Integration details
Class | Package | PY support | Version |
---|---|---|---|
ElasticVectorSearch | @langchain/community | ✅ |
Setup
To use Elasticsearch vector stores, you’ll need to install the@langchain/community
integration package.
LangChain.js accepts @elastic/elasticsearch
as the client for Elasticsearch vectorstore. You’ll need to install it as a peer dependency.
This guide will also use OpenAI embeddings, which require you to install the @langchain/openai
integration package. You can also use other supported embeddings models if you wish.
Credentials
To use Elasticsearch vector stores, you’ll need to have an Elasticsearch instance running. You can use the official Docker image to get started, or you can use Elastic Cloud, Elastic’s official cloud service. For connecting to Elastic Cloud you can read the documentation reported here for obtaining an API key. If you are using OpenAI embeddings for this guide, you’ll need to set your OpenAI key as well:Instantiation
Instatiating Elasticsearch will vary depending on where your instance is hosted.Manage vector store
Add items to vector store
Delete items from vector store
You can delete values from the store by passing the same id you passed in:Query vector store
Once your vector store has been created and the relevant documents have been added you will most likely wish to query it during the running of your chain or agent.Query directly
Performing a simple similarity search can be done as follows:Query by turning into retriever
You can also transform the vector store into a retriever for easier usage in your chains.Usage for retrieval-augmented generation
For guides on how to use this vector store for retrieval-augmented generation (RAG), see the following sections:API reference
For detailed documentation of allElasticVectorSearch
features and configurations head to the API reference.