Expand description
A typed Rust client for Elasticsearch, generated from the Elasticsearch specification.
The README’s quick start (examples/quickstart.rs) does semantic search
over your own documents in a dozen lines; examples/rag.rs is the
retrieval half of a RAG application on any license.
This crate re-exports the others behind features. The defaults are the
AI-search set: search, docs, mapping and inference. The other
areas generated so far are aggs (aggregations with typed results),
esql (ES|QL, with a typed builder and rows read into your own types;
esql-arrow adds Arrow output), admin (cluster, index and node
administration), ingest (pipelines and processors), query-rules
(results pinned or excluded for matching queries), synonyms (synonym
sets), snapshot (repositories and snapshots), ilm (index lifecycle
policies), async-search, eql, sql, search-application (search
templates behind a name), enrich (enrich policies), license,
analysis and tasks. document adds the typed document layer and derive its derive
macro, helpers the point-in-time scan and the bulk loader, and
transport-reqwest the default HTTP transport.
The Client sends the generated requests over a Transport, such as
the one in transport-reqwest. Query and Retriever build the
common queries and retrievers in one call each, fusion fuses
retrievers’ results on the client when the cluster’s license doesn’t
include the rrf and linear retrievers, and document reads and
writes your own document types.
For what isn’t covered yet, implement Endpoint for your own request
(Route::segments and Body::json help), write a query, retriever or
value as a Raw variant, or send any request with Client::send_raw;
examples/escape_hatches.rs shows each.
The transport’s layers are opt-in: transport_reqwest’s builder adds
several nodes with failover, retries, sniffing, credentials and
compression, auth signs requests with credentials that refresh, and
a layer of your own is a Transport that wraps another. telemetry
records a span per request and its duration through the tracing and
metrics facades, for oxtel or any other exporter.
Every API is generated whatever the cluster’s license. A request for a
feature the license doesn’t include, such as the rrf retriever or
ELSER on Basic, fails with Error::License.
This release is generated from the Elasticsearch specification’s 9.5 branch and tested against Elasticsearch 9.5; the README’s version table lists each release’s branch.
oxsearch is not affiliated with or endorsed by Elastic. Elasticsearch is a trademark of Elasticsearch B.V.
Re-exports§
pub use oxsearch_core;pub use oxsearch_admin as admin;pub use oxsearch_aggs as aggs;pub use oxsearch_analysis as analysis;pub use oxsearch_async_search as async_search;pub use oxsearch_derive as derive;pub use oxsearch_docs as docs;pub use oxsearch_enrich as enrich;pub use oxsearch_eql as eql;pub use oxsearch_esql as esql;pub use oxsearch_ilm as ilm;pub use oxsearch_inference as inference;pub use oxsearch_ingest as ingest;pub use oxsearch_license as license;pub use oxsearch_mapping as mapping;pub use oxsearch_query_rules as query_rules;pub use oxsearch_search as search;pub use oxsearch_search_application as search_application;pub use oxsearch_snapshot as snapshot;pub use oxsearch_sql as sql;pub use oxsearch_synonyms as synonyms;pub use oxsearch_tasks as tasks;pub use oxsearch_transport_reqwest as transport_reqwest;
Modules§
- auth
- Authentication: a layer that signs each request, with fixed credentials or your own that refresh.
- document
- The typed document layer: a struct is a document type, its fields define
the index’s mapping, and an
Indexreads, writes and searches it. - fusion
- Several retrievers’ results fused into one list, on the server when its
license includes the
rrfandlinearretrievers, else on the client. - helpers
- Helpers for reading and loading a lot of documents:
Scanstreams every document a query matches over a point in time, andBulkLoaderloads documents with bulk requests. - info
- ping
- query_
dsl - shapes
- Value shapes the Elasticsearch specification uses that serde doesn’t
provide: a value or an array of values, an object keyed by a field name,
values Elasticsearch sometimes writes as strings, and so on. The
generated types are built from these, and from
IndexMapfor objects used as maps. - spec_
utils - telemetry
- Telemetry through the
tracingandmetricsfacades, following the OpenTelemetry semantic conventions for Elasticsearch: one client span per request and thedb.client.operation.durationhistogram. Install a subscriber and a recorder, such as oxtel’s, to export them; without them, nothing is recorded.
Structs§
- Acknowledged
Response Base - Aggs
Body - A search’s aggregations, as the request sends them: a JSON object of
named aggregations.
json!values convert into it, and so will the types in oxsearch-aggs. - Bulk
Index ByScroll Failure - Bulk
Stats - Cartesian
Point - Chunk
Rescorer - Client
- Sends calls to a cluster over a
Transport. - Cluster
Details - Cluster
Statistics - Completion
Stats - Coords
GeoBounds - Diversify
Retriever - DocStats
- Elasticsearch
Error - An error response from Elasticsearch.
- Elasticsearch
Version Info - Elasticsearch
Version MinInfo - Reduced (minimal) info ElasticsearchVersion
- Embedding
- Empty
Object - For empty Class assignments
- Error
Cause - Cause and details about a request failure. This class defines the properties common to all error types. Additional details are also provided, that depend on the error type.
- Error
Response Base - The response returned by Elasticsearch when request execution did not succeed.
- Field
Memory Usage - Field
Size Usage - Field
Sort - Fielddata
Stats - Flush
Stats - GeoDistance
Sort - GeoHash
Location - GeoLine
- A GeoJson GeoLine.
- GetStats
- Global
Ordinal Field Stats - Global
Ordinals Stats - Http
Request - The HTTP request a transport sends.
- Http
Response - The HTTP response a transport returns.
- Indexing
Stats - Indices
Options - Controls how to deal with unavailable concrete indices (closed or missing), how wildcard expressions are expanded to actual indices (all, closed or open indices) and how to deal with wildcard expressions that resolve to no indices.
- Indices
Response Base - Inference
String - Inline
Get - Inner
Retriever - KnnQuery
- KnnRetriever
- KnnSearch
- LatLon
GeoLocation - License
Error - A request Elasticsearch refused because the cluster’s license doesn’t include a feature it uses.
- Linear
Retriever - Lookup
Query Vector Builder - Merges
Stats - Nested
Sort Value - Node
Attributes - Node
Shard - Node
Statistics - Contains statistics about the number of nodes selected by the request.
- Pinned
Retriever - Plugin
Stats - Query
- Builders for queries. Each returns a
QueryContainer, exceptQuery::bool, whose clauses you add. - Query
Cache Stats - RRFRetriever
- RRFRetriever
Component - Wraps a retriever with an optional weight for RRF scoring.
- Rank
Base - Recovery
Stats - Refresh
Stats - Reindex
Status - Reindex
Task Info - Information about a single parent reindex task, as returned by the reindex management APIs.
- Reindex
Task Result - The final result of a completed reindex operation, as stored in the task result.
This is the serialized form of
BulkByScrollResponse. - Relocation
Failure Info - Request
Base - Request
Cache Stats - Rescore
Vector - Rescorer
Retriever - Retries
- Retriever
- Builders for retrievers. Each returns a
RetrieverContainer, and those that combine retrievers take queries too. - Retriever
Base - Route
- Where a call goes: its method and its path, percent-encoded.
- RowError
- A row of a tabular result that didn’t fit the type it was read into.
- RrfRank
- Rule
Retriever - Score
Sort - Script
- Script
Field - Script
Sort - Script
Transform - Search
Stats - Search
Transform - Segments
Stats - Shard
Failure - Shard
Statistics - Shards
Operation Response Base - Sliced
Scroll - Specified
Document - Standard
Retriever - Store
Stats - Stored
Script - Task
Failure - Text
Embedding - Text
Similarity Reranker - Token
Pruning Config - TopLeft
Bottom Right GeoBounds - TopRight
Bottom Left GeoBounds - Translog
Stats - Warmer
Stats - WktGeo
Bounds - Write
Response Base
Enums§
- Body
- A request’s body.
- Byte
Size - Bytes
- Cluster
Info Target - Cluster
Search Status - Common
Stats Flag - Conflicts
- DFIIndependence
Measure - DFRAfter
Effect - DFRBasic
Model - Date
Time - A date and time, either as a string whose format can depend on the context (defaulting to ISO 8601), or a number of milliseconds since the Epoch. Elasticsearch accepts both as input, but will generally output a string representation.
- Distance
Unit - Diversify
Retriever Types - Duration
- A duration. Units can be
nanos,micros,ms(milliseconds),s(seconds),m(minutes),h(hours) andd(days). Also accepts “0” without a unit and “-1” to indicate an unspecified value. - Error
- What can go wrong in a call.
- Expand
Wildcard - Field
Sort Numeric Type - Field
Value - A field value.
- Fuzziness
- GeoBounds
- A geo bounding box. It can be represented in various ways:
- GeoDistance
Sort Location - GeoDistance
Type - GeoHash
Precision - A precision that can be expressed as a geohash length between 1 and 12, or a distance measure like “1km”, “10m”.
- GeoLocation
- A latitude/longitude as a 2 dimensional point. It can be represented in various ways:
- GeoShape
Relation - Health
Status - IBDistribution
- IBLambda
- KnnEmbedding
Input - Knn embedding input. Either a string, an object or array of objects
- Level
- Lifecycle
Operation Mode - Method
- An HTTP method.
- Minimum
Should Match - The minimum number of terms that should match as integer, percentage or range
- Node
Role - Node
Stats Level - Normalization
- OpType
- Percentage
- Query
Vector Builder - RRFRetriever
Entry - Either a direct RetrieverContainer (backward compatible) or an RRFRetrieverComponent with weight.
- Rank
Container - Refresh
- Result
- Retriever
Container - Scalar
Value - A scalar value.
- Score
Normalizer - Script
Language - Script
Sort Type - Script
Source - Search
Type - Slices
- Slices configuration used to parallelize a process.
- Slices
Calculation - Sort
Combinations - Sort
Mode - Sort
Options - Sort
Order - Suggest
Mode - Thread
Type - Time
Unit - Transform
Container - Version
Type - Wait
ForActive Shard Options - Wait
ForActive Shards - Wait
ForEvents
Traits§
- Endpoint
- A call Elasticsearch understands, and the response it returns. Every generated request implements it, and anything else can: the client sends a user’s own endpoint the same way.
- Transport
- Carries requests to a cluster and brings back its responses: an HTTP
client, or a layer around one, such as
Authenticated.
Type Aliases§
- Aggregate
Name - The aggregation name as returned from the server. Depending whether typed_keys is specified this could come back
in the form of
name#typeinstead of simplyname - Category
Id - Cluster
Alias - Cluster
Info Targets - Common
Stats Flags - Data
Stream Name - Data
Stream Names - Date
Format - Date
Math - Distance
- Duration
Large - A date histogram interval. Similar to
Durationwith additional units:w(week),M(month),q(quarter) andy(year) - Expand
Wildcards - Field
- Path to field or array of paths. Some API’s support wildcards in the path to select multiple fields.
- Fields
- GeoHash
- GeoHex
Cell - A map hex cell (H3) reference
- GeoShape
- A GeoJson shape, that can also use Elasticsearch’s
envelopeextension. - GeoTile
- A map tile reference, represented as
{zoom}/{x}/{y} - GeoTile
Precision - Grok
Pattern - Host
- Http
Headers - Id
- Ids
- Index
Alias - Index
Name - Index
Pattern - Index
Patterns - Indices
- Inference
String Group - Ip
- Mapbox
Vector Tiles - Metadata
- Multi
Term Query Rewrite - Name
- Names
- Namespace
- NodeId
- NodeIds
- Node
Name - Node
Roles - Password
- Pipeline
Name - Project
Routing - Property
Name - Query
Vector - RawAggs
- A search’s aggregation results, as JSON by aggregation name: the default
for a search response’s
TAggregations. Name your own type there, such assearch::Response<Article, MyAggregations>, to read them typed. - Relation
Name - Routing
- Only to be used in query and path parameters, as the array form is actually a csv
- Scroll
Id - Scroll
Ids - Sequence
Number - Service
- Sort
- Sort
Results - Stream
Result - Suggestion
Name - The suggestion name as returned from the server. Depending whether typed_keys is specified this could come back
in the form of
name#typeinstead of simplyname - TaskId
- Time
OfDay - Time of day, expressed as HH:MM:SS
- Time
Zone - Transport
Address - Transport
Error - An error from a transport: the request couldn’t be sent, or no response came back.
- Unit
Float Millis - Time unit for fractional milliseconds
- Unit
Millis - Time unit for milliseconds
- Unit
Nanos - Time unit for nanoseconds
- Unit
Seconds - Time unit for seconds
- Username
- Uuid
- Version
Number - Version
String