quickwit-oss/tantivy · error
could not find field in accessors
Error message
could not find field in accessors
What it means
Fires in the top-hits collector's collect loop: for each sort key of the top_hits request it indexes the per-field accessor vector by the sort clause position. The accessors vec is built 1:1 with req.sort during preparation, so accessors.get(idx) should always be Some; the panic means fewer accessors than sort clauses exist, i.e. preparation and collection are out of sync (an internal invariant violation, e.g. a sort field failed to open an accessor).
Source
Thrown at src/aggregation/metric/top_hits.rs:617
agg_data: &mut AggregationsSegmentCtx,
) -> crate::Result<()> {
let top_n = &mut self.buckets[parent_bucket_id as usize];
let req_data = agg_data.get_top_hits_req_data(self.accessor_idx);
let req = &req_data.req;
let accessors = &req_data.accessors;
for &doc_id in docs {
// TODO: this is terrible, a new vec is allocated for every doc
// We can fetch blocks instead
// We don't need to store the order for every value
let sorts: Vec<DocValueAndOrder> = req
.sort
.iter()
.enumerate()
.map(|(idx, KeyOrder { order, .. })| {
let order = *order;
let value = accessors
.get(idx)
.expect("could not find field in accessors")
.0
.values_for_doc(doc_id)
.next();
DocValueAndOrder { value, order }
})
.collect();
top_n.push(
sorts,
DocAddress {
segment_ord: self.segment_ordinal,
doc_id,
},
);
}
Ok(())
}
View on GitHub (pinned to b5d8deb80c)
Solutions
- Verify TopHitsReqData preparation pushed one accessor per sort clause, including nested/dotted field names
- Log the requested sort field when accessor resolution fails during preparation instead of silently skipping
- Ensure the same AggregationsSegmentCtx used for preparation is passed to collect
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/aggregation/metric/top_hits.rs:617 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/9006bbf9827d18f8.
Report an issue: GitHub.