From d22fab5baec0fdc6029056e9c8af87acb1fddeae Mon Sep 17 00:00:00 2001 From: mpostma Date: Wed, 13 Jan 2021 18:18:52 +0100 Subject: [PATCH] implement open index --- Cargo.lock | 13 ++++++++++++- src/index_controller/mod.rs | 9 +++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4415db555..40528367e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1710,6 +1710,7 @@ dependencies = [ "bstr", "byte-unit", "byteorder", + "chrono", "crossbeam-channel", "csv", "either", @@ -1724,13 +1725,13 @@ dependencies = [ "levenshtein_automata", "linked-hash-map", "log", + "meilisearch-tokenizer", "memmap", "near-proximity", "num-traits", "obkv", "once_cell", "ordered-float", - "page_size", "pest 2.1.3 (git+https://github.com/pest-parser/pest.git?rev=51fd1d49f1041f7839975664ef71fe15c7dcaf67)", "pest_derive", "rayon", @@ -1739,6 +1740,7 @@ dependencies = [ "roaring", "serde", "serde_json", + "serde_millis", "slice-group-by", "smallstr", "smallvec", @@ -2605,6 +2607,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_millis" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e2dc780ca5ee2c369d1d01d100270203c4ff923d2a4264812d723766434d00" +dependencies = [ + "serde", +] + [[package]] name = "serde_qs" version = "0.8.2" diff --git a/src/index_controller/mod.rs b/src/index_controller/mod.rs index 9dfa23ce5..0c6a95c1f 100644 --- a/src/index_controller/mod.rs +++ b/src/index_controller/mod.rs @@ -67,8 +67,9 @@ struct IndexMetadata { } impl IndexMetadata { - fn open_index(&self) -> Result { - todo!() + fn open_index(&self, path: impl AsRef) -> Result { + let path = path.as_ref().to_path_buf().push("indexes").push(&self.id); + Ok(Index::new(self.options, path)?) } } @@ -79,7 +80,7 @@ struct IndexView<'a, U> { } struct IndexViewMut<'a, U> { - txn: heed::RwTxn<'a>, + txn: heed::RwTxn<'a, 'a>, index: &'a Index, update_store: &'a U, } @@ -97,7 +98,7 @@ impl<'a, U> Deref for IndexViewMut<'a, U> { } impl<'a, U: UpdateStore> IndexView<'a, U> { - fn search(&self, search_query: SearchQuery) -> Result { + pub fn search(&self, search_query: SearchQuery) -> Result { let mut search = self.index.search(self.txn); if let Some(query) = &search_query.q { search.query(query);