mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 06:44:27 +01:00
Use an union instead of a sort for prefix fetching
This commit is contained in:
parent
70a529d197
commit
d7a7560220
@ -397,25 +397,24 @@ pub fn traverse_query_tree<'o, 'txn>(
|
|||||||
array
|
array
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut docids = Vec::new();
|
let mut results: Vec<&Set<_>> = Vec::new();
|
||||||
|
|
||||||
// We retrieve the cached postings lists for all
|
// We retrieve the cached postings lists for all
|
||||||
// the words that starts with this short prefix.
|
// the words that starts with this short prefix.
|
||||||
let result = ctx.prefix_postings_lists.prefix_postings_list(reader, prefix)?.unwrap_or_default();
|
let result = ctx.prefix_postings_lists.prefix_postings_list(reader, prefix)?.unwrap_or_default();
|
||||||
let key = PostingsKey { query, input: word.clone().into_bytes(), distance: 0, is_exact: false };
|
let key = PostingsKey { query, input: word.clone().into_bytes(), distance: 0, is_exact: false };
|
||||||
postings.insert(key, result.matches);
|
postings.insert(key, result.matches);
|
||||||
docids.extend_from_slice(&result.docids);
|
results.push(&result.docids);
|
||||||
|
|
||||||
// We retrieve the exact postings list for the prefix,
|
// We retrieve the exact postings list for the prefix,
|
||||||
// because we must consider these matches as exact.
|
// because we must consider these matches as exact.
|
||||||
if let Some(result) = ctx.postings_lists.postings_list(reader, word.as_bytes())? {
|
let result = ctx.postings_lists.postings_list(reader, word.as_bytes())?.unwrap_or_default();
|
||||||
let key = PostingsKey { query, input: word.clone().into_bytes(), distance: 0, is_exact: true };
|
let key = PostingsKey { query, input: word.clone().into_bytes(), distance: 0, is_exact: true };
|
||||||
postings.insert(key, result.matches);
|
postings.insert(key, result.matches);
|
||||||
docids.extend_from_slice(&result.docids);
|
results.push(&result.docids);
|
||||||
}
|
|
||||||
|
|
||||||
let before = Instant::now();
|
let before = Instant::now();
|
||||||
let docids = SetBuf::from_dirty(docids);
|
let docids = sdset::multi::Union::new(results).into_set_buf();
|
||||||
println!("{:2$}prefix docids construction took {:.02?}", "", before.elapsed(), depth * 2);
|
println!("{:2$}prefix docids construction took {:.02?}", "", before.elapsed(), depth * 2);
|
||||||
|
|
||||||
Cow::Owned(docids)
|
Cow::Owned(docids)
|
||||||
|
Loading…
Reference in New Issue
Block a user