ElasticHandshake
class provides seamless integration between Chonkie’s chunking system and Elasticsearch, allowing you to leverage its powerful vector search capabilities.
Embed and store your Chonkie chunks in an Elasticsearch index without ever leaving the Chonkie SDK. The handshake automatically handles index creation and the necessary vector field mapping.
Installation
Before using the Elasticsearch handshake, make sure to install the required dependencies:Basic Usage
Initialization
Parameters
An existing
elasticsearch.Elasticsearch
client instance. If not provided, a new client will be created based on other parameters.Name of the Elasticsearch index to use. If “random”, a unique name will be generated.
The embedding model to use for creating vectors. Can be a model name from Hugging Face or a
BaseEmbeddings
instance.The URL(s) of the Elasticsearch instance(s) to connect to.
The Cloud ID for connecting to an Elastic Cloud deployment.
The API key for authenticating with Elasticsearch, commonly used for Elastic Cloud.
Writing Chunks to Elasticsearch
Searching Chunks in Elasticsearch
You can retrieve the most similar chunks from your Elasticsearch index using thesearch
method, which performs a k-Nearest Neighbor (kNN) vector search.