mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 21:04:27 +01:00
Use new term matching strategy logic in resolve_maximally_reduced_...
This commit is contained in:
parent
2a5997fb20
commit
2997d1f186
@ -16,7 +16,7 @@ mod sort;
|
|||||||
// TODO: documentation + comments
|
// TODO: documentation + comments
|
||||||
mod words;
|
mod words;
|
||||||
|
|
||||||
use std::collections::{BTreeSet, HashSet};
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use charabia::TokenizerBuilder;
|
use charabia::TokenizerBuilder;
|
||||||
use db_cache::DatabaseCache;
|
use db_cache::DatabaseCache;
|
||||||
@ -25,7 +25,7 @@ use heed::RoTxn;
|
|||||||
use interner::DedupInterner;
|
use interner::DedupInterner;
|
||||||
pub use logger::detailed::DetailedSearchLogger;
|
pub use logger::detailed::DetailedSearchLogger;
|
||||||
pub use logger::{DefaultSearchLogger, SearchLogger};
|
pub use logger::{DefaultSearchLogger, SearchLogger};
|
||||||
use query_graph::{QueryGraph, QueryNode, QueryNodeData};
|
use query_graph::{QueryGraph, QueryNode};
|
||||||
use query_term::{located_query_terms_from_string, Phrase, QueryTerm};
|
use query_term::{located_query_terms_from_string, Phrase, QueryTerm};
|
||||||
use ranking_rules::{bucket_sort, PlaceholderQuery, RankingRuleOutput, RankingRuleQueryTrait};
|
use ranking_rules::{bucket_sort, PlaceholderQuery, RankingRuleOutput, RankingRuleQueryTrait};
|
||||||
use resolve_query_graph::PhraseDocIdsCache;
|
use resolve_query_graph::PhraseDocIdsCache;
|
||||||
@ -75,33 +75,17 @@ fn resolve_maximally_reduced_query_graph(
|
|||||||
logger: &mut dyn SearchLogger<QueryGraph>,
|
logger: &mut dyn SearchLogger<QueryGraph>,
|
||||||
) -> Result<RoaringBitmap> {
|
) -> Result<RoaringBitmap> {
|
||||||
let mut graph = query_graph.clone();
|
let mut graph = query_graph.clone();
|
||||||
let mut positions_to_remove = match matching_strategy {
|
|
||||||
TermsMatchingStrategy::Last => {
|
let nodes_to_remove = match matching_strategy {
|
||||||
let mut all_positions = BTreeSet::new();
|
TermsMatchingStrategy::Last => query_graph
|
||||||
for (_, n) in query_graph.nodes.iter() {
|
.removal_order_for_terms_matching_strategy_last()
|
||||||
match &n.data {
|
.iter()
|
||||||
QueryNodeData::Term(term) => {
|
.flat_map(|x| x.iter())
|
||||||
all_positions.extend(term.positions.clone());
|
.collect(),
|
||||||
}
|
|
||||||
QueryNodeData::Deleted | QueryNodeData::Start | QueryNodeData::End => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
all_positions.into_iter().collect()
|
|
||||||
}
|
|
||||||
TermsMatchingStrategy::All => vec![],
|
TermsMatchingStrategy::All => vec![],
|
||||||
};
|
};
|
||||||
// don't remove the first term
|
graph.remove_nodes(&nodes_to_remove);
|
||||||
if !positions_to_remove.is_empty() {
|
|
||||||
positions_to_remove.remove(0);
|
|
||||||
}
|
|
||||||
loop {
|
|
||||||
if positions_to_remove.is_empty() {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
let position_to_remove = positions_to_remove.pop().unwrap();
|
|
||||||
let _ = graph.remove_words_starting_at_position(position_to_remove);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logger.query_for_universe(&graph);
|
logger.query_for_universe(&graph);
|
||||||
let docids = compute_query_graph_docids(ctx, &graph, universe)?;
|
let docids = compute_query_graph_docids(ctx, &graph, universe)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user