mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 14:54:27 +01:00
Remove unused term matching strategies
This commit is contained in:
parent
1d937f831b
commit
2d88089129
@ -36,6 +36,7 @@ mod distinct;
|
|||||||
pub mod facet;
|
pub mod facet;
|
||||||
mod fst_utils;
|
mod fst_utils;
|
||||||
mod matches;
|
mod matches;
|
||||||
|
pub mod new;
|
||||||
mod query_tree;
|
mod query_tree;
|
||||||
|
|
||||||
pub struct Search<'a> {
|
pub struct Search<'a> {
|
||||||
@ -344,14 +345,6 @@ pub enum CriterionImplementationStrategy {
|
|||||||
pub enum TermsMatchingStrategy {
|
pub enum TermsMatchingStrategy {
|
||||||
// remove last word first
|
// remove last word first
|
||||||
Last,
|
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 words are mandatory
|
||||||
All,
|
All,
|
||||||
}
|
}
|
||||||
|
@ -487,49 +487,12 @@ fn create_query_tree(
|
|||||||
for _ in 0..=remove_count {
|
for _ in 0..=remove_count {
|
||||||
let pos = match terms_matching_strategy {
|
let pos = match terms_matching_strategy {
|
||||||
TermsMatchingStrategy::All => return ngrams(ctx, authorize_typos, &query, false),
|
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
|
TermsMatchingStrategy::Last => query
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter(|(_, part)| !part.is_phrase())
|
.filter(|(_, part)| !part.is_phrase())
|
||||||
.last()
|
.last()
|
||||||
.map(|(pos, _)| pos),
|
.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
|
// compute and push the current branch on the front
|
||||||
|
Loading…
Reference in New Issue
Block a user