diff --git a/benchmarks/Cargo.toml b/benchmarks/Cargo.toml index 570ed2a2a..78d08b77f 100644 --- a/benchmarks/Cargo.toml +++ b/benchmarks/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "benchmarks" -version = "0.33.1" +version = "0.33.2" edition = "2018" publish = false diff --git a/cli/Cargo.toml b/cli/Cargo.toml index fe3dc7c96..52cad5696 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cli" -version = "0.33.1" +version = "0.33.2" edition = "2018" description = "A CLI to interact with a milli index" publish = false diff --git a/filter-parser/Cargo.toml b/filter-parser/Cargo.toml index b8d159355..f44d72370 100644 --- a/filter-parser/Cargo.toml +++ b/filter-parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "filter-parser" -version = "0.33.1" +version = "0.33.2" edition = "2021" description = "The parser for the Meilisearch filter syntax" publish = false diff --git a/flatten-serde-json/Cargo.toml b/flatten-serde-json/Cargo.toml index e965efe5e..1d556a243 100644 --- a/flatten-serde-json/Cargo.toml +++ b/flatten-serde-json/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "flatten-serde-json" -version = "0.33.1" +version = "0.33.2" edition = "2021" description = "Flatten serde-json objects like elastic search" readme = "README.md" diff --git a/helpers/Cargo.toml b/helpers/Cargo.toml index 552ec863c..f5a89eaaa 100644 --- a/helpers/Cargo.toml +++ b/helpers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "helpers" -version = "0.33.1" +version = "0.33.2" authors = ["Clément Renault "] edition = "2018" description = "A small tool to do operations on the database" diff --git a/http-ui/Cargo.toml b/http-ui/Cargo.toml index 87044d540..2d9540e21 100644 --- a/http-ui/Cargo.toml +++ b/http-ui/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "http-ui" description = "The HTTP user interface of the milli search engine" -version = "0.33.1" +version = "0.33.2" authors = ["Clément Renault "] edition = "2018" publish = false diff --git a/infos/Cargo.toml b/infos/Cargo.toml index b161d7a63..60474c829 100644 --- a/infos/Cargo.toml +++ b/infos/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "infos" -version = "0.33.1" +version = "0.33.2" authors = ["Clément Renault "] edition = "2018" publish = false diff --git a/json-depth-checker/Cargo.toml b/json-depth-checker/Cargo.toml index 0d869062b..510eaf985 100644 --- a/json-depth-checker/Cargo.toml +++ b/json-depth-checker/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "json-depth-checker" -version = "0.33.1" +version = "0.33.2" edition = "2021" description = "A library that indicates if a JSON must be flattened" publish = false diff --git a/milli/Cargo.toml b/milli/Cargo.toml index 639734757..547c65dfb 100644 --- a/milli/Cargo.toml +++ b/milli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "milli" -version = "0.33.1" +version = "0.33.2" authors = ["Kerollmops "] edition = "2018" diff --git a/milli/src/search/query_tree.rs b/milli/src/search/query_tree.rs index 51774d8b4..1c60e41f7 100644 --- a/milli/src/search/query_tree.rs +++ b/milli/src/search/query_tree.rs @@ -1,5 +1,5 @@ use std::borrow::Cow; -use std::cmp::min; +use std::cmp::max; use std::{cmp, fmt, mem}; use charabia::classifier::ClassifiedTokenIter; @@ -450,14 +450,14 @@ fn create_query_tree( } let number_phrases = query.iter().filter(|p| p.is_phrase()).count(); - let remove_count = query.len() - min(number_phrases, 1); + let remove_count = query.len() - max(number_phrases, 1); if remove_count == 0 { return ngrams(ctx, authorize_typos, query, false); } let mut operation_children = Vec::new(); let mut query = query.to_vec(); - for _ in 0..remove_count { + for _ in 0..=remove_count { let pos = match terms_matching_strategy { TermsMatchingStrategy::All => return ngrams(ctx, authorize_typos, &query, false), TermsMatchingStrategy::Any => { @@ -1058,6 +1058,26 @@ mod test { "###); } + #[test] + fn phrase_2() { + // https://github.com/meilisearch/meilisearch/issues/2722 + let query = "coco \"harry\""; + let tokens = query.tokenize(); + + let (query_tree, _) = TestContext::default() + .build(TermsMatchingStrategy::default(), true, None, tokens) + .unwrap() + .unwrap(); + + insta::assert_debug_snapshot!(query_tree, @r###" + OR(WORD) + Exact { word: "harry" } + AND + Exact { word: "coco" } + Exact { word: "harry" } + "###); + } + #[test] fn phrase_with_hard_separator() { let query = "\"hey friends. wooop wooop\"";