diff --git a/milli/src/index.rs b/milli/src/index.rs index f8efa324e..5c5fc9895 100644 --- a/milli/src/index.rs +++ b/milli/src/index.rs @@ -352,6 +352,17 @@ impl Index { } } + /* word documents count */ + + /// Returns the number of documents ids associated with the given word, + /// it is much faster than deserializing the bitmap and getting the length of it. + pub fn word_documents_count(&self, rtxn: &RoTxn, word: &str) -> anyhow::Result> { + self.word_docids + .remap_data_type::() + .get(rtxn, word) + .map_err(Into::into) + } + /* documents */ /// Returns a [`Vec`] of the requested documents. Returns an error if a document is missing.