mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-08-18 12:08:22 +00:00
52a95b159b
`BooleanWeight::for_each_pruning` handed a union of term scorers straight to `block_wand`, whatever the weight's score combiner. Block-WAND prunes on the sum of the per-term block maxima and scores the survivors the same way, so it silently replaces the combiner with a sum. A `DisjunctionMaxQuery` collected through `TopDocs` therefore scored a document matching in two fields as the sum of both instead of the better of the two, and ignored the tie breaker. The union only reaches that path when every clause reads term frequencies, which is why the bug hid: a query asking for `Basic` postings falls back to `BufferedUnionScorer`, which does honor the combiner. `ScoreCombiner` now declares whether Block-WAND may drive it. Only `SumCombiner` opts in; everything else falls back to the plain union, which still prunes on the threshold but makes no assumption about how the scores combine. The intersection specialization needs no such fallback: `Intersection::score` sums its children whatever the combiner (the combiner only shapes how should clauses combine), so `block_wand_intersection`'s summing already matches the unpruned scorer for every combiner. A second test pins that equivalence by comparing `for_each_pruning` against a manual scorer walk on a must+must weight built with `DisjunctionMaxCombiner`.