feat: add search module and bulk indexing functionality
This commit is contained in:
@@ -1 +1,2 @@
|
||||
pub mod hello;
|
||||
pub mod hello;
|
||||
pub mod search;
|
3
src/handler/search.rs
Normal file
3
src/handler/search.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
pub fn index_new_document() {
|
||||
println!("index_new_document");
|
||||
}
|
@@ -79,6 +79,12 @@ impl SearchEngine {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bulk_index(&mut self, documents: Vec<(&str, &str)>) {
|
||||
for (url, content) in documents {
|
||||
self.index(url, content);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_urls(&self, keyword: &str) -> HashMap<String, i32> {
|
||||
let keyword = normalize_string(keyword);
|
||||
self.index.get(&keyword).cloned().unwrap_or(HashMap::new())
|
||||
|
Reference in New Issue
Block a user