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() {
|
for (_, node) in self.nodes.iter() {
|
||||||
match &node.data {
|
match &node.data {
|
||||||
QueryNodeData::Term(t) => {
|
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() {
|
for id in t.term_ids.clone() {
|
||||||
term_docids
|
term_docids
|
||||||
.entry(id)
|
.entry(id)
|
||||||
|
@ -59,7 +59,7 @@ impl RankingRuleGraphTrait for ExactnessGraph {
|
|||||||
}
|
}
|
||||||
ExactnessCondition::Any(dest_node) => {
|
ExactnessCondition::Any(dest_node) => {
|
||||||
let docids =
|
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())
|
(docids, dest_node.clone())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -22,10 +22,8 @@ pub fn compute_docids(
|
|||||||
(left_term, right_term, *cost)
|
(left_term, right_term, *cost)
|
||||||
}
|
}
|
||||||
ProximityCondition::Term { term } => {
|
ProximityCondition::Term { term } => {
|
||||||
let mut docids = compute_query_term_subset_docids(ctx, &term.term_subset)?;
|
|
||||||
docids &= universe;
|
|
||||||
return Ok(ComputedCondition {
|
return Ok(ComputedCondition {
|
||||||
docids,
|
docids: compute_query_term_subset_docids(ctx, Some(universe), &term.term_subset)?,
|
||||||
universe_len: universe.len(),
|
universe_len: universe.len(),
|
||||||
start_term_subset: None,
|
start_term_subset: None,
|
||||||
end_term_subset: term.clone(),
|
end_term_subset: term.clone(),
|
||||||
|
@ -27,8 +27,7 @@ impl RankingRuleGraphTrait for TypoGraph {
|
|||||||
) -> Result<ComputedCondition> {
|
) -> Result<ComputedCondition> {
|
||||||
let TypoCondition { term, .. } = condition;
|
let TypoCondition { term, .. } = condition;
|
||||||
// maybe compute_query_term_subset_docids should accept a universe as argument
|
// maybe compute_query_term_subset_docids should accept a universe as argument
|
||||||
let mut docids = compute_query_term_subset_docids(ctx, &term.term_subset)?;
|
let docids = compute_query_term_subset_docids(ctx, Some(universe), &term.term_subset)?;
|
||||||
docids &= universe;
|
|
||||||
|
|
||||||
Ok(ComputedCondition {
|
Ok(ComputedCondition {
|
||||||
docids,
|
docids,
|
||||||
|
@ -26,8 +26,7 @@ impl RankingRuleGraphTrait for WordsGraph {
|
|||||||
) -> Result<ComputedCondition> {
|
) -> Result<ComputedCondition> {
|
||||||
let WordsCondition { term, .. } = condition;
|
let WordsCondition { term, .. } = condition;
|
||||||
// maybe compute_query_term_subset_docids should accept a universe as argument
|
// maybe compute_query_term_subset_docids should accept a universe as argument
|
||||||
let mut docids = compute_query_term_subset_docids(ctx, &term.term_subset)?;
|
let docids = compute_query_term_subset_docids(ctx, Some(universe), &term.term_subset)?;
|
||||||
docids &= universe;
|
|
||||||
|
|
||||||
Ok(ComputedCondition {
|
Ok(ComputedCondition {
|
||||||
docids,
|
docids,
|
||||||
|
@ -31,6 +31,7 @@ impl<'ctx> SearchContext<'ctx> {
|
|||||||
}
|
}
|
||||||
pub fn compute_query_term_subset_docids(
|
pub fn compute_query_term_subset_docids(
|
||||||
ctx: &mut SearchContext<'_>,
|
ctx: &mut SearchContext<'_>,
|
||||||
|
universe: Option<&RoaringBitmap>,
|
||||||
term: &QueryTermSubset,
|
term: &QueryTermSubset,
|
||||||
) -> Result<RoaringBitmap> {
|
) -> Result<RoaringBitmap> {
|
||||||
let mut docids = RoaringBitmap::new();
|
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(
|
pub fn compute_query_term_subset_docids_within_field_id(
|
||||||
@ -147,10 +151,7 @@ pub fn compute_query_graph_docids(
|
|||||||
term_subset,
|
term_subset,
|
||||||
positions: _,
|
positions: _,
|
||||||
term_ids: _,
|
term_ids: _,
|
||||||
}) => {
|
}) => compute_query_term_subset_docids(ctx, Some(&predecessors_docids), term_subset)?,
|
||||||
let node_docids = compute_query_term_subset_docids(ctx, term_subset)?;
|
|
||||||
predecessors_docids & node_docids
|
|
||||||
}
|
|
||||||
QueryNodeData::Deleted => {
|
QueryNodeData::Deleted => {
|
||||||
panic!()
|
panic!()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user