mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-25 19:45:05 +08:00
feat: Make the Stream return a Document
This commit is contained in:
parent
6fa164dc56
commit
e8c24a0f07
@ -6,9 +6,9 @@ authors = ["Kerollmops <renault.cle@gmail.com>"]
|
||||
[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"
|
||||
|
@ -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);
|
||||
|
@ -21,8 +21,8 @@ fn match_query_index(a: &Match, b: &Match) -> bool {
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Document {
|
||||
document_id: DocumentId,
|
||||
matches: Vec<Match>,
|
||||
pub document_id: DocumentId,
|
||||
pub matches: Vec<Match>,
|
||||
}
|
||||
|
||||
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<Self::Item> {
|
||||
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()
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user