diff options
author | metamuffin <metamuffin@disroot.org> | 2024-04-15 15:52:09 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-04-15 15:52:09 +0200 |
commit | e38c599bcfe0c052881b78bc141e9f54c75290ea (patch) | |
tree | dad96fda6de95c591bceb69c672d9b2cbde61757 /base | |
parent | c988e7db759966d9586471e8cfcfd0d91e855dc0 (diff) | |
download | jellything-e38c599bcfe0c052881b78bc141e9f54c75290ea.tar jellything-e38c599bcfe0c052881b78bc141e9f54c75290ea.tar.bz2 jellything-e38c599bcfe0c052881b78bc141e9f54c75290ea.tar.zst |
search almost works
Diffstat (limited to 'base')
-rw-r--r-- | base/src/database.rs | 15 |
1 files changed, 8 insertions, 7 deletions
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<Vec<(Vec<usize>, Node)>>> = pub struct DataAcid { pub inner: redb::Database, - pub node_index: NodeFulltextIndex, + pub node_index: NodeIndex, } impl DataAcid { pub fn open(path: &Path) -> Result<Self, anyhow::Error> { - 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<IndexWriter>, @@ -82,7 +83,7 @@ pub struct NodeFulltextIndex { pub description: Field, pub f_index: Field, } -impl NodeFulltextIndex { +impl NodeIndex { fn new(path: &Path) -> anyhow::Result<Self> { let mut schema = Schema::builder(); let id = schema.add_text_field("id", TEXT | STORED | FAST); |