Skip to main content
Elasticsearch is a distributed, RESTful search and analytics engine that can efficiently store and search vector data using dense vectors and k-NN search.

Installation

Elasticsearch support requires the Elasticsearch client as an extra dependency.

Usage

The TypeScript SDK uses camelCase config keys: collectionName, embeddingModelDims, cloudId, apiKey, useSsl, verifyCerts, caCerts, autoCreateIndex, and username (in place of the Python user). collectionName and embeddingModelDims are required. Because the vector store embeds text with your configured embedder before writing, set an embedder in the config as shown above.

Config

Here are the parameters available for configuring Elasticsearch:

Features

  • Efficient vector search using Elasticsearch’s native k-NN search
  • Support for both local and cloud deployments (Elastic Cloud)
  • Multiple authentication methods (Basic Auth, API Key)
  • Automatic index creation with optimized mappings for vector search
  • Memory isolation through payload filtering
  • Custom search query function to customize the search query

Custom Search Query

custom_search_query is available in the Python SDK only. The TypeScript SDK runs a fixed k-NN query with optional metadata filters.
The custom_search_query parameter allows you to customize the search query when Memory.search is called. Example
It should be a function that takes the following parameters:
  • query: a query vector used in Memory.search
  • limit: a number of results used in Memory.search
  • filters: a dictionary of key-value pairs used in Memory.search. You can add custom pairs for the custom search query.
The function should return a query body for the Elasticsearch search API.