Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Merge #620
Browse files Browse the repository at this point in the history
620: Fix word criterion r=Kerollmops a=ManyTheFish

related to meilisearch/meilisearch#2722

- fix the word strategy bug
- update milli version to v0.33.2

Co-authored-by: ManyTheFish <many@meilisearch.com>
  • Loading branch information
bors[bot] and ManyTheFish authored Sep 1, 2022
2 parents 17d020e + bf750e4 commit f7c352a
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 12 deletions.
2 changes: 1 addition & 1 deletion benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "benchmarks"
version = "0.33.1"
version = "0.33.2"
edition = "2018"
publish = false

Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion filter-parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion flatten-serde-json/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion helpers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "helpers"
version = "0.33.1"
version = "0.33.2"
authors = ["Clément Renault <clement@meilisearch.com>"]
edition = "2018"
description = "A small tool to do operations on the database"
Expand Down
2 changes: 1 addition & 1 deletion http-ui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <clement@meilisearch.com>"]
edition = "2018"
publish = false
Expand Down
2 changes: 1 addition & 1 deletion infos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "infos"
version = "0.33.1"
version = "0.33.2"
authors = ["Clément Renault <clement@meilisearch.com>"]
edition = "2018"
publish = false
Expand Down
2 changes: 1 addition & 1 deletion json-depth-checker/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion milli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "milli"
version = "0.33.1"
version = "0.33.2"
authors = ["Kerollmops <clement@meilisearch.com>"]
edition = "2018"

Expand Down
26 changes: 23 additions & 3 deletions milli/src/search/query_tree.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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\"";
Expand Down

0 comments on commit f7c352a

Please sign in to comment.