Compare commits

...

4 Commits

Author SHA1 Message Date
ManyTheFish
8dc5acf998 Try fix 2023-08-08 16:52:36 +02:00
ManyTheFish
fc2590fc9d Add a test 2023-08-08 16:43:08 +02:00
meili-bors[bot]
e338ceb97f Merge #3982
3982: Update version for the next release (v1.3.1) in Cargo.toml r=irevoire a=meili-bot

⚠️ This PR is automatically generated. Check the new version is the expected one and Cargo.lock has been updated before merging.

Co-authored-by: irevoire <irevoire@users.noreply.github.com>
2023-08-08 10:30:56 +00:00
irevoire
75c87d5391 Update version for the next release (v1.3.1) in Cargo.toml 2023-08-08 10:30:06 +00:00
4 changed files with 80 additions and 19 deletions

28
Cargo.lock generated
View File

@@ -469,7 +469,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
[[package]]
name = "benchmarks"
version = "1.3.0"
version = "1.3.1"
dependencies = [
"anyhow",
"bytes",
@@ -1199,7 +1199,7 @@ dependencies = [
[[package]]
name = "dump"
version = "1.3.0"
version = "1.3.1"
dependencies = [
"anyhow",
"big_s",
@@ -1413,7 +1413,7 @@ dependencies = [
[[package]]
name = "file-store"
version = "1.3.0"
version = "1.3.1"
dependencies = [
"faux",
"tempfile",
@@ -1435,7 +1435,7 @@ dependencies = [
[[package]]
name = "filter-parser"
version = "1.3.0"
version = "1.3.1"
dependencies = [
"insta",
"nom",
@@ -1454,7 +1454,7 @@ dependencies = [
[[package]]
name = "flatten-serde-json"
version = "1.3.0"
version = "1.3.1"
dependencies = [
"criterion",
"serde_json",
@@ -1572,7 +1572,7 @@ dependencies = [
[[package]]
name = "fuzzers"
version = "1.3.0"
version = "1.3.1"
dependencies = [
"arbitrary",
"clap",
@@ -1894,7 +1894,7 @@ dependencies = [
[[package]]
name = "index-scheduler"
version = "1.3.0"
version = "1.3.1"
dependencies = [
"anyhow",
"big_s",
@@ -2081,7 +2081,7 @@ dependencies = [
[[package]]
name = "json-depth-checker"
version = "1.3.0"
version = "1.3.1"
dependencies = [
"criterion",
"serde_json",
@@ -2493,7 +2493,7 @@ checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
[[package]]
name = "meili-snap"
version = "1.3.0"
version = "1.3.1"
dependencies = [
"insta",
"md5",
@@ -2502,7 +2502,7 @@ dependencies = [
[[package]]
name = "meilisearch"
version = "1.3.0"
version = "1.3.1"
dependencies = [
"actix-cors",
"actix-http",
@@ -2591,7 +2591,7 @@ dependencies = [
[[package]]
name = "meilisearch-auth"
version = "1.3.0"
version = "1.3.1"
dependencies = [
"base64 0.21.2",
"enum-iterator",
@@ -2610,7 +2610,7 @@ dependencies = [
[[package]]
name = "meilisearch-types"
version = "1.3.0"
version = "1.3.1"
dependencies = [
"actix-web",
"anyhow",
@@ -2664,7 +2664,7 @@ dependencies = [
[[package]]
name = "milli"
version = "1.3.0"
version = "1.3.1"
dependencies = [
"big_s",
"bimap",
@@ -2994,7 +2994,7 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
[[package]]
name = "permissive-json-pointer"
version = "1.3.0"
version = "1.3.1"
dependencies = [
"big_s",
"serde_json",

View File

@@ -18,7 +18,7 @@ members = [
]
[workspace.package]
version = "1.3.0"
version = "1.3.1"
authors = ["Quentin de Quelen <quentin@dequelen.me>", "Clément Renault <clement@meilisearch.com>"]
description = "Meilisearch HTTP server"
homepage = "https://meilisearch.com"

View File

@@ -1104,3 +1104,59 @@ async fn camelcased_words() {
})
.await;
}
#[actix_rt::test]
async fn simple_search_with_strange_synonyms() {
let server = Server::new().await;
let index = server.index("test");
index.update_settings(json!({ "synonyms": {"&": ["to"], "to": ["&"]} })).await;
let r = index.wait_task(0).await;
meili_snap::snapshot!(r["status"], @r###""succeeded""###);
let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await;
index.wait_task(1).await;
index
.search(json!({"q": "How to train"}), |response, code| {
meili_snap::snapshot!(code, @"200 OK");
meili_snap::snapshot!(meili_snap::json_string!(response["hits"]), @r###"
[
{
"title": "How to Train Your Dragon: The Hidden World",
"id": "166428"
}
]
"###);
})
.await;
index
.search(json!({"q": "How & train"}), |response, code| {
meili_snap::snapshot!(code, @"200 OK");
meili_snap::snapshot!(meili_snap::json_string!(response["hits"]), @r###"
[
{
"title": "How to Train Your Dragon: The Hidden World",
"id": "166428"
}
]
"###);
})
.await;
index
.search(json!({"q": "to"}), |response, code| {
meili_snap::snapshot!(code, @"200 OK");
meili_snap::snapshot!(meili_snap::json_string!(response["hits"]), @r###"
[
{
"title": "How to Train Your Dragon: The Hidden World",
"id": "166428"
}
]
"###);
})
.await;
}

View File

@@ -477,13 +477,18 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> {
for (word, synonyms) in synonyms {
// Normalize both the word and associated synonyms.
let normalized_word = normalize(&tokenizer, word);
let normalized_synonyms =
synonyms.iter().map(|synonym| normalize(&tokenizer, synonym));
let normalized_synonyms: Vec<_> = synonyms
.iter()
.map(|synonym| normalize(&tokenizer, synonym))
.filter(|synonym| !synonym.is_empty())
.collect();
// Store the normalized synonyms under the normalized word,
// merging the possible duplicate words.
let entry = new_synonyms.entry(normalized_word).or_insert_with(Vec::new);
entry.extend(normalized_synonyms);
if !normalized_word.is_empty() && !normalized_synonyms.is_empty() {
let entry = new_synonyms.entry(normalized_word).or_insert_with(Vec::new);
entry.extend(normalized_synonyms.into_iter());
}
}
// Make sure that we don't have duplicate synonyms.