pub struct Sort { /* private fields */ }Expand description
A single sort key. Produced by .asc() / .desc() on a sortable handle, by
Sort::score / Sort::script, or by Geo::distance_sort; chain the
option setters (missing_first, mode, unmapped_type, …) onto it.
Implementations§
Source§impl Sort
impl Sort
Sourcepub fn script(
script_type: ScriptSortType,
source: impl Into<String>,
order: SortOrder,
) -> Self
pub fn script( script_type: ScriptSortType, source: impl Into<String>, order: SortOrder, ) -> Self
Sort by a computed script value. script_type is the emitted value type
(ScriptSortType::Number / ScriptSortType::String); source is
the painless expression.
Sourcepub fn missing_first(self) -> Self
pub fn missing_first(self) -> Self
Place documents missing this field first. On a map-key sort this resolves
to a direction-correct sentinel in params.missing (a _script sort
ignores the missing body field).
Sourcepub fn missing_last(self) -> Self
pub fn missing_last(self) -> Self
Place documents missing this field last. On a map-key sort this resolves
to a direction-correct sentinel in params.missing.
Sourcepub fn missing(self, value: impl Into<Value>) -> Self
pub fn missing(self, value: impl Into<Value>) -> Self
Substitute a literal value for documents missing this field. On a map-key
sort this becomes the params.missing fallback value.
Sourcepub fn unmapped_type(self, unmapped_type: impl Into<String>) -> Self
pub fn unmapped_type(self, unmapped_type: impl Into<String>) -> Self
Type to assume when the field is unmapped on some shard (instead of
failing the search), e.g. "long". A no-op on a map-key _script sort —
it’s a field-sort option with no meaning there.
Sourcepub fn numeric_type(self, numeric_type: NumericType) -> Self
pub fn numeric_type(self, numeric_type: NumericType) -> Self
Numeric type to sort as (NumericType), for cross-index type coercion.
A no-op on a map-key _script sort — a field-sort-only option.
Sourcepub fn format(self, format: impl Into<String>) -> Self
pub fn format(self, format: impl Into<String>) -> Self
Date format for a date field sort. A no-op on a map-key _script
sort — a field-sort-only option.
Sourcepub fn nested_filtered<S>(
self,
path: impl Into<String>,
filter: impl AsQuery<S>,
) -> Self
pub fn nested_filtered<S>( self, path: impl Into<String>, filter: impl AsQuery<S>, ) -> Self
Sort by a field inside a nested array scoped to path, considering
only elements matching filter. An escape hatch for the rare
filter-scoped nested sort; ordinary nested sorts come from a
Sortable handle, which derives the (possibly multi-level) nested
chain from the field’s scope automatically.