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

View file

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