mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-09 22:48:54 +01:00
Modify the compute_query_term_subset_docids function to accept the universe
This commit is contained in:
parent
2099b4f0dd
commit
50a7393c55
@ -302,7 +302,7 @@ impl QueryGraph {
|
||||
for (_, node) in self.nodes.iter() {
|
||||
match &node.data {
|
||||
QueryNodeData::Term(t) => {
|
||||
let docids = compute_query_term_subset_docids(ctx, &t.term_subset)?;
|
||||
let docids = compute_query_term_subset_docids(ctx, None, &t.term_subset)?;
|
||||
for id in t.term_ids.clone() {
|
||||
term_docids
|
||||
.entry(id)
|
||||
|
@ -59,7 +59,7 @@ impl RankingRuleGraphTrait for ExactnessGraph {
|
||||
}
|
||||
ExactnessCondition::Any(dest_node) => {
|
||||
let docids =
|
||||
universe & compute_query_term_subset_docids(ctx, &dest_node.term_subset)?;
|
||||
compute_query_term_subset_docids(ctx, Some(universe), &dest_node.term_subset)?;
|
||||
(docids, dest_node.clone())
|
||||
}
|
||||
};
|
||||
|
@ -22,10 +22,8 @@ pub fn compute_docids(
|
||||
(left_term, right_term, *cost)
|
||||
}
|
||||
ProximityCondition::Term { term } => {
|
||||
let mut docids = compute_query_term_subset_docids(ctx, &term.term_subset)?;
|
||||
docids &= universe;
|
||||
return Ok(ComputedCondition {
|
||||
docids,
|
||||
docids: compute_query_term_subset_docids(ctx, Some(universe), &term.term_subset)?,
|
||||
universe_len: universe.len(),
|
||||
start_term_subset: None,
|
||||
end_term_subset: term.clone(),
|
||||
|
@ -27,8 +27,7 @@ impl RankingRuleGraphTrait for TypoGraph {
|
||||
) -> Result<ComputedCondition> {
|
||||
let TypoCondition { term, .. } = condition;
|
||||
// maybe compute_query_term_subset_docids should accept a universe as argument
|
||||
let mut docids = compute_query_term_subset_docids(ctx, &term.term_subset)?;
|
||||
docids &= universe;
|
||||
let docids = compute_query_term_subset_docids(ctx, Some(universe), &term.term_subset)?;
|
||||
|
||||
Ok(ComputedCondition {
|
||||
docids,
|
||||
|
@ -26,8 +26,7 @@ impl RankingRuleGraphTrait for WordsGraph {
|
||||
) -> Result<ComputedCondition> {
|
||||
let WordsCondition { term, .. } = condition;
|
||||
// maybe compute_query_term_subset_docids should accept a universe as argument
|
||||
let mut docids = compute_query_term_subset_docids(ctx, &term.term_subset)?;
|
||||
docids &= universe;
|
||||
let docids = compute_query_term_subset_docids(ctx, Some(universe), &term.term_subset)?;
|
||||
|
||||
Ok(ComputedCondition {
|
||||
docids,
|
||||
|
@ -31,6 +31,7 @@ impl<'ctx> SearchContext<'ctx> {
|
||||
}
|
||||
pub fn compute_query_term_subset_docids(
|
||||
ctx: &mut SearchContext<'_>,
|
||||
universe: Option<&RoaringBitmap>,
|
||||
term: &QueryTermSubset,
|
||||
) -> Result<RoaringBitmap> {
|
||||
let mut docids = RoaringBitmap::new();
|
||||
@ -49,7 +50,10 @@ pub fn compute_query_term_subset_docids(
|
||||
}
|
||||
}
|
||||
|
||||
Ok(docids)
|
||||
match universe {
|
||||
Some(universe) => Ok(docids & universe),
|
||||
None => Ok(docids),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn compute_query_term_subset_docids_within_field_id(
|
||||
@ -147,10 +151,7 @@ pub fn compute_query_graph_docids(
|
||||
term_subset,
|
||||
positions: _,
|
||||
term_ids: _,
|
||||
}) => {
|
||||
let node_docids = compute_query_term_subset_docids(ctx, term_subset)?;
|
||||
predecessors_docids & node_docids
|
||||
}
|
||||
}) => compute_query_term_subset_docids(ctx, Some(&predecessors_docids), term_subset)?,
|
||||
QueryNodeData::Deleted => {
|
||||
panic!()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user