(&self, query: &str)
| 1069 | } |
| 1070 | |
| 1071 | fn kg_fts_match_ids(&self, query: &str) -> PristineResult<Vec<(String, usize)>> { |
| 1072 | let fts_table = match self.txn.open_multimap_table(KG_FTS) { |
| 1073 | Ok(t) => t, |
| 1074 | Err(redb::TableError::TableDoesNotExist(_)) => return Ok(Vec::new()), |
| 1075 | Err(e) => return Err(PristineError::from(e)), |
| 1076 | }; |
| 1077 | |
| 1078 | let tokens = tokenize_for_fts(query); |
| 1079 | if tokens.is_empty() { |
| 1080 | return Ok(Vec::new()); |
| 1081 | } |
| 1082 | |
| 1083 | let mut hit_counts: std::collections::HashMap<String, usize> = |
| 1084 | std::collections::HashMap::new(); |
| 1085 | for token in &tokens { |
| 1086 | let iter = match fts_table.get(token.as_str()) { |
| 1087 | Ok(iter) => iter, |
| 1088 | Err(_) => continue, |
| 1089 | }; |
| 1090 | for result in iter { |
| 1091 | let node_id_guard = result?; |
| 1092 | let node_id = node_id_guard.value().to_string(); |
| 1093 | *hit_counts.entry(node_id).or_insert(0) += 1; |
| 1094 | } |
| 1095 | } |
| 1096 | |
| 1097 | Ok(hit_counts.into_iter().collect()) |
| 1098 | } |
| 1099 | |
| 1100 | fn count_kg_nodes(&self) -> PristineResult<usize> { |
| 1101 | let table = match self.txn.open_table(KG_NODES) { |
no test coverage detected