Intergrate smart crop in Meilisearch

This commit is contained in:
ManyTheFish 2022-05-18 10:26:52 +02:00
parent 6d221058f1
commit 0250ea9157
5 changed files with 182 additions and 1063 deletions

25
Cargo.lock generated
View File

@ -1092,8 +1092,8 @@ dependencies = [
[[package]] [[package]]
name = "filter-parser" name = "filter-parser"
version = "0.26.4" version = "0.28.0"
source = "git+https://github.com/meilisearch/milli.git?tag=v0.26.5#1f6dc31e2f8ee02cdda255a856d15f253daf17ec" source = "git+https://github.com/meilisearch/milli.git?tag=v0.28.0#19dac01c5ca81543b751f66ad51fcff61608d969"
dependencies = [ dependencies = [
"nom", "nom",
"nom_locate", "nom_locate",
@ -1119,8 +1119,8 @@ dependencies = [
[[package]] [[package]]
name = "flatten-serde-json" name = "flatten-serde-json"
version = "0.26.4" version = "0.28.0"
source = "git+https://github.com/meilisearch/milli.git?tag=v0.26.5#1f6dc31e2f8ee02cdda255a856d15f253daf17ec" source = "git+https://github.com/meilisearch/milli.git?tag=v0.28.0#19dac01c5ca81543b751f66ad51fcff61608d969"
dependencies = [ dependencies = [
"serde_json", "serde_json",
] ]
@ -1622,8 +1622,8 @@ dependencies = [
[[package]] [[package]]
name = "json-depth-checker" name = "json-depth-checker"
version = "0.26.4" version = "0.28.0"
source = "git+https://github.com/meilisearch/milli.git?tag=v0.26.5#1f6dc31e2f8ee02cdda255a856d15f253daf17ec" source = "git+https://github.com/meilisearch/milli.git?tag=v0.28.0#19dac01c5ca81543b751f66ad51fcff61608d969"
dependencies = [ dependencies = [
"serde_json", "serde_json",
] ]
@ -2151,8 +2151,8 @@ dependencies = [
[[package]] [[package]]
name = "milli" name = "milli"
version = "0.26.4" version = "0.28.0"
source = "git+https://github.com/meilisearch/milli.git?tag=v0.26.5#1f6dc31e2f8ee02cdda255a856d15f253daf17ec" source = "git+https://github.com/meilisearch/milli.git?tag=v0.28.0#19dac01c5ca81543b751f66ad51fcff61608d969"
dependencies = [ dependencies = [
"bimap", "bimap",
"bincode", "bincode",
@ -2189,6 +2189,7 @@ dependencies = [
"smallvec", "smallvec",
"smartstring", "smartstring",
"tempfile", "tempfile",
"thiserror",
"time 0.3.9", "time 0.3.9",
"uuid", "uuid",
] ]
@ -3360,18 +3361,18 @@ checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.30" version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.30" version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
dependencies = [ dependencies = [
"proc-macro2 1.0.37", "proc-macro2 1.0.37",
"quote 1.0.17", "quote 1.0.17",

View File

@ -6,7 +6,7 @@ edition = "2021"
[dependencies] [dependencies]
enum-iterator = "0.7.0" enum-iterator = "0.7.0"
meilisearch-error = { path = "../meilisearch-error" } meilisearch-error = { path = "../meilisearch-error" }
milli = { git = "https://github.com/meilisearch/milli.git", tag = "v0.26.5" } milli = { git = "https://github.com/meilisearch/milli.git", tag = "v0.28.0" }
rand = "0.8.4" rand = "0.8.4"
serde = { version = "1.0.136", features = ["derive"] } serde = { version = "1.0.136", features = ["derive"] }
serde_json = { version = "1.0.79", features = ["preserve_order"] } serde_json = { version = "1.0.79", features = ["preserve_order"] }

View File

@ -16,7 +16,7 @@ async fn formatted_contain_wildcard() {
index.wait_task(1).await; index.wait_task(1).await;
let (response, code) = index let (response, code) = index
.search_post(json!({ "q": "pesti", "attributesToRetrieve": ["father", "mother"], "attributesToHighlight": ["father", "mother", "*"], "attributesToCrop": ["doggos"] })) .search_post(json!({ "q": "pesti", "attributesToRetrieve": ["father", "mother"], "attributesToHighlight": ["father", "mother", "*"], "attributesToCrop": ["doggos"], "matches": true }))
.await; .await;
assert_eq!(code, 200, "{}", response); assert_eq!(code, 200, "{}", response);
assert_eq!( assert_eq!(
@ -25,7 +25,8 @@ async fn formatted_contain_wildcard() {
"_formatted": { "_formatted": {
"id": "852", "id": "852",
"cattos": "<em>pesti</em>", "cattos": "<em>pesti</em>",
} },
"_matchesInfo": {"cattos": [{"start": 0, "length": 5}]},
}) })
); );
@ -43,7 +44,7 @@ async fn formatted_contain_wildcard() {
let (response, code) = index let (response, code) = index
.search_post( .search_post(
json!({ "q": "pesti", "attributesToRetrieve": ["*"], "attributesToHighlight": ["id"] }), json!({ "q": "pesti", "attributesToRetrieve": ["*"], "attributesToHighlight": ["id"], "matches": true }),
) )
.await; .await;
assert_eq!(code, 200, "{}", response); assert_eq!(code, 200, "{}", response);
@ -55,7 +56,8 @@ async fn formatted_contain_wildcard() {
"_formatted": { "_formatted": {
"id": "852", "id": "852",
"cattos": "pesti", "cattos": "pesti",
} },
"_matchesInfo": {"cattos": [{"start": 0, "length": 5}]},
}) })
); );
@ -141,6 +143,27 @@ async fn format_nested() {
}) })
); );
let (response, code) = index
.search_post(
json!({ "q": "bobby", "attributesToRetrieve": ["doggos.name"], "matches": true }),
)
.await;
assert_eq!(code, 200, "{}", response);
assert_eq!(
response["hits"][0],
json!({
"doggos": [
{
"name": "bobby",
},
{
"name": "buddy",
},
],
"_matchesInfo": {"doggos.name": [{"start": 0, "length": 5}]},
})
);
let (response, code) = index let (response, code) = index
.search_post(json!({ "q": "pesti", "attributesToRetrieve": [], "attributesToHighlight": ["doggos.name"] })) .search_post(json!({ "q": "pesti", "attributesToRetrieve": [], "attributesToHighlight": ["doggos.name"] }))
.await; .await;

View File

@ -30,7 +30,7 @@ lazy_static = "1.4.0"
log = "0.4.14" log = "0.4.14"
meilisearch-auth = { path = "../meilisearch-auth" } meilisearch-auth = { path = "../meilisearch-auth" }
meilisearch-error = { path = "../meilisearch-error" } meilisearch-error = { path = "../meilisearch-error" }
milli = { git = "https://github.com/meilisearch/milli.git", tag = "v0.26.5" } milli = { git = "https://github.com/meilisearch/milli.git", tag = "v0.28.0" }
mime = "0.3.16" mime = "0.3.16"
num_cpus = "1.13.1" num_cpus = "1.13.1"
obkv = "0.2.0" obkv = "0.2.0"

File diff suppressed because it is too large Load Diff