mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Add "position" part of the attribute ranking rule
This commit is contained in:
parent
8edad8291b
commit
bd9aba4d77
11 changed files with 314 additions and 31 deletions
|
@ -87,6 +87,41 @@ pub fn compute_query_term_subset_docids_within_field_id(
|
|||
Ok(docids)
|
||||
}
|
||||
|
||||
pub fn compute_query_term_subset_docids_within_position(
|
||||
ctx: &mut SearchContext,
|
||||
term: &QueryTermSubset,
|
||||
position: u16,
|
||||
) -> Result<RoaringBitmap> {
|
||||
// TODO Use the roaring::MultiOps trait
|
||||
|
||||
let mut docids = RoaringBitmap::new();
|
||||
for word in term.all_single_words_except_prefix_db(ctx)? {
|
||||
if let Some(word_position_docids) =
|
||||
ctx.get_db_word_position_docids(word.interned(), position)?
|
||||
{
|
||||
docids |= word_position_docids;
|
||||
}
|
||||
}
|
||||
|
||||
for phrase in term.all_phrases(ctx)? {
|
||||
for &word in phrase.words(ctx).iter().flatten() {
|
||||
if let Some(word_position_docids) = ctx.get_db_word_position_docids(word, position)? {
|
||||
docids |= word_position_docids;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(word_prefix) = term.use_prefix_db(ctx) {
|
||||
if let Some(word_position_docids) =
|
||||
ctx.get_db_word_prefix_position_docids(word_prefix.interned(), position)?
|
||||
{
|
||||
docids |= word_position_docids;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(docids)
|
||||
}
|
||||
|
||||
pub fn compute_query_graph_docids(
|
||||
ctx: &mut SearchContext,
|
||||
q: &QueryGraph,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue