Skip to main content

Module elastic

Module elastic 

Source
Expand description

Elasticsearch AsyncVectorIndex (feature elastic). Elasticsearch AsyncVectorIndex (elastic feature).

ElasticsearchVectorIndex implements AsyncVectorIndex over a hand-rolled reqwest client speaking Elasticsearch 8.x’s REST API. It is the async counterpart to the in-memory VectorIndex and a sibling of QdrantVectorIndex.

§Why hand-rolled reqwest (not the elasticsearch crate)?

The official elasticsearch crate has no stable release — every published version is -alpha.x (max_stable_version: None on crates.io). For a foundation library heading into the v1.0.0 semver lock, an alpha dependency is a blocker. The REST surface this trait needs is small (index create/delete, bulk upsert/delete, knn _search, _count), so a typed reqwest client reuses the existing client-async reqwest dependency and adds zero transitive crates.

§Scope

Elasticsearch is a hybrid engine (BM25 + dense vector). Per the v0.9.0 design decision, this implementation exposes only the dense-vector contract of AsyncVectorIndex — native BM25 text search via a SearchProvider is deferred to a later milestone. The vector results federate cleanly with Qdrant and TurboVec because federation defaults to rank-based RRF (scale-invariant).

§Score semantics

The score field of each SearchHit carries the Elasticsearch knn _score, which for a cosine-similarity dense_vector field is (1 + cosine) / 2 ∈ [0, 1]not the raw cosine that Qdrant reports ([0, 1] of a different monotonic map) nor the [-1, 1] raw cosine of the in-memory TurbovecIndex. Cross-backend score magnitudes are therefore not directly comparable. This is harmless under the federation default (Reciprocal Rank Fusion — rank-based and scale-invariant), but WeightedSum federation (behind the optional federation feature, which min-max normalizes each list in isolation before a weighted sum) should be used with care across these heterogeneous scales. See the federation module’s “Why RRF is the default” docs for the full rationale.

Structs§

ElasticsearchVectorIndex
Async vector index backed by an Elasticsearch 8.x index.

Functions§

redact_credentials
Strip user:pass@ userinfo from any URL embedded in s.