Use Numerical Range Facets for counting, filtering, and sorting
mainNumerical range facets allow you to group documents into explicitly defined numeric buckets (e.g., Price ranges like 0..10, 10..20).
- Supported Types:
u8,u16,u32,u64,i8,i16,i32,i64,f32,f64. - Counting: You must define the ranges and labels at query time. Use
RangeTypeto specify how to count:CountWithinRange: Count values strictly within the specified range.CountAboveRange: Count values within the range and all ranges above.CountBelowRange: Count values within the range and all ranges below.
- Filtering: Use
FacetFilterwith a range (e.g.,21..65) to restrict results. - Sorting: Results can be sorted by the numerical field value.
use seekstorm::search::{QueryFacet, RangeType};
let query_facets = vec![QueryFacet::U8 {
field: "age".into(),
range_type: RangeType::CountWithinRange,
ranges: vec![
("0-20".into(), 0),
("20-40".into(), 20),
("40-60".into(), 40),
("60-80".into(), 60),
("80-100".into(), 80),
],
}];