Skip to main content

xz_knowledge_graph/
config.rs

1use serde::{Deserialize, Serialize};
2
3use crate::types::import::MergeStrategy;
4use crate::types::relation::WeightStrategy;
5
6/// Knowledge graph configuration.
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct KgConfig {
9    pub storage: StorageConfig,
10    pub merge_strategy: MergeStrategy,
11    pub weight_strategy: WeightStrategy,
12    pub max_bfs_depth: u32,
13    pub max_path_search: u32,
14    pub fts: FtsConfig,
15}
16
17/// Storage backend configuration.
18#[derive(Debug, Clone, Serialize, Deserialize)]
19pub struct StorageConfig {
20    pub backend: String,
21    pub path: String,
22    pub pool_size: u32,
23}
24
25impl Default for StorageConfig {
26    fn default() -> Self {
27        Self {
28            backend: "sqlite".into(),
29            path: "./data/knowledge_graph.db".into(),
30            pool_size: 5,
31        }
32    }
33}
34
35/// FTS configuration.
36#[derive(Debug, Clone, Serialize, Deserialize)]
37pub struct FtsConfig {
38    pub enabled: bool,
39    pub min_query_length: usize,
40}
41
42impl Default for FtsConfig {
43    fn default() -> Self {
44        Self {
45            enabled: true,
46            min_query_length: 2,
47        }
48    }
49}
50
51impl Default for KgConfig {
52    fn default() -> Self {
53        Self {
54            storage: StorageConfig::default(),
55            merge_strategy: MergeStrategy::Replace,
56            weight_strategy: WeightStrategy::InverseConfidence,
57            max_bfs_depth: 5,
58            max_path_search: 10,
59            fts: FtsConfig::default(),
60        }
61    }
62}