diff --git a/meilidb-data/src/cf_tree.rs b/meilidb-data/src/cf_tree.rs
index 791f0de81..c15bbbcbb 100644
--- a/meilidb-data/src/cf_tree.rs
+++ b/meilidb-data/src/cf_tree.rs
@@ -93,6 +93,13 @@ impl CfTree {
let mut iter = self.index.db.iterator_cf(cf, IteratorMode::End)?;
Ok(iter.next().map(|(key, _)| key))
}
+
+ pub fn prefix_iterator
(&self, prefix: P) -> RocksDbResult
+ where P: AsRef<[u8]>,
+ {
+ let cf = self.index.db.cf_handle(&self.index.name).unwrap();
+ self.index.db.prefix_iterator_cf(cf, prefix)
+ }
}
pub struct CfIter<'a> {
diff --git a/meilidb-data/src/database/index/common_index.rs b/meilidb-data/src/database/index/common_index.rs
new file mode 100644
index 000000000..d102bb3bb
--- /dev/null
+++ b/meilidb-data/src/database/index/common_index.rs
@@ -0,0 +1,68 @@
+use serde::de::DeserializeOwned;
+use serde::Serialize;
+use super::Error;
+use std::marker::PhantomData;
+
+#[derive(Clone)]
+pub struct CommonIndex(pub crate::CfTree);
+
+impl CommonIndex {
+ pub fn get(&self, key: K) -> Result