Skip to content

Commit a484bc8

Browse files
committed
Add the TopDocs::order_by method.
Uses: * a `TopOrderable` trait which can be derived for tuples * a `TopOrderableCollector` to collect for it. * a `TopNCompare` trait which can be used together with a `LazyTopNComputer` to lazily fetch columns during TopN. Note that this does not use the `CustomScorer` API because: 1. `TopNComputer` does not allow for lazily fetching additional fields for the comparison tuple, which is important when tiebreakers are only rarely actually coming into play in the comparison, and most values are being eliminated by earlier columns. 2. `CustomScoreTopCollector` does not allow segments to Top-N a different type than their final output type, which is essential for ordering by `String`s. 3. In order to include scores as one of the ordering columns, we need to be able to optionally enable scores. 4. The `CustomScoreTopCollector::merge_fruits` function needs to operate over a wrapper type in order to apply different ordering globally than per-segment.
1 parent c301e7b commit a484bc8

File tree

5 files changed

+1500
-338
lines changed

5 files changed

+1500
-338
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ itertools = "0.14.0"
5656
measure_time = "0.9.0"
5757
arc-swap = "1.5.0"
5858
bon = "3.3.1"
59+
paste = "1.0.11"
5960

6061
columnar = { version = "0.5", path = "./columnar", package = "tantivy-columnar" }
6162
sstable = { version = "0.5", path = "./sstable", package = "tantivy-sstable", optional = true }
@@ -82,7 +83,6 @@ pretty_assertions = "1.2.1"
8283
proptest = "1.0.0"
8384
test-log = "0.2.10"
8485
futures = "0.3.21"
85-
paste = "1.0.11"
8686
more-asserts = "0.3.1"
8787
rand_distr = "0.4.3"
8888
time = { version = "0.3.10", features = ["serde-well-known", "macros"] }

src/collector/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ pub use self::multi_collector::{FruitHandle, MultiCollector, MultiFruit};
9696

9797
mod top_collector;
9898

99+
mod top_orderable;
100+
pub use self::top_orderable::{Feature, FieldFeature, ScoreFeature};
101+
99102
mod top_score_collector;
100103
pub use self::top_collector::ComparableDoc;
101104
pub use self::top_score_collector::{TopDocs, TopNComputer};

0 commit comments

Comments
 (0)