Use resolve_phrase function for exactness criteria as well

This commit is contained in:
Loïc Lecrenier 2022-09-15 13:34:52 +02:00 committed by Loïc Lecrenier
parent 18d578dfc4
commit 830a7c0c7a

View File

@ -7,7 +7,7 @@ use log::debug;
use roaring::RoaringBitmap; use roaring::RoaringBitmap;
use crate::search::criteria::{ use crate::search::criteria::{
resolve_query_tree, Context, Criterion, CriterionParameters, CriterionResult, resolve_phrase, resolve_query_tree, Context, Criterion, CriterionParameters, CriterionResult,
}; };
use crate::search::query_tree::{Operation, PrimitiveQueryPart}; use crate::search::query_tree::{Operation, PrimitiveQueryPart};
use crate::{absolute_from_relative_position, FieldId, Result}; use crate::{absolute_from_relative_position, FieldId, Result};
@ -226,20 +226,7 @@ fn resolve_state(
} }
// compute intersection on pair of words with a proximity of 0. // compute intersection on pair of words with a proximity of 0.
Phrase(phrase) => { Phrase(phrase) => {
// TODO: use resolve_phrase here candidates |= resolve_phrase(ctx, phrase)?;
let mut bitmaps = Vec::with_capacity(phrase.len().saturating_sub(1));
for words in phrase.windows(2) {
if let [left, right] = words {
match ctx.word_pair_proximity_docids(left, right, 0)? {
Some(docids) => bitmaps.push(docids),
None => {
bitmaps.clear();
break;
}
}
}
}
candidates |= intersection_of(bitmaps.iter().collect());
} }
} }
parts_candidates_array.push(candidates); parts_candidates_array.push(candidates);