Skip to main content

Crate oxsearch

Crate oxsearch 

Source
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_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 Index reads, writes and searches it.
fusion
Several retrievers’ results fused into one list, on the server when its license includes the rrf and linear retrievers, else on the client.
helpers
Helpers for reading and loading a lot of documents: Scan streams every document a query matches over a point in time, and BulkLoader loads 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 IndexMap for objects used as maps.
spec_utils
telemetry
Telemetry through the tracing and metrics facades, following the OpenTelemetry semantic conventions for Elasticsearch: one client span per request and the db.client.operation.duration histogram. Install a subscriber and a recorder, such as oxtel’s, to export them; without them, nothing is recorded.

Structs§

AcknowledgedResponseBase
AggsBody
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.
BulkIndexByScrollFailure
BulkStats
CartesianPoint
ChunkRescorer
Client
Sends calls to a cluster over a Transport.
ClusterDetails
ClusterStatistics
CompletionStats
CoordsGeoBounds
DiversifyRetriever
DocStats
ElasticsearchError
An error response from Elasticsearch.
ElasticsearchVersionInfo
ElasticsearchVersionMinInfo
Reduced (minimal) info ElasticsearchVersion
Embedding
EmptyObject
For empty Class assignments
ErrorCause
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.
ErrorResponseBase
The response returned by Elasticsearch when request execution did not succeed.
FieldMemoryUsage
FieldSizeUsage
FieldSort
FielddataStats
FlushStats
GeoDistanceSort
GeoHashLocation
GeoLine
A GeoJson GeoLine.
GetStats
GlobalOrdinalFieldStats
GlobalOrdinalsStats
HttpRequest
The HTTP request a transport sends.
HttpResponse
The HTTP response a transport returns.
IndexingStats
IndicesOptions
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.
IndicesResponseBase
InferenceString
InlineGet
InnerRetriever
KnnQuery
KnnRetriever
KnnSearch
LatLonGeoLocation
LicenseError
A request Elasticsearch refused because the cluster’s license doesn’t include a feature it uses.
LinearRetriever
LookupQueryVectorBuilder
MergesStats
NestedSortValue
NodeAttributes
NodeShard
NodeStatistics
Contains statistics about the number of nodes selected by the request.
PinnedRetriever
PluginStats
Query
Builders for queries. Each returns a QueryContainer, except Query::bool, whose clauses you add.
QueryCacheStats
RRFRetriever
RRFRetrieverComponent
Wraps a retriever with an optional weight for RRF scoring.
RankBase
RecoveryStats
RefreshStats
ReindexStatus
ReindexTaskInfo
Information about a single parent reindex task, as returned by the reindex management APIs.
ReindexTaskResult
The final result of a completed reindex operation, as stored in the task result. This is the serialized form of BulkByScrollResponse.
RelocationFailureInfo
RequestBase
RequestCacheStats
RescoreVector
RescorerRetriever
Retries
Retriever
Builders for retrievers. Each returns a RetrieverContainer, and those that combine retrievers take queries too.
RetrieverBase
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
RuleRetriever
ScoreSort
Script
ScriptField
ScriptSort
ScriptTransform
SearchStats
SearchTransform
SegmentsStats
ShardFailure
ShardStatistics
ShardsOperationResponseBase
SlicedScroll
SpecifiedDocument
StandardRetriever
StoreStats
StoredScript
TaskFailure
TextEmbedding
TextSimilarityReranker
TokenPruningConfig
TopLeftBottomRightGeoBounds
TopRightBottomLeftGeoBounds
TranslogStats
WarmerStats
WktGeoBounds
WriteResponseBase

Enums§

Body
A request’s body.
ByteSize
Bytes
ClusterInfoTarget
ClusterSearchStatus
CommonStatsFlag
Conflicts
DFIIndependenceMeasure
DFRAfterEffect
DFRBasicModel
DateTime
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.
DistanceUnit
DiversifyRetrieverTypes
Duration
A duration. Units can be nanos, micros, ms (milliseconds), s (seconds), m (minutes), h (hours) and d (days). Also accepts “0” without a unit and “-1” to indicate an unspecified value.
Error
What can go wrong in a call.
ExpandWildcard
FieldSortNumericType
FieldValue
A field value.
Fuzziness
GeoBounds
A geo bounding box. It can be represented in various ways:
GeoDistanceSortLocation
GeoDistanceType
GeoHashPrecision
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:
GeoShapeRelation
HealthStatus
IBDistribution
IBLambda
KnnEmbeddingInput
Knn embedding input. Either a string, an object or array of objects
Level
LifecycleOperationMode
Method
An HTTP method.
MinimumShouldMatch
The minimum number of terms that should match as integer, percentage or range
NodeRole
NodeStatsLevel
Normalization
OpType
Percentage
QueryVectorBuilder
RRFRetrieverEntry
Either a direct RetrieverContainer (backward compatible) or an RRFRetrieverComponent with weight.
RankContainer
Refresh
Result
RetrieverContainer
ScalarValue
A scalar value.
ScoreNormalizer
ScriptLanguage
ScriptSortType
ScriptSource
SearchType
Slices
Slices configuration used to parallelize a process.
SlicesCalculation
SortCombinations
SortMode
SortOptions
SortOrder
SuggestMode
ThreadType
TimeUnit
TransformContainer
VersionType
WaitForActiveShardOptions
WaitForActiveShards
WaitForEvents

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§

AggregateName
The aggregation name as returned from the server. Depending whether typed_keys is specified this could come back in the form of name#type instead of simply name
CategoryId
ClusterAlias
ClusterInfoTargets
CommonStatsFlags
DataStreamName
DataStreamNames
DateFormat
DateMath
Distance
DurationLarge
A date histogram interval. Similar to Duration with additional units: w (week), M (month), q (quarter) and y (year)
ExpandWildcards
Field
Path to field or array of paths. Some API’s support wildcards in the path to select multiple fields.
Fields
GeoHash
GeoHexCell
A map hex cell (H3) reference
GeoShape
A GeoJson shape, that can also use Elasticsearch’s envelope extension.
GeoTile
A map tile reference, represented as {zoom}/{x}/{y}
GeoTilePrecision
GrokPattern
Host
HttpHeaders
Id
Ids
IndexAlias
IndexName
IndexPattern
IndexPatterns
Indices
InferenceStringGroup
Ip
MapboxVectorTiles
Metadata
MultiTermQueryRewrite
Name
Names
Namespace
NodeId
NodeIds
NodeName
NodeRoles
Password
PipelineName
ProjectRouting
PropertyName
QueryVector
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 as search::Response<Article, MyAggregations>, to read them typed.
RelationName
Routing
Only to be used in query and path parameters, as the array form is actually a csv
ScrollId
ScrollIds
SequenceNumber
Service
Sort
SortResults
StreamResult
SuggestionName
The suggestion name as returned from the server. Depending whether typed_keys is specified this could come back in the form of name#type instead of simply name
TaskId
TimeOfDay
Time of day, expressed as HH:MM:SS
TimeZone
TransportAddress
TransportError
An error from a transport: the request couldn’t be sent, or no response came back.
UnitFloatMillis
Time unit for fractional milliseconds
UnitMillis
Time unit for milliseconds
UnitNanos
Time unit for nanoseconds
UnitSeconds
Time unit for seconds
Username
Uuid
VersionNumber
VersionString