From e38c599bcfe0c052881b78bc141e9f54c75290ea Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 15 Apr 2024 15:52:09 +0200 Subject: search almost works --- base/src/database.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'base/src/database.rs') diff --git a/base/src/database.rs b/base/src/database.rs index 2fabf1c..3971c62 100644 --- a/base/src/database.rs +++ b/base/src/database.rs @@ -33,15 +33,16 @@ pub const T_NODE_IMPORT: TableDefinition<&str, Ser, Node)>>> = pub struct DataAcid { pub inner: redb::Database, - pub node_index: NodeFulltextIndex, + pub node_index: NodeIndex, } impl DataAcid { pub fn open(path: &Path) -> Result { - info!("database"); - create_dir_all(path)?; - let db = redb::Database::create(path.join("data"))?; - let ft_node = NodeFulltextIndex::new(path)?; + create_dir_all(path).context("creating database directory")?; + info!("opening kv store..."); + let db = redb::Database::create(path.join("data")).context("opening kv store")?; + info!("opening node index..."); + let ft_node = NodeIndex::new(path).context("in node index")?; let r = Self { inner: db, node_index: ft_node, @@ -71,7 +72,7 @@ impl Deref for DataAcid { } } -pub struct NodeFulltextIndex { +pub struct NodeIndex { pub schema: Schema, pub reader: IndexReader, pub writer: RwLock, @@ -82,7 +83,7 @@ pub struct NodeFulltextIndex { pub description: Field, pub f_index: Field, } -impl NodeFulltextIndex { +impl NodeIndex { fn new(path: &Path) -> anyhow::Result { let mut schema = Schema::builder(); let id = schema.add_text_field("id", TEXT | STORED | FAST); -- cgit v1.2.3-70-g09d2