diff --git a/raptor-search/Cargo.toml b/raptor-search/Cargo.toml index f0bac0962..85fb9c202 100644 --- a/raptor-search/Cargo.toml +++ b/raptor-search/Cargo.toml @@ -6,9 +6,9 @@ authors = ["Kerollmops "] [dependencies] env_logger = { version = "0.3", default-features = false } raptor = { path = "../raptor" } +elapsed = "0.1" serde = "1.0" serde_derive = "1.0" -elapsed = "0.1" [dependencies.fst] git = "https://github.com/Kerollmops/fst.git" diff --git a/raptor-search/src/main.rs b/raptor-search/src/main.rs index 03910ac92..7f2a431a9 100644 --- a/raptor-search/src/main.rs +++ b/raptor-search/src/main.rs @@ -20,10 +20,10 @@ fn search(map: &DocIndexMap, lev_builder: &LevBuilder, db: &DB, query: &str) { } let mut stream = RankedStream::new(&map, map.values(), automatons, 20); - while let Some(document_id) = stream.next() { - print!("{:?} ", document_id); + while let Some(document) = stream.next() { + print!("{:?} ", document.document_id); - let title_key = format!("{}-title", document_id); + let title_key = format!("{}-title", document.document_id); let title = db.get(title_key.as_bytes()).unwrap().unwrap(); let title = unsafe { from_utf8_unchecked(&title) }; print!("{:?}", title); diff --git a/raptor/src/rank.rs b/raptor/src/rank.rs index 5bca5ebe9..ccfc75a35 100644 --- a/raptor/src/rank.rs +++ b/raptor/src/rank.rs @@ -21,8 +21,8 @@ fn match_query_index(a: &Match, b: &Match) -> bool { #[derive(Debug, Clone)] pub struct Document { - document_id: DocumentId, - matches: Vec, + pub document_id: DocumentId, + pub matches: Vec, } impl Document { @@ -210,7 +210,7 @@ impl<'m, 'v> RankedStream<'m, 'v> { } impl<'m, 'v, 'a> fst::Streamer<'a> for RankedStream<'m, 'v> { - type Item = DocumentId; + type Item = Document; fn next(&'a mut self) -> Option { let mut matches = HashMap::new(); @@ -260,7 +260,7 @@ impl<'m, 'v, 'a> fst::Streamer<'a> for RankedStream<'m, 'v> { } }, RankedStream::Pours { inner } => { - return inner.next().map(|d| d.document_id) + return inner.next() }, }