Skip to main content
Elasticsearch is a distributed, RESTful search and analytics engine. It provides a distributed, multi-tenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.

Installation and Setup

Setup Elasticsearch

There are two ways to get started with Elasticsearch:

Install Elasticsearch on your local machine

The easiest way to run Elasticsearch locally for development and testing is using the start-local script. This script sets up Elasticsearch using Docker with a simple one-line command.
curl -fsSL https://elastic.co/start-local | sh
This creates an elastic-start-local folder. To start Elasticsearch:
cd elastic-start-local
./start.sh
Elasticsearch will be available at http://localhost:9200. The password for the elastic user and API key are automatically generated and stored in the .env file in the elastic-start-local folder. If you only need Elasticsearch without Kibana, you can use the --esonly option:
curl -fsSL https://elastic.co/start-local | sh -s -- --esonly
The start-local setup is for local testing only and should not be used in production. For production installations, refer to the official Elasticsearch documentation.

Deploy Elasticsearch on Elastic Cloud

Elastic Cloud is a managed Elasticsearch service. Signup for a free trial.

Install Client

pip install elasticsearch
pip install langchain-elasticsearch

Embedding models

See a usage example.
from langchain_elasticsearch import ElasticsearchEmbeddings

Vector store

See a usage example.
from langchain_elasticsearch import ElasticsearchStore

Third-party integrations

EcloudESVectorStore

from langchain_community.vectorstores.ecloud_vector_search import EcloudESVectorStore

Retrievers

ElasticsearchRetriever

The ElasticsearchRetriever enables flexible access to all Elasticsearch features through the Query DSL. See a usage example.
from langchain_elasticsearch import ElasticsearchRetriever

BM25

See a usage example.
from langchain_community.retrievers import ElasticSearchBM25Retriever

LLM cache

from langchain_elasticsearch import ElasticsearchCache

Byte Store

See a usage example.
from langchain_elasticsearch import ElasticsearchEmbeddingsCache

Chain

It is a chain for interacting with Elasticsearch Database.
from langchain_classic.chains.elasticsearch_database import ElasticsearchDatabaseChain

Connect these docs to Claude, VSCode, and more via MCP for real-time answers.