pub struct MapKeySort<S = Root> { /* private fields */ }Expand description
A sort over a dynamic-key map field by an ordered fallback of keys —
“sort by it, else en, …”. Built with *Map::sort_key("it").or("en") and
used like any other sortable handle: SortBuilder::by(handle, dir), or
.asc() / .desc() for a bare Sort.
It renders a _script sort whose painless source walks the keys in order and
sorts by the value of the first one a document has — true fallback, so a
row with only en still orders by en (not lexicographic tiers). String
maps sort case-insensitively on the dynamic .keyword subfield; numeric/date
maps on the bare key (epoch millis for dates). Nesting-aware via scope S,
exactly like a field sort.
Documents with none of the keys sort first under .asc() / last under
.desc() by default; place them explicitly with .missing_first() /
.missing_last() / .missing(value) on the produced Sort (or via the
OrderBy passed to SortBuilder::by) — these redirect into the script’s
fallback value, so they work despite a _script sort ignoring missing.
use flusso_query::{Root, SortBuilder, SortOrder, TextMap};
// Italian, falling back to English — through the normal `by`.
let sorts = SortBuilder::new()
.by(TextMap::<Root>::at("name").sort_key("it").or("en"), SortOrder::Desc)
.build();
assert_eq!(sorts.len(), 1);Implementations§
Trait Implementations§
Source§impl<S: Clone> Clone for MapKeySort<S>
impl<S: Clone> Clone for MapKeySort<S>
Source§fn clone(&self) -> MapKeySort<S>
fn clone(&self) -> MapKeySort<S>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more