oxsearch
A typed Rust client for Elasticsearch, generated from the Elasticsearch specification, with typed AI search: retrievers, semantic, knn and sparse_vector queries, semantic_text mappings, the inference API, and a typed document layer.
Status: 0.2. The generated crates cover search, documents, mappings, analysis, inference, tasks, aggregations, ES|QL, administration, ingest pipelines, enrich policies, query rules, synonyms, search applications, async search, EQL, SQL, snapshots, index lifecycle management and the license API: 289 endpoints, tested against the specification's own examples, and 183 of them against Elasticsearch 9 on the Basic license and a trial. Security, machine learning, transforms and the other areas come next; see DESIGN.md for the plan and CHANGELOG.md for what's in each release.
Quick start
Semantic search over your own documents, with features = ["derive", "transport-reqwest"]. semantic_text embeds with the cluster's default ELSER model, which needs a license above Basic, such as a trial; on Basic, the RAG example uses your own embeddings and fuses on the client instead.
use ;
use ReqwestTransport;
use ;
use ;
async
(examples/quickstart.rs; a test keeps the two the same.)
What's in it
- Generated types and endpoints for every request and response in the areas generated so far, with builders,
Rawvariants for what a newer Elasticsearch adds, and typed errors (license refusals and version conflicts have their own). - Aggregations with typed results (
oxsearch::aggs, theaggsfeature):Agg::terms("category", 10).sub("avg_price", Agg::avg("price")), sent withtyped_keysand read back asAggregates. - ES|QL (
oxsearch::esql, theesqlfeature): a typed builder,Esql::from_index("books").where_(col("year").gte(2020)).sort([col("year").desc()]), with values sent as parameters,FORKandFUSE; and rows read into your own structs by column name with.fetch(&client), or as Arrow record batches with.fetch_arrow(&client)(theesql-arrowfeature). - Ingest pipelines (
oxsearch::ingest, theingestfeature): pipelines built from typed processors (SetProcessor::new("indexed_by").value(…).into()), simulated, or run as documents are indexed, including the inference processor that embeds text at index time. - Search relevance: query rules that pin documents for matching queries (
oxsearch::query_rules, thequery-rulesfeature) and synonym sets that analyzers read and update without reindexing (oxsearch::synonyms, thesynonymsfeature). - More ways to query: async search, EQL and SQL (
oxsearch::async_search,oxsearch::eql,oxsearch::sql), search applications (oxsearch::search_application) and enrich policies (oxsearch::enrich), each behind the feature of its name. - Operations: snapshots (
oxsearch::snapshot, thesnapshotfeature) and index lifecycle policies (oxsearch::ilm, theilmfeature). - Administration (
oxsearch::admin, theadminfeature): indices, their mappings, settings, aliases, templates and data streams; the cluster's health, settings and state; and nodes' information and statistics. - Query and retriever builders:
Query::r#match,Query::semantic,Retriever::knn,Retriever::rrf, …; and fusion on the client (oxsearch::fusion) when the license doesn't include therrfandlinearretrievers. - A typed document layer (
oxsearch::document, thedocumentfeature, whichderiveimplies):#[derive(Document)]maps a struct,Index<T>reads and writes it, and field handles offer only the queries that suit each field. - Helpers (
oxsearch::helpers): a point-in-time scan and a bulk loader with backpressure. - Transport layers: several nodes with failover, retries, sniffing, credentials (basic, bearer, API key, Elastic Cloud) and gzip.
- Telemetry through
tracingandmetrics, following the OpenTelemetry conventions for Elasticsearch, for oxtel or any other exporter. - A
rigvector store (oxsearch-rig). - Escape hatches for what isn't covered yet: your own
Endpoint,Rawvariants andClient::send_raw(example).
docs/coverage.md lists the endpoints generated and those the integration tests exercise.
Versions
oxsearch's versions are its own, 0.N while its API settles. Each release is generated from one branch of the Elasticsearch specification, one Elasticsearch minor, and tested against that minor:
| oxsearch | Specification branch (commit) | Tested against |
|---|---|---|
| 0.2 | 9.5 (84bf510a) |
Elasticsearch 9.5.5 |
| 0.1 | 9.5 (84bf510a) |
Elasticsearch 9.5.5 |
Elasticsearch 9 servers of other minors understand it too, for what both have; a newer server's additions read as Raw values until a release generated from its branch.
Licenses of Elasticsearch features
Every API is generated whatever the license; a request for a feature the cluster's license doesn't include fails with Error::License. What the integration tests show on Elasticsearch 9.5:
| Feature | Basic | Above Basic (trial) |
|---|---|---|
kNN query and retriever, standard, pinned, rescorer, diversify retrievers |
✓ | ✓ |
sparse_vector with weights, intervals, everything else in the query DSL |
✓ | ✓ |
Fusion on the client (oxsearch::fusion) |
✓ | ✓ |
rrf and linear retrievers (server-side fusion) |
✓ | |
rule and text_similarity_reranker retrievers |
✓ | |
semantic_text with ELSER, and other machine learning models, including the ingest inference processor |
✓ | |
| ES|QL, aggregations, async search, EQL, SQL, ingest pipelines, enrich, synonyms, snapshots, ILM, administration | ✓ | ✓ |
ES|QL FUSE |
✓ | |
| Query rules (Enterprise) and search applications (Platinum) | ✓ |
Elastic's subscription matrix is the authority, and it has moved between releases.
Development
The workspace needs Rust 1.95 or newer.
The generator reads the specification's schema.json from the commit pinned in spec/pin.toml, one Elasticsearch minor at a time. This downloads it, checks its SHA-256 and reads it:
The generated code in each crate's src/generated comes from that pin, and is never edited by hand. This writes it again, with round-trip tests from the specification's examples in each crate's tests/examples.rs:
The integration tests run against Elasticsearch in Docker, on the Basic license or a trial license:
OXSEARCH_TEST_LICENSE=trial
With the fixture up, the examples run against it:
License
Apache-2.0. See LICENSE and CONTRIBUTING.md; every commit is signed off under the Developer Certificate of Origin.
oxsearch is not affiliated with or endorsed by Elastic. Elasticsearch is a trademark of Elasticsearch B.V., used here only to say what oxsearch works with.