From 21ae4143b177389dde584411107f6559a5fbe4aa Mon Sep 17 00:00:00 2001 From: ad hoc Date: Fri, 25 Mar 2022 16:27:48 +0100 Subject: [PATCH] add exact_word_prefix to Context --- milli/src/search/criteria/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/milli/src/search/criteria/mod.rs b/milli/src/search/criteria/mod.rs index df9189239..3daa258bf 100644 --- a/milli/src/search/criteria/mod.rs +++ b/milli/src/search/criteria/mod.rs @@ -70,6 +70,7 @@ pub trait Context<'c> { fn word_docids(&self, word: &str) -> heed::Result>; fn exact_word_docids(&self, word: &str) -> heed::Result>; fn word_prefix_docids(&self, word: &str) -> heed::Result>; + fn exact_word_prefix_docids(&self, word: &str) -> heed::Result>; fn word_pair_proximity_docids( &self, left: &str, @@ -127,6 +128,10 @@ impl<'c> Context<'c> for CriteriaBuilder<'c> { self.index.word_prefix_docids.get(self.rtxn, &word) } + fn exact_word_prefix_docids(&self, word: &str) -> heed::Result> { + self.index.exact_word_prefix_docids.get(self.rtxn, &word) + } + fn word_pair_proximity_docids( &self, left: &str, @@ -522,6 +527,7 @@ pub mod test { word_docids: HashMap, exact_word_docids: HashMap, word_prefix_docids: HashMap, + exact_word_prefix_docids: HashMap, word_pair_proximity_docids: HashMap<(String, String, i32), RoaringBitmap>, word_prefix_pair_proximity_docids: HashMap<(String, String, i32), RoaringBitmap>, docid_words: HashMap>, @@ -544,6 +550,10 @@ pub mod test { Ok(self.word_prefix_docids.get(&word.to_string()).cloned()) } + fn exact_word_prefix_docids(&self, word: &str) -> heed::Result> { + Ok(self.exact_word_prefix_docids.get(&word.to_string()).cloned()) + } + fn word_pair_proximity_docids( &self, left: &str, @@ -672,6 +682,8 @@ pub mod test { s("20") => &word_docids[&s("2020")] | &word_docids[&s("2021")], }; + let exact_word_prefix_docids = HashMap::new(); + let mut word_pair_proximity_docids = HashMap::new(); let mut word_prefix_pair_proximity_docids = HashMap::new(); for (lword, lcandidates) in &word_docids { @@ -729,6 +741,7 @@ pub mod test { word_docids, exact_word_docids, word_prefix_docids, + exact_word_prefix_docids, word_pair_proximity_docids, word_prefix_pair_proximity_docids, docid_words,