{"record":{"id":"9006bbf9827d18f8","repo":"quickwit-oss/tantivy","slug":"could-not-find-field-in-accessors","errorCode":null,"errorMessage":"could not find field in accessors","messagePattern":"could not find field in accessors","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/aggregation/metric/top_hits.rs","lineNumber":617,"sourceCode":"        agg_data: &mut AggregationsSegmentCtx,\n    ) -> crate::Result<()> {\n        let top_n = &mut self.buckets[parent_bucket_id as usize];\n        let req_data = agg_data.get_top_hits_req_data(self.accessor_idx);\n        let req = &req_data.req;\n        let accessors = &req_data.accessors;\n        for &doc_id in docs {\n            // TODO: this is terrible, a new vec is allocated for every doc\n            // We can fetch blocks instead\n            // We don't need to store the order for every value\n            let sorts: Vec<DocValueAndOrder> = req\n                .sort\n                .iter()\n                .enumerate()\n                .map(|(idx, KeyOrder { order, .. })| {\n                    let order = *order;\n                    let value = accessors\n                        .get(idx)\n                        .expect(\"could not find field in accessors\")\n                        .0\n                        .values_for_doc(doc_id)\n                        .next();\n                    DocValueAndOrder { value, order }\n                })\n                .collect();\n\n            top_n.push(\n                sorts,\n                DocAddress {\n                    segment_ord: self.segment_ordinal,\n                    doc_id,\n                },\n            );\n        }\n        Ok(())\n    }\n","sourceCodeStart":599,"sourceCodeEnd":635,"githubUrl":"https://github.com/quickwit-oss/tantivy/blob/b5d8deb80c26924e6b007a5b1a7630f35ca64de4/src/aggregation/metric/top_hits.rs#L599-L635","documentation":"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).","triggerScenarios":"Thrown at src/aggregation/metric/top_hits.rs:617 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b5d8deb80c26924e6b007a5b1a7630f35ca64de4","analyzedAt":"2026-09-05T13:20:51.521Z","contentChangedAt":"2026-09-05T13:20:51.521Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}