mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-06-01 08:00:41 +00:00
## What Enable range queries and TopN sorting on `Bytes` fast fields, bringing them to parity with `Str` fields. ## Why `BytesColumn` uses the same dictionary encoding as `StrColumn` internally, but range queries and TopN sorting were explicitly disabled for `Bytes`. This prevented use cases like storing lexicographically sortable binary data (e.g., arbitrary-precision decimals) that need efficient range filtering. ## How 1. **Enable range queries for Bytes** - Changed `is_type_valid_for_fastfield_range_query()` to return `true` for `Type::Bytes` 2. **Add BytesColumn handling in scorer** - Added a branch in `FastFieldRangeWeight::scorer()` to handle bytes fields using dictionary ordinal lookup (mirrors the existing `StrColumn` logic) 3. **Add SortByBytes** - New sort key computer for TopN queries on bytes columns ## Tests - `test_bytes_field_ff_range_query` - Tests inclusive/exclusive bounds and unbounded ranges - `test_sort_by_bytes_asc` / `test_sort_by_bytes_desc` - Tests lexicographic ordering in both directions
27 lines
559 B
Rust
27 lines
559 B
Rust
use crate::schema::Type;
|
|
|
|
mod fast_field_range_doc_set;
|
|
mod range_query;
|
|
mod range_query_fastfield;
|
|
|
|
pub use common::bounds::BoundsRange;
|
|
|
|
pub use self::range_query::*;
|
|
pub use self::range_query_fastfield::*;
|
|
|
|
// TODO is this correct?
|
|
pub(crate) fn is_type_valid_for_fastfield_range_query(typ: Type) -> bool {
|
|
match typ {
|
|
Type::Str
|
|
| Type::U64
|
|
| Type::I64
|
|
| Type::F64
|
|
| Type::Bool
|
|
| Type::Date
|
|
| Type::Json
|
|
| Type::IpAddr
|
|
| Type::Bytes => true,
|
|
Type::Facet => false,
|
|
}
|
|
}
|