quickwit-oss/tantivy · error

This implementation always produces a score.

Error message

This implementation always produces a score.

What it means

Fires in ScoreSegmentSortKeyComputer::convert_segment_sort_key, which converts a u64 sort key back to f64 for score-based sorting. Its counterpart segment_sort_key always returns Some(score encoded as u64), never None, so the Option unwrap is expected to be infallible; a None here means a sort key produced by a different computer (e.g. a field-based computer where missing values yield None) was fed to the score converter, breaking the pairing between key producer and converter.

Source

Thrown at src/collector/sort_key/sort_by_erased_type.rs:73

    fn convert_segment_sort_key(&self, sort_key: Option<u64>) -> OwnedValue {
        let val = self.inner.convert_segment_sort_key(sort_key);
        (self.converter)(val)
    }
}

struct ScoreSegmentSortKeyComputer {
    segment_computer: SortBySimilarityScore,
}

impl ErasedSegmentSortKeyComputer for ScoreSegmentSortKeyComputer {
    fn segment_sort_key(&mut self, doc: DocId, score: Score) -> Option<u64> {
        let score_value: f64 = self.segment_computer.segment_sort_key(doc, score).into();
        Some(score_value.to_u64())
    }

    fn convert_segment_sort_key(&self, sort_key: Option<u64>) -> OwnedValue {
        let score_value: u64 = sort_key.expect("This implementation always produces a score.");
        OwnedValue::F64(f64::from_u64(score_value))
    }
}

impl SortKeyComputer for SortByErasedType {
    type SortKey = OwnedValue;
    type Child = ErasedColumnSegmentSortKeyComputer;
    type Comparator = NaturalComparator;

    fn requires_scoring(&self) -> bool {
        matches!(self, Self::Score)
    }

    fn segment_sort_key_computer(
        &self,
        segment_reader: &crate::SegmentReader,
    ) -> crate::Result<Self::Child> {
        let inner: Box<dyn ErasedSegmentSortKeyComputer> = match self {

View on GitHub (pinned to b5d8deb80c)

Solutions

  1. Ensure the erased computer used to produce keys is the same ScoreSegmentSortKeyComputer used to convert them
  2. Check that segment/collector wiring keeps producer and converter paired per sort specification
  3. If None is a legitimate state, handle missing scores explicitly instead of panicking
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at src/collector/sort_key/sort_by_erased_type.rs:73 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of quickwit-oss/tantivy@b5d8deb80c (2026-09-05). Data as JSON: /api/errors/64cc291e0f7155ef. Report an issue: GitHub.