mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 04:17:10 +02:00
Merge #185
185: Provide an iterator over all the documents in a milli index r=Kerollmops a=irevoire Co-authored-by: tamo <tamo@meilisearch.com>
This commit is contained in:
commit
1207a058d0
1 changed files with 12 additions and 0 deletions
|
@ -477,6 +477,18 @@ impl Index {
|
||||||
Ok(documents)
|
Ok(documents)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns an iterator over all the documents in the index.
|
||||||
|
pub fn all_documents<'t>(
|
||||||
|
&self,
|
||||||
|
rtxn: &'t RoTxn,
|
||||||
|
) -> anyhow::Result<impl Iterator<Item = heed::Result<(DocumentId, obkv::KvReader<'t>)>>> {
|
||||||
|
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> {
|
pub fn facets_distribution<'a>(&'a self, rtxn: &'a RoTxn) -> FacetDistribution<'a> {
|
||||||
FacetDistribution::new(rtxn, self)
|
FacetDistribution::new(rtxn, self)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue