mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 20:15:07 +08:00
Remove unused term matching strategies
This commit is contained in:
parent
1d937f831b
commit
2d88089129
@ -36,6 +36,7 @@ mod distinct;
|
||||
pub mod facet;
|
||||
mod fst_utils;
|
||||
mod matches;
|
||||
pub mod new;
|
||||
mod query_tree;
|
||||
|
||||
pub struct Search<'a> {
|
||||
@ -344,14 +345,6 @@ pub enum CriterionImplementationStrategy {
|
||||
pub enum TermsMatchingStrategy {
|
||||
// remove last word first
|
||||
Last,
|
||||
// remove first word first
|
||||
First,
|
||||
// remove more frequent word first
|
||||
Frequency,
|
||||
// remove smallest word first
|
||||
Size,
|
||||
// only one of the word is mandatory
|
||||
Any,
|
||||
// all words are mandatory
|
||||
All,
|
||||
}
|
||||
|
@ -487,49 +487,12 @@ fn create_query_tree(
|
||||
for _ in 0..=remove_count {
|
||||
let pos = match terms_matching_strategy {
|
||||
TermsMatchingStrategy::All => return ngrams(ctx, authorize_typos, &query, false),
|
||||
TermsMatchingStrategy::Any => {
|
||||
let operation = Operation::Or(
|
||||
true,
|
||||
vec![
|
||||
// branch allowing matching documents to contains any query word.
|
||||
ngrams(ctx, authorize_typos, &query, true)?,
|
||||
// branch forcing matching documents to contains all the query words,
|
||||
// keeping this documents of the top of the resulted list.
|
||||
ngrams(ctx, authorize_typos, &query, false)?,
|
||||
],
|
||||
);
|
||||
|
||||
return Ok(operation);
|
||||
}
|
||||
TermsMatchingStrategy::Last => query
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, part)| !part.is_phrase())
|
||||
.last()
|
||||
.map(|(pos, _)| pos),
|
||||
TermsMatchingStrategy::First => {
|
||||
query.iter().enumerate().find(|(_, part)| !part.is_phrase()).map(|(pos, _)| pos)
|
||||
}
|
||||
TermsMatchingStrategy::Size => query
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, part)| !part.is_phrase())
|
||||
.min_by_key(|(_, part)| match part {
|
||||
PrimitiveQueryPart::Word(s, _) => s.len(),
|
||||
_ => unreachable!(),
|
||||
})
|
||||
.map(|(pos, _)| pos),
|
||||
TermsMatchingStrategy::Frequency => query
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, part)| !part.is_phrase())
|
||||
.max_by_key(|(_, part)| match part {
|
||||
PrimitiveQueryPart::Word(s, _) => {
|
||||
ctx.word_documents_count(s).unwrap_or_default().unwrap_or(u64::max_value())
|
||||
}
|
||||
_ => unreachable!(),
|
||||
})
|
||||
.map(|(pos, _)| pos),
|
||||
};
|
||||
|
||||
// compute and push the current branch on the front
|
||||
|
Loading…
Reference in New Issue
Block a user