quickwit-oss/tantivy · error

could not read term dictionary

Error message

could not read term dictionary

What it means

Fires in get_document_field_data when materializing sort/hit values for a top_hits aggregation on a Bytes or Str dynamic column. The column stores values as term ordinals; ord_to_bytes(term_ord, ...) is expected to always resolve an ordinal that was just produced by term_ords(doc_id) for the same accessor. Returning None means the term dictionary lookup failed for a valid ordinal, indicating corruption or an inconsistent dictionary, so the panic guards against silently emitting a wrong value.

Source

Thrown at src/aggregation/metric/top_hits.rs:301

                            .values_for_doc(doc_id)
                            .map(FastFieldValue::U64)
                            .collect::<Vec<_>>(),
                        DynamicColumn::I64(accessor) => accessor
                            .values_for_doc(doc_id)
                            .map(FastFieldValue::I64)
                            .collect::<Vec<_>>(),
                        DynamicColumn::F64(accessor) => accessor
                            .values_for_doc(doc_id)
                            .map(FastFieldValue::F64)
                            .collect::<Vec<_>>(),
                        DynamicColumn::Bytes(accessor) => accessor
                            .term_ords(doc_id)
                            .map(|term_ord| {
                                let mut buffer = vec![];
                                assert!(
                                    accessor
                                        .ord_to_bytes(term_ord, &mut buffer)
                                        .expect("could not read term dictionary"),
                                    "term corresponding to term_ord does not exist"
                                );
                                FastFieldValue::Bytes(buffer)
                            })
                            .collect::<Vec<_>>(),
                        DynamicColumn::Str(accessor) => accessor
                            .term_ords(doc_id)
                            .map(|term_ord| {
                                let mut buffer = vec![];
                                assert!(
                                    accessor
                                        .ord_to_bytes(term_ord, &mut buffer)
                                        .expect("could not read term dictionary"),
                                    "term corresponding to term_ord does not exist"
                                );
                                FastFieldValue::Str(String::from_utf8(buffer).unwrap())
                            })
                            .collect::<Vec<_>>(),

View on GitHub (pinned to b5d8deb80c)

Solutions

  1. Check the index for corruption in the term dictionary of the sort field
  2. Re-index the segment if the dictionary files were damaged
  3. Verify the column accessor and term_ords output come from the same open column
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/aggregation/metric/top_hits.rs:301 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/802fa240a464c420. Report an issue: GitHub.