Search knowledge in Elasticsearch with vector, keyword and hybrid search
September 16, 20261 min read
Agno's new Elasticsearch vector database, from agno.vectordb.elasticsearch, stores the chunks of an Agno Knowledge in an Elasticsearch index. Teams that already run Elasticsearch for search and logs can keep agent knowledge there too.
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.elasticsearch import Elasticsearch
from agno.vectordb.search import SearchType
knowledge = Knowledge(
vector_db=Elasticsearch(
index_name="recipes",
url="http://localhost:9200",
search_type=SearchType.hybrid,
),
)
Vector search is the default. It runs kNN over a dense_vector field and applies your filters before the search. Keyword search runs multi_match over each chunk's content and name. Hybrid search combines the two, and hybrid_strategy picks how:
HybridStrategy.boost, the default, adds 0.7 of the vector score to 0.3 of the keyword score. It works on every Elasticsearch license.HybridStrategy.rrfuses reciprocal rank fusion. It needs a Platinum, Enterprise or trial license. On a cluster without one, Agno logs a warning and falls back to boost.
The Elasticsearch vector database connects with a URL, a list of node URLs, or an Elastic Cloud ID, and authenticates with an API key or basic auth. It verifies TLS certificates by default. It also supports metadata filters, rerankers, bulk inserts and upserts, and per-user isolation through a user_id field. Every read and write has an async version on the native async client.
Pin the elasticsearch client to your cluster's major version. An 8.x cluster rejects a 9.x client.
See the cookbook, and learn more about the Elasticsearch vector database and per-user isolation in the documentation.
Frequently asked questions
Install elasticsearch[async], then pass Elasticsearch(index_name=...) from agno.vectordb.elasticsearch as the vector_db of an Agno Knowledge. It connects to http://localhost:9200 by default. See the cookbook.
Yes. Set search_type=SearchType.hybrid. The default HybridStrategy.boost adds 0.7 of the vector score to 0.3 of the keyword score and works on every Elasticsearch license. HybridStrategy.rrf uses reciprocal rank fusion and needs a Platinum, Enterprise or trial license.
Agno logs a warning and falls back to HybridStrategy.boost, so hybrid search keeps working. Set hybrid_strategy=HybridStrategy.boost to silence the warning.
Match the client's major version to your cluster's. An 8.x cluster rejects a 9.x client, so pin elasticsearch to the major version your cluster runs.

