mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-29 16:24:26 +01: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]
|
[dependencies]
|
||||||
env_logger = { version = "0.3", default-features = false }
|
env_logger = { version = "0.3", default-features = false }
|
||||||
raptor = { path = "../raptor" }
|
raptor = { path = "../raptor" }
|
||||||
|
elapsed = "0.1"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
serde_derive = "1.0"
|
serde_derive = "1.0"
|
||||||
elapsed = "0.1"
|
|
||||||
|
|
||||||
[dependencies.fst]
|
[dependencies.fst]
|
||||||
git = "https://github.com/Kerollmops/fst.git"
|
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);
|
let mut stream = RankedStream::new(&map, map.values(), automatons, 20);
|
||||||
while let Some(document_id) = stream.next() {
|
while let Some(document) = stream.next() {
|
||||||
print!("{:?} ", document_id);
|
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 = db.get(title_key.as_bytes()).unwrap().unwrap();
|
||||||
let title = unsafe { from_utf8_unchecked(&title) };
|
let title = unsafe { from_utf8_unchecked(&title) };
|
||||||
print!("{:?}", title);
|
print!("{:?}", title);
|
||||||
|
@ -21,8 +21,8 @@ fn match_query_index(a: &Match, b: &Match) -> bool {
|
|||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Document {
|
pub struct Document {
|
||||||
document_id: DocumentId,
|
pub document_id: DocumentId,
|
||||||
matches: Vec<Match>,
|
pub matches: Vec<Match>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Document {
|
impl Document {
|
||||||
@ -210,7 +210,7 @@ impl<'m, 'v> RankedStream<'m, 'v> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'m, 'v, 'a> fst::Streamer<'a> for 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> {
|
fn next(&'a mut self) -> Option<Self::Item> {
|
||||||
let mut matches = HashMap::new();
|
let mut matches = HashMap::new();
|
||||||
@ -260,7 +260,7 @@ impl<'m, 'v, 'a> fst::Streamer<'a> for RankedStream<'m, 'v> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
RankedStream::Pours { inner } => {
|
RankedStream::Pours { inner } => {
|
||||||
return inner.next().map(|d| d.document_id)
|
return inner.next()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user