implement open index

This commit is contained in:
mpostma 2021-01-13 18:18:52 +01:00
parent ddd7789713
commit d22fab5bae
No known key found for this signature in database
GPG key ID: CBC8A7C1D7A28C3A
2 changed files with 17 additions and 5 deletions

View file

@ -67,8 +67,9 @@ struct IndexMetadata {
}
impl IndexMetadata {
fn open_index(&self) -> Result<Self> {
todo!()
fn open_index(&self, path: impl AsRef<Path>) -> Result<Self> {
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<SearchResult> {
pub fn search(&self, search_query: SearchQuery) -> Result<SearchResult> {
let mut search = self.index.search(self.txn);
if let Some(query) = &search_query.q {
search.query(query);