Skip to main content

Elasticsearch

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 via Dockerโ€‹

Example: Run a single-node Elasticsearch instance with security disabled. This is not recommended for production use.

    docker run -p 9200:9200 -e "discovery.type=single-node" -e "xpack.security.enabled=false" -e "xpack.security.http.ssl.enabled=false" docker.elastic.co/elasticsearch/elasticsearch:8.9.0

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
API Reference:ElasticsearchStore

Third-party integrationsโ€‹

EcloudESVectorStoreโ€‹

from langchain_community.vectorstores.ecloud_vector_search import EcloudESVectorStore
API Reference: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

Memoryโ€‹

See a usage example.

from langchain_elasticsearch import ElasticsearchChatMessageHistory

LLM cacheโ€‹

See a usage example.

from langchain_elasticsearch import ElasticsearchCache
API Reference:ElasticsearchCache

Byte Storeโ€‹

See a usage example.

from langchain_elasticsearch import ElasticsearchEmbeddingsCache

Chainโ€‹

It is a chain for interacting with Elasticsearch Database.

from langchain.chains.elasticsearch_database import ElasticsearchDatabaseChain

Was this page helpful?