1
0
Forkuj 0
kopia lustrzana https://github.com/meilisearch/MeiliSearch zsynchronizowano 2025-07-03 11:57:07 +02:00

Better support space around the negative operator (-)

Ten commit jest zawarty w:
Clément Renault 2024-03-26 17:42:09 +01:00
rodzic e4a3e603b3
commit 1da9e0f246
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: F250A4C4E3AE5F5F

Wyświetl plik

@ -21,6 +21,7 @@ pub fn located_query_terms_from_tokens(
let mut located_terms = Vec::new();
let mut phrase: Option<PhraseBuilder> = None;
let mut encountered_whitespace = true;
let mut negative_next_token = false;
let mut negative_words = Vec::new();
@ -34,6 +35,7 @@ pub fn located_query_terms_from_tokens(
if token.lemma().is_empty() {
continue;
}
// early return if word limit is exceeded
if located_terms.len() >= parts_limit {
return Ok((located_terms, negative_words));
@ -131,12 +133,14 @@ pub fn located_query_terms_from_tokens(
(quote_count % 2 == 1).then_some(PhraseBuilder::empty())
};
if phrase.is_none() && token.lemma() == "-" {
negative_next_token = true;
}
negative_next_token =
phrase.is_none() && token.lemma() == "-" && encountered_whitespace;
}
_ => (),
}
encountered_whitespace =
token.lemma().chars().last().filter(|c| c.is_whitespace()).is_some();
}
// If a quote is never closed, we consider all of the end of the query as a phrase.