mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-10-11 14:16:31 +00:00
Fix tests
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
use insta::{allow_duplicates, assert_json_snapshot};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -18,16 +19,27 @@ async fn formatted_contain_wildcard() {
|
|||||||
|response, code|
|
|response, code|
|
||||||
{
|
{
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"_formatted": {
|
"_formatted": {
|
||||||
"id": "852",
|
"id": "852",
|
||||||
"cattos": "<em>pésti</em>",
|
"cattos": "<em>pésti</em>"
|
||||||
},
|
},
|
||||||
"_matchesPosition": {"cattos": [{"start": 0, "length": 5}]},
|
"_matchesPosition": {
|
||||||
})
|
"cattos": [
|
||||||
);
|
{
|
||||||
|
"start": 0,
|
||||||
|
"length": 5
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"_rankingScore": "[score]"
|
||||||
|
}
|
||||||
|
"###);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@@ -35,13 +47,17 @@ async fn formatted_contain_wildcard() {
|
|||||||
index
|
index
|
||||||
.search(json!({ "q": "pésti", "attributesToRetrieve": ["*"] }), |response, code| {
|
.search(json!({ "q": "pésti", "attributesToRetrieve": ["*"] }), |response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"id": 852,
|
"id": 852,
|
||||||
"cattos": "pésti",
|
"cattos": "pésti",
|
||||||
})
|
"_rankingScore": "[score]"
|
||||||
);
|
}
|
||||||
|
"###)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@@ -50,20 +66,30 @@ async fn formatted_contain_wildcard() {
|
|||||||
json!({ "q": "pésti", "attributesToRetrieve": ["*"], "attributesToHighlight": ["id"], "showMatchesPosition": true }),
|
json!({ "q": "pésti", "attributesToRetrieve": ["*"], "attributesToHighlight": ["id"], "showMatchesPosition": true }),
|
||||||
|response, code| {
|
|response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"id": 852,
|
"id": 852,
|
||||||
"cattos": "pésti",
|
"cattos": "pésti",
|
||||||
"_formatted": {
|
"_formatted": {
|
||||||
"id": "852",
|
"id": "852",
|
||||||
"cattos": "pésti",
|
"cattos": "pésti"
|
||||||
},
|
},
|
||||||
"_matchesPosition": {"cattos": [{"start": 0, "length": 5}]},
|
"_matchesPosition": {
|
||||||
})
|
"cattos": [
|
||||||
);
|
{
|
||||||
|
"start": 0,
|
||||||
|
"length": 5
|
||||||
}
|
}
|
||||||
)
|
]
|
||||||
|
},
|
||||||
|
"_rankingScore": "[score]"
|
||||||
|
}
|
||||||
|
"###)
|
||||||
|
}
|
||||||
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
index
|
index
|
||||||
@@ -71,17 +97,21 @@ async fn formatted_contain_wildcard() {
|
|||||||
json!({ "q": "pésti", "attributesToRetrieve": ["*"], "attributesToCrop": ["*"] }),
|
json!({ "q": "pésti", "attributesToRetrieve": ["*"], "attributesToCrop": ["*"] }),
|
||||||
|response, code| {
|
|response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"id": 852,
|
"id": 852,
|
||||||
"cattos": "pésti",
|
"cattos": "pésti",
|
||||||
"_formatted": {
|
"_formatted": {
|
||||||
"id": "852",
|
"id": "852",
|
||||||
"cattos": "pésti",
|
"cattos": "pésti"
|
||||||
|
},
|
||||||
|
"_rankingScore": "[score]"
|
||||||
|
}
|
||||||
|
"###);
|
||||||
}
|
}
|
||||||
})
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@@ -89,17 +119,21 @@ async fn formatted_contain_wildcard() {
|
|||||||
index
|
index
|
||||||
.search(json!({ "q": "pésti", "attributesToCrop": ["*"] }), |response, code| {
|
.search(json!({ "q": "pésti", "attributesToCrop": ["*"] }), |response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"id": 852,
|
"id": 852,
|
||||||
"cattos": "pésti",
|
"cattos": "pésti",
|
||||||
"_formatted": {
|
"_formatted": {
|
||||||
"id": "852",
|
"id": "852",
|
||||||
"cattos": "pésti",
|
"cattos": "pésti"
|
||||||
|
},
|
||||||
|
"_rankingScore": "[score]"
|
||||||
|
}
|
||||||
|
"###)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@@ -116,21 +150,25 @@ async fn format_nested() {
|
|||||||
index
|
index
|
||||||
.search(json!({ "q": "pésti", "attributesToRetrieve": ["doggos"] }), |response, code| {
|
.search(json!({ "q": "pésti", "attributesToRetrieve": ["doggos"] }), |response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"doggos": [
|
"doggos": [
|
||||||
{
|
{
|
||||||
"name": "bobby",
|
"name": "bobby",
|
||||||
"age": 2,
|
"age": 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "buddy",
|
"name": "buddy",
|
||||||
"age": 4,
|
"age": 4
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
})
|
"_rankingScore": "[score]"
|
||||||
);
|
}
|
||||||
|
"###)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@@ -139,19 +177,23 @@ async fn format_nested() {
|
|||||||
json!({ "q": "pésti", "attributesToRetrieve": ["doggos.name"] }),
|
json!({ "q": "pésti", "attributesToRetrieve": ["doggos.name"] }),
|
||||||
|response, code| {
|
|response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"doggos": [
|
"doggos": [
|
||||||
{
|
{
|
||||||
"name": "bobby",
|
"name": "bobby"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "buddy",
|
"name": "buddy"
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
})
|
"_rankingScore": "[score]"
|
||||||
);
|
}
|
||||||
|
"###)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@@ -161,20 +203,31 @@ async fn format_nested() {
|
|||||||
json!({ "q": "bobby", "attributesToRetrieve": ["doggos.name"], "showMatchesPosition": true }),
|
json!({ "q": "bobby", "attributesToRetrieve": ["doggos.name"], "showMatchesPosition": true }),
|
||||||
|response, code| {
|
|response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"doggos": [
|
"doggos": [
|
||||||
{
|
{
|
||||||
"name": "bobby",
|
"name": "bobby"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "buddy",
|
"name": "buddy"
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
"_matchesPosition": {"doggos.name": [{"start": 0, "length": 5}]},
|
"_matchesPosition": {
|
||||||
})
|
"doggos.name": [
|
||||||
);
|
{
|
||||||
|
"start": 0,
|
||||||
|
"length": 5
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"_rankingScore": "[score]"
|
||||||
|
}
|
||||||
|
"###)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@@ -183,21 +236,25 @@ async fn format_nested() {
|
|||||||
.search(json!({ "q": "pésti", "attributesToRetrieve": [], "attributesToHighlight": ["doggos.name"] }),
|
.search(json!({ "q": "pésti", "attributesToRetrieve": [], "attributesToHighlight": ["doggos.name"] }),
|
||||||
|response, code| {
|
|response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"_formatted": {
|
"_formatted": {
|
||||||
"doggos": [
|
"doggos": [
|
||||||
{
|
{
|
||||||
"name": "bobby",
|
"name": "bobby"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "buddy",
|
"name": "buddy"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
],
|
"_rankingScore": "[score]"
|
||||||
},
|
}
|
||||||
})
|
"###)
|
||||||
);
|
}
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@@ -205,21 +262,25 @@ async fn format_nested() {
|
|||||||
.search(json!({ "q": "pésti", "attributesToRetrieve": [], "attributesToCrop": ["doggos.name"] }),
|
.search(json!({ "q": "pésti", "attributesToRetrieve": [], "attributesToCrop": ["doggos.name"] }),
|
||||||
|response, code| {
|
|response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"_formatted": {
|
"_formatted": {
|
||||||
"doggos": [
|
"doggos": [
|
||||||
{
|
{
|
||||||
"name": "bobby",
|
"name": "bobby"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "buddy",
|
"name": "buddy"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
],
|
"_rankingScore": "[score]"
|
||||||
},
|
}
|
||||||
})
|
"###)
|
||||||
);
|
}
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@@ -227,31 +288,35 @@ async fn format_nested() {
|
|||||||
.search(json!({ "q": "pésti", "attributesToRetrieve": ["doggos.name"], "attributesToHighlight": ["doggos.age"] }),
|
.search(json!({ "q": "pésti", "attributesToRetrieve": ["doggos.name"], "attributesToHighlight": ["doggos.age"] }),
|
||||||
|response, code| {
|
|response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"doggos": [
|
"doggos": [
|
||||||
{
|
{
|
||||||
"name": "bobby",
|
"name": "bobby"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "buddy",
|
"name": "buddy"
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
"_formatted": {
|
"_formatted": {
|
||||||
"doggos": [
|
"doggos": [
|
||||||
{
|
{
|
||||||
"name": "bobby",
|
"name": "bobby",
|
||||||
"age": "2",
|
"age": "2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "buddy",
|
"name": "buddy",
|
||||||
"age": "4",
|
"age": "4"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
],
|
"_rankingScore": "[score]"
|
||||||
},
|
}
|
||||||
})
|
"###)
|
||||||
);
|
}
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@@ -259,23 +324,27 @@ async fn format_nested() {
|
|||||||
.search(json!({ "q": "pésti", "attributesToRetrieve": [], "attributesToHighlight": ["doggos.age"], "attributesToCrop": ["doggos.name"] }),
|
.search(json!({ "q": "pésti", "attributesToRetrieve": [], "attributesToHighlight": ["doggos.age"], "attributesToCrop": ["doggos.name"] }),
|
||||||
|response, code| {
|
|response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"_formatted": {
|
"_formatted": {
|
||||||
"doggos": [
|
"doggos": [
|
||||||
{
|
{
|
||||||
"name": "bobby",
|
"name": "bobby",
|
||||||
"age": "2",
|
"age": "2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "buddy",
|
"name": "buddy",
|
||||||
"age": "4",
|
"age": "4"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
],
|
"_rankingScore": "[score]"
|
||||||
},
|
}
|
||||||
})
|
"###)
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@@ -297,54 +366,70 @@ async fn displayedattr_2_smol() {
|
|||||||
.search(json!({ "attributesToRetrieve": ["father", "id"], "attributesToHighlight": ["mother"], "attributesToCrop": ["cattos"] }),
|
.search(json!({ "attributesToRetrieve": ["father", "id"], "attributesToHighlight": ["mother"], "attributesToCrop": ["cattos"] }),
|
||||||
|response, code| {
|
|response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"id": 852,
|
"id": 852,
|
||||||
})
|
"_rankingScore": "[score]"
|
||||||
);
|
}
|
||||||
|
"###)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
index
|
index
|
||||||
.search(json!({ "attributesToRetrieve": ["id"] }), |response, code| {
|
.search(json!({ "attributesToRetrieve": ["id"] }), |response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"id": 852,
|
"id": 852,
|
||||||
})
|
"_rankingScore": "[score]"
|
||||||
);
|
}
|
||||||
|
"###)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
index
|
index
|
||||||
.search(json!({ "attributesToHighlight": ["id"] }), |response, code| {
|
.search(json!({ "attributesToHighlight": ["id"] }), |response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"id": 852,
|
"id": 852,
|
||||||
"_formatted": {
|
"_formatted": {
|
||||||
"id": "852",
|
"id": "852"
|
||||||
|
},
|
||||||
|
"_rankingScore": "[score]"
|
||||||
|
}
|
||||||
|
"###)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
index
|
index
|
||||||
.search(json!({ "attributesToCrop": ["id"] }), |response, code| {
|
.search(json!({ "attributesToCrop": ["id"] }), |response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"id": 852,
|
"id": 852,
|
||||||
"_formatted": {
|
"_formatted": {
|
||||||
"id": "852",
|
"id": "852"
|
||||||
|
},
|
||||||
|
"_rankingScore": "[score]"
|
||||||
|
}
|
||||||
|
"###)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@@ -353,15 +438,19 @@ async fn displayedattr_2_smol() {
|
|||||||
json!({ "attributesToHighlight": ["id"], "attributesToCrop": ["id"] }),
|
json!({ "attributesToHighlight": ["id"], "attributesToCrop": ["id"] }),
|
||||||
|response, code| {
|
|response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"id": 852,
|
"id": 852,
|
||||||
"_formatted": {
|
"_formatted": {
|
||||||
"id": "852",
|
"id": "852"
|
||||||
|
},
|
||||||
|
"_rankingScore": "[score]"
|
||||||
|
}
|
||||||
|
"###)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@@ -369,31 +458,47 @@ async fn displayedattr_2_smol() {
|
|||||||
index
|
index
|
||||||
.search(json!({ "attributesToHighlight": ["cattos"] }), |response, code| {
|
.search(json!({ "attributesToHighlight": ["cattos"] }), |response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"id": 852,
|
"id": 852,
|
||||||
})
|
"_rankingScore": "[score]"
|
||||||
);
|
}
|
||||||
|
"###)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
index
|
index
|
||||||
.search(json!({ "attributesToCrop": ["cattos"] }), |response, code| {
|
.search(json!({ "attributesToCrop": ["cattos"] }), |response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"id": 852,
|
"id": 852,
|
||||||
})
|
"_rankingScore": "[score]"
|
||||||
);
|
}
|
||||||
|
"###)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
index
|
index
|
||||||
.search(json!({ "attributesToRetrieve": ["cattos"] }), |response, code| {
|
.search(json!({ "attributesToRetrieve": ["cattos"] }), |response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(response["hits"][0], json!({}));
|
allow_duplicates! {
|
||||||
|
assert_json_snapshot!(response["hits"][0],
|
||||||
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
|
"_rankingScore": "[score]"
|
||||||
|
}
|
||||||
|
"###)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@@ -402,7 +507,15 @@ async fn displayedattr_2_smol() {
|
|||||||
json!({ "attributesToRetrieve": ["cattos"], "attributesToHighlight": ["cattos"], "attributesToCrop": ["cattos"] }),
|
json!({ "attributesToRetrieve": ["cattos"], "attributesToHighlight": ["cattos"], "attributesToCrop": ["cattos"] }),
|
||||||
|response, code| {
|
|response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(response["hits"][0], json!({}));
|
allow_duplicates! {
|
||||||
|
assert_json_snapshot!(response["hits"][0],
|
||||||
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
|
"_rankingScore": "[score]"
|
||||||
|
}
|
||||||
|
"###)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -413,14 +526,18 @@ async fn displayedattr_2_smol() {
|
|||||||
json!({ "attributesToRetrieve": ["cattos"], "attributesToHighlight": ["id"] }),
|
json!({ "attributesToRetrieve": ["cattos"], "attributesToHighlight": ["id"] }),
|
||||||
|response, code| {
|
|response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"_formatted": {
|
"_formatted": {
|
||||||
"id": "852",
|
"id": "852"
|
||||||
|
},
|
||||||
|
"_rankingScore": "[score]"
|
||||||
|
}
|
||||||
|
"###)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@@ -430,14 +547,18 @@ async fn displayedattr_2_smol() {
|
|||||||
json!({ "attributesToRetrieve": ["cattos"], "attributesToCrop": ["id"] }),
|
json!({ "attributesToRetrieve": ["cattos"], "attributesToCrop": ["id"] }),
|
||||||
|response, code| {
|
|response, code| {
|
||||||
assert_eq!(code, 200, "{}", response);
|
assert_eq!(code, 200, "{}", response);
|
||||||
assert_eq!(
|
allow_duplicates! {
|
||||||
response["hits"][0],
|
assert_json_snapshot!(response["hits"][0],
|
||||||
json!({
|
{ "._rankingScore" => "[score]" },
|
||||||
|
@r###"
|
||||||
|
{
|
||||||
"_formatted": {
|
"_formatted": {
|
||||||
"id": "852",
|
"id": "852"
|
||||||
|
},
|
||||||
|
"_rankingScore": "[score]"
|
||||||
|
}
|
||||||
|
"###)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
@@ -65,14 +65,15 @@ async fn simple_search_single_index() {
|
|||||||
]}))
|
]}))
|
||||||
.await;
|
.await;
|
||||||
snapshot!(code, @"200 OK");
|
snapshot!(code, @"200 OK");
|
||||||
insta::assert_json_snapshot!(response["results"], { "[].processingTimeMs" => "[time]" }, @r###"
|
insta::assert_json_snapshot!(response["results"], { "[].processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###"
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"indexUid": "test",
|
"indexUid": "test",
|
||||||
"hits": [
|
"hits": [
|
||||||
{
|
{
|
||||||
"title": "Gläss",
|
"title": "Gläss",
|
||||||
"id": "450465"
|
"id": "450465",
|
||||||
|
"_rankingScore": "[score]"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"query": "glass",
|
"query": "glass",
|
||||||
@@ -86,7 +87,8 @@ async fn simple_search_single_index() {
|
|||||||
"hits": [
|
"hits": [
|
||||||
{
|
{
|
||||||
"title": "Captain Marvel",
|
"title": "Captain Marvel",
|
||||||
"id": "299537"
|
"id": "299537",
|
||||||
|
"_rankingScore": "[score]"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"query": "captain",
|
"query": "captain",
|
||||||
@@ -170,14 +172,15 @@ async fn simple_search_two_indexes() {
|
|||||||
]}))
|
]}))
|
||||||
.await;
|
.await;
|
||||||
snapshot!(code, @"200 OK");
|
snapshot!(code, @"200 OK");
|
||||||
insta::assert_json_snapshot!(response["results"], { "[].processingTimeMs" => "[time]" }, @r###"
|
insta::assert_json_snapshot!(response["results"], { "[].processingTimeMs" => "[time]", ".**._rankingScore" => "[score]" }, @r###"
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"indexUid": "test",
|
"indexUid": "test",
|
||||||
"hits": [
|
"hits": [
|
||||||
{
|
{
|
||||||
"title": "Gläss",
|
"title": "Gläss",
|
||||||
"id": "450465"
|
"id": "450465",
|
||||||
|
"_rankingScore": "[score]"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"query": "glass",
|
"query": "glass",
|
||||||
@@ -203,7 +206,8 @@ async fn simple_search_two_indexes() {
|
|||||||
"age": 4
|
"age": 4
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"cattos": "pésti"
|
"cattos": "pésti",
|
||||||
|
"_rankingScore": "[score]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 654,
|
"id": 654,
|
||||||
@@ -218,7 +222,8 @@ async fn simple_search_two_indexes() {
|
|||||||
"cattos": [
|
"cattos": [
|
||||||
"simba",
|
"simba",
|
||||||
"pestiféré"
|
"pestiféré"
|
||||||
]
|
],
|
||||||
|
"_rankingScore": "[score]"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"query": "pésti",
|
"query": "pésti",
|
||||||
|
Reference in New Issue
Block a user