Skip to main content
This will help you get started with Elasticsearch key-value stores. For detailed documentation of all ElasticsearchEmbeddingsCache features and configurations head to the API reference.

Overview

The ElasticsearchEmbeddingsCache is a ByteStore implementation that uses your Elasticsearch instance for efficient storage and retrieval of embeddings.

Integration details

Setup

To create a ElasticsearchEmbeddingsCache byte store, you’ll need an Elasticsearch cluster. You can set one up locally or create an Elastic account.

Installation

The LangChain ElasticsearchEmbeddingsCache integration lives in the langchain-elasticsearch package:

Instantiation

Now we can instantiate our byte store:

Usage

You can set data under keys like this using the mset method:
And you can delete data using the mdelete method:

Use as an embeddings cache

Like other ByteStores, you can use an ElasticsearchEmbeddingsCache instance for persistent caching in document ingestion for RAG. However, cached vectors won’t be searchable by default. The developer can customize the building of the Elasticsearch document in order to add indexed vector field. This can be done by subclassing and overriding methods:
When overriding the mapping and the document building, please only make additive modifications, keeping the base mapping intact.

API reference

For detailed documentation of all ElasticsearchEmbeddingsCache features and configurations, head to the API reference