diff --git a/milli/src/index.rs b/milli/src/index.rs index 584ffab56..945567cdb 100644 --- a/milli/src/index.rs +++ b/milli/src/index.rs @@ -477,6 +477,18 @@ impl Index { Ok(documents) } + /// Returns an iterator over all the documents in the index. + pub fn all_documents<'t>( + &self, + rtxn: &'t RoTxn, + ) -> anyhow::Result)>>> { + Ok(self + .documents + .iter(rtxn)? + // we cast the BEU32 to a DocumentId + .map(|document| document.map(|(id, obkv)| (id.get(), obkv)))) + } + pub fn facets_distribution<'a>(&'a self, rtxn: &'a RoTxn) -> FacetDistribution<'a> { FacetDistribution::new(rtxn, self) }