mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-31 16:06: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,30 +19,43 @@ 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]" }, | ||||||
|                     "_formatted": { |                     @r###" | ||||||
|                         "id": "852", |               { | ||||||
|                         "cattos": "<em>pésti</em>", |                 "_formatted": { | ||||||
|                     }, |                   "id": "852", | ||||||
|                     "_matchesPosition": {"cattos": [{"start": 0, "length": 5}]}, |                   "cattos": "<em>pésti</em>" | ||||||
|                 }) |                 }, | ||||||
|             ); |                 "_matchesPosition": { | ||||||
|         } |                   "cattos": [ | ||||||
|  |                     { | ||||||
|  |                       "start": 0, | ||||||
|  |                       "length": 5 | ||||||
|  |                     } | ||||||
|  |                   ] | ||||||
|  |                 } | ||||||
|  |               } | ||||||
|  |               "###); | ||||||
|  |             } | ||||||
|  |     } | ||||||
|     ) |     ) | ||||||
|     .await; |     .await; | ||||||
|  |  | ||||||
|     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]" }, | ||||||
|                     "id": 852, |                 @r###" | ||||||
|                     "cattos": "pésti", |                 { | ||||||
|                 }) |                   "id": 852, | ||||||
|             ); |                   "cattos": "pésti" | ||||||
|  |                 } | ||||||
|  |                 "###) | ||||||
|  |             } | ||||||
|         }) |         }) | ||||||
|         .await; |         .await; | ||||||
|  |  | ||||||
| @@ -50,20 +64,29 @@ 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]" }, | ||||||
|                         "id": 852, |                  @r###" | ||||||
|                         "cattos": "pésti", |                   { | ||||||
|                         "_formatted": { |                     "id": 852, | ||||||
|                             "id": "852", |                     "cattos": "pésti", | ||||||
|                             "cattos": "pésti", |                     "_formatted": { | ||||||
|                         }, |                       "id": "852", | ||||||
|                         "_matchesPosition": {"cattos": [{"start": 0, "length": 5}]}, |                       "cattos": "pésti" | ||||||
|                     }) |                     }, | ||||||
|                 ); |                     "_matchesPosition": { | ||||||
|             } |                       "cattos": [ | ||||||
|         ) |                         { | ||||||
|  |                           "start": 0, | ||||||
|  |                           "length": 5 | ||||||
|  |                         } | ||||||
|  |                       ] | ||||||
|  |                     } | ||||||
|  |                   } | ||||||
|  |                   "###) | ||||||
|  |              } | ||||||
|  |         }) | ||||||
|         .await; |         .await; | ||||||
|  |  | ||||||
|     index |     index | ||||||
| @@ -71,17 +94,20 @@ 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]" }, | ||||||
|                         "id": 852, |                     @r###" | ||||||
|                         "cattos": "pésti", |                     { | ||||||
|                         "_formatted": { |                       "id": 852, | ||||||
|                             "id": "852", |                       "cattos": "pésti", | ||||||
|                             "cattos": "pésti", |                       "_formatted": { | ||||||
|                         } |                         "id": "852", | ||||||
|                     }) |                         "cattos": "pésti" | ||||||
|                 ); |                       } | ||||||
|  |                     } | ||||||
|  |                     "###); | ||||||
|  |                 } | ||||||
|             }, |             }, | ||||||
|         ) |         ) | ||||||
|         .await; |         .await; | ||||||
| @@ -89,17 +115,20 @@ 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]" }, | ||||||
|                     "id": 852, |                 @r###" | ||||||
|                     "cattos": "pésti", |                 { | ||||||
|                     "_formatted": { |                   "id": 852, | ||||||
|                         "id": "852", |                   "cattos": "pésti", | ||||||
|                         "cattos": "pésti", |                   "_formatted": { | ||||||
|                     } |                     "id": "852", | ||||||
|                 }) |                     "cattos": "pésti" | ||||||
|             ); |                   } | ||||||
|  |                 } | ||||||
|  |                 "###) | ||||||
|  |             } | ||||||
|         }) |         }) | ||||||
|         .await; |         .await; | ||||||
| } | } | ||||||
| @@ -116,21 +145,24 @@ 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]" }, | ||||||
|                     "doggos": [ |                 @r###" | ||||||
|                         { |                 { | ||||||
|                             "name": "bobby", |                   "doggos": [ | ||||||
|                             "age": 2, |                     { | ||||||
|                         }, |                       "name": "bobby", | ||||||
|                         { |                       "age": 2 | ||||||
|                             "name": "buddy", |                     }, | ||||||
|                             "age": 4, |                     { | ||||||
|                         }, |                       "name": "buddy", | ||||||
|                     ], |                       "age": 4 | ||||||
|                 }) |                     } | ||||||
|             ); |                   ] | ||||||
|  |                 } | ||||||
|  |                 "###) | ||||||
|  |             } | ||||||
|         }) |         }) | ||||||
|         .await; |         .await; | ||||||
|  |  | ||||||
| @@ -139,19 +171,22 @@ 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]" }, | ||||||
|                         "doggos": [ |                     @r###" | ||||||
|                             { |                     { | ||||||
|                                 "name": "bobby", |                       "doggos": [ | ||||||
|                             }, |                         { | ||||||
|                             { |                           "name": "bobby" | ||||||
|                                 "name": "buddy", |                         }, | ||||||
|                             }, |                         { | ||||||
|                         ], |                           "name": "buddy" | ||||||
|                     }) |                         } | ||||||
|                 ); |                       ] | ||||||
|  |                     } | ||||||
|  |                     "###) | ||||||
|  |                 } | ||||||
|             }, |             }, | ||||||
|         ) |         ) | ||||||
|         .await; |         .await; | ||||||
| @@ -161,20 +196,30 @@ 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]" }, | ||||||
|                         "doggos": [ |                     @r###" | ||||||
|                             { |                     { | ||||||
|                                 "name": "bobby", |                       "doggos": [ | ||||||
|                             }, |                         { | ||||||
|                             { |                           "name": "bobby" | ||||||
|                                 "name": "buddy", |                         }, | ||||||
|                             }, |                         { | ||||||
|                         ], |                           "name": "buddy" | ||||||
|                         "_matchesPosition": {"doggos.name": [{"start": 0, "length": 5}]}, |                         } | ||||||
|                     }) |                       ], | ||||||
|                 ); |                       "_matchesPosition": { | ||||||
|  |                         "doggos.name": [ | ||||||
|  |                           { | ||||||
|  |                             "start": 0, | ||||||
|  |                             "length": 5 | ||||||
|  |                           } | ||||||
|  |                         ] | ||||||
|  |                       } | ||||||
|  |                     } | ||||||
|  |                     "###) | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         ) |         ) | ||||||
|         .await; |         .await; | ||||||
| @@ -183,21 +228,24 @@ 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]" }, | ||||||
|                     "_formatted": { |                 @r###" | ||||||
|                         "doggos": [ |                 { | ||||||
|                             { |                   "_formatted": { | ||||||
|                                 "name": "bobby", |                     "doggos": [ | ||||||
|                             }, |                       { | ||||||
|                             { |                         "name": "bobby" | ||||||
|                                 "name": "buddy", |                       }, | ||||||
|                             }, |                       { | ||||||
|                         ], |                         "name": "buddy" | ||||||
|                     }, |                       } | ||||||
|                 }) |                     ] | ||||||
|             ); |                   } | ||||||
|  |                 } | ||||||
|  |                 "###) | ||||||
|  |             } | ||||||
|         }) |         }) | ||||||
|         .await; |         .await; | ||||||
|  |  | ||||||
| @@ -205,21 +253,24 @@ 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]" }, | ||||||
|                     "_formatted": { |                 @r###" | ||||||
|                         "doggos": [ |                 { | ||||||
|                             { |                   "_formatted": { | ||||||
|                                 "name": "bobby", |                     "doggos": [ | ||||||
|                             }, |                       { | ||||||
|                             { |                         "name": "bobby" | ||||||
|                                 "name": "buddy", |                       }, | ||||||
|                             }, |                       { | ||||||
|                         ], |                         "name": "buddy" | ||||||
|                     }, |                       } | ||||||
|                 }) |                     ] | ||||||
|             ); |                   } | ||||||
|  |                 } | ||||||
|  |                 "###) | ||||||
|  |             } | ||||||
|         }) |         }) | ||||||
|         .await; |         .await; | ||||||
|  |  | ||||||
| @@ -227,55 +278,61 @@ 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]" }, | ||||||
|             "doggos": [ |         @r###" | ||||||
|                 { |         { | ||||||
|                     "name": "bobby", |           "doggos": [ | ||||||
|                 }, |             { | ||||||
|                 { |               "name": "bobby" | ||||||
|                     "name": "buddy", |  | ||||||
|                 }, |  | ||||||
|             ], |  | ||||||
|             "_formatted": { |  | ||||||
|                 "doggos": [ |  | ||||||
|                     { |  | ||||||
|                         "name": "bobby", |  | ||||||
|                         "age": "2", |  | ||||||
|                     }, |  | ||||||
|                     { |  | ||||||
|                         "name": "buddy", |  | ||||||
|                         "age": "4", |  | ||||||
|                     }, |  | ||||||
|                 ], |  | ||||||
|             }, |             }, | ||||||
|         }) |             { | ||||||
|     ); |               "name": "buddy" | ||||||
|         }) |             } | ||||||
|  |           ], | ||||||
|  |           "_formatted": { | ||||||
|  |             "doggos": [ | ||||||
|  |               { | ||||||
|  |                 "name": "bobby", | ||||||
|  |                 "age": "2" | ||||||
|  |               }, | ||||||
|  |               { | ||||||
|  |                 "name": "buddy", | ||||||
|  |                 "age": "4" | ||||||
|  |               } | ||||||
|  |             ] | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  |         "###) | ||||||
|  |     } | ||||||
|  |     }) | ||||||
|         .await; |         .await; | ||||||
|  |  | ||||||
|     index |     index | ||||||
|         .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]" }, | ||||||
|             "_formatted": { |                     @r###" | ||||||
|                 "doggos": [ |  | ||||||
|                     { |                     { | ||||||
|                         "name": "bobby", |                       "_formatted": { | ||||||
|                         "age": "2", |                         "doggos": [ | ||||||
|                     }, |                           { | ||||||
|                     { |                             "name": "bobby", | ||||||
|                         "name": "buddy", |                             "age": "2" | ||||||
|                         "age": "4", |                           }, | ||||||
|                     }, |                           { | ||||||
|                 ], |                             "name": "buddy", | ||||||
|             }, |                             "age": "4" | ||||||
|         }) |                           } | ||||||
|     ); |                         ] | ||||||
|  |                       } | ||||||
|  |                     } | ||||||
|  |                     "###) | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         ) |         ) | ||||||
|         .await; |         .await; | ||||||
| @@ -297,54 +354,66 @@ 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]" }, | ||||||
|             "id": 852, |         @r###" | ||||||
|         }) |         { | ||||||
|     ); |           "id": 852 | ||||||
|  |         } | ||||||
|  |         "###) | ||||||
|  |     } | ||||||
|         }) |         }) | ||||||
|         .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]" }, | ||||||
|                     "id": 852, |                 @r###" | ||||||
|                 }) |                 { | ||||||
|             ); |                   "id": 852 | ||||||
|  |                 } | ||||||
|  |                 "###) | ||||||
|  |             } | ||||||
|         }) |         }) | ||||||
|         .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]" }, | ||||||
|                     "id": 852, |                 @r###" | ||||||
|                     "_formatted": { |                 { | ||||||
|                         "id": "852", |                   "id": 852, | ||||||
|                     } |                   "_formatted": { | ||||||
|                 }) |                     "id": "852" | ||||||
|             ); |                   } | ||||||
|  |                 } | ||||||
|  |                 "###) | ||||||
|  |             } | ||||||
|         }) |         }) | ||||||
|         .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]" }, | ||||||
|                     "id": 852, |                 @r###" | ||||||
|                     "_formatted": { |                 { | ||||||
|                         "id": "852", |                   "id": 852, | ||||||
|                     } |                   "_formatted": { | ||||||
|                 }) |                     "id": "852" | ||||||
|             ); |                   } | ||||||
|  |                 } | ||||||
|  |                 "###) | ||||||
|  |             } | ||||||
|         }) |         }) | ||||||
|         .await; |         .await; | ||||||
|  |  | ||||||
| @@ -353,15 +422,18 @@ 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]" }, | ||||||
|                         "id": 852, |                     @r###" | ||||||
|                         "_formatted": { |                     { | ||||||
|                             "id": "852", |                       "id": 852, | ||||||
|                         } |                       "_formatted": { | ||||||
|                     }) |                         "id": "852" | ||||||
|                 ); |                       } | ||||||
|  |                     } | ||||||
|  |                     "###) | ||||||
|  |                 } | ||||||
|             }, |             }, | ||||||
|         ) |         ) | ||||||
|         .await; |         .await; | ||||||
| @@ -369,31 +441,41 @@ 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]" }, | ||||||
|                     "id": 852, |                 @r###" | ||||||
|                 }) |                 { | ||||||
|             ); |                   "id": 852 | ||||||
|  |                 } | ||||||
|  |                 "###) | ||||||
|  |             } | ||||||
|         }) |         }) | ||||||
|         .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]" }, | ||||||
|                     "id": 852, |                 @r###" | ||||||
|                 }) |                 { | ||||||
|             ); |                   "id": 852 | ||||||
|  |                 } | ||||||
|  |                 "###) | ||||||
|  |             } | ||||||
|         }) |         }) | ||||||
|         .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]" }, | ||||||
|  |                 @"{}") | ||||||
|  |             } | ||||||
|         }) |         }) | ||||||
|         .await; |         .await; | ||||||
|  |  | ||||||
| @@ -402,7 +484,11 @@ 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]" }, | ||||||
|  |         @"{}") | ||||||
|  |     } | ||||||
|  |  | ||||||
|             } |             } | ||||||
|         ) |         ) | ||||||
| @@ -413,14 +499,17 @@ 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]" }, | ||||||
|                         "_formatted": { |                     @r###" | ||||||
|                             "id": "852", |                     { | ||||||
|                         } |                       "_formatted": { | ||||||
|                     }) |                         "id": "852" | ||||||
|                 ); |                       } | ||||||
|  |                     } | ||||||
|  |                     "###) | ||||||
|  |                 } | ||||||
|             }, |             }, | ||||||
|         ) |         ) | ||||||
|         .await; |         .await; | ||||||
| @@ -430,14 +519,17 @@ 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]" }, | ||||||
|                         "_formatted": { |                     @r###" | ||||||
|                             "id": "852", |                     { | ||||||
|                         } |                       "_formatted": { | ||||||
|                     }) |                         "id": "852" | ||||||
|                 ); |                       } | ||||||
|  |                     } | ||||||
|  |                     "###) | ||||||
|  |                 } | ||||||
|             }, |             }, | ||||||
|         ) |         ) | ||||||
|         .await; |         .await; | ||||||
|   | |||||||
| @@ -65,7 +65,7 @@ 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", | ||||||
| @@ -170,7 +170,7 @@ 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", | ||||||
|   | |||||||
| @@ -123,7 +123,7 @@ fn test_attribute_fid_simple() { | |||||||
|     s.terms_matching_strategy(TermsMatchingStrategy::All); |     s.terms_matching_strategy(TermsMatchingStrategy::All); | ||||||
|     s.query("the quick brown fox jumps over the lazy dog"); |     s.query("the quick brown fox jumps over the lazy dog"); | ||||||
|     let SearchResult { documents_ids, .. } = s.execute().unwrap(); |     let SearchResult { documents_ids, .. } = s.execute().unwrap(); | ||||||
|     insta::assert_snapshot!(format!("{documents_ids:?}"), @"[2, 6, 5, 4, 3, 9, 7, 8, 11, 10, 12, 13, 14, 0]"); |     insta::assert_snapshot!(format!("{documents_ids:?}"), @"[2, 6, 5, 4, 3, 9, 8, 7, 11, 10, 13, 12, 14, 0]"); | ||||||
| } | } | ||||||
|  |  | ||||||
| #[test] | #[test] | ||||||
| @@ -136,5 +136,5 @@ fn test_attribute_fid_ngrams() { | |||||||
|     s.terms_matching_strategy(TermsMatchingStrategy::All); |     s.terms_matching_strategy(TermsMatchingStrategy::All); | ||||||
|     s.query("the quick brown fox jumps over the lazy dog"); |     s.query("the quick brown fox jumps over the lazy dog"); | ||||||
|     let SearchResult { documents_ids, .. } = s.execute().unwrap(); |     let SearchResult { documents_ids, .. } = s.execute().unwrap(); | ||||||
|     insta::assert_snapshot!(format!("{documents_ids:?}"), @"[2, 6, 5, 4, 3, 9, 7, 8, 11, 10, 12, 13, 14, 0]"); |     insta::assert_snapshot!(format!("{documents_ids:?}"), @"[2, 6, 5, 4, 3, 9, 8, 7, 11, 10, 13, 12, 14, 0]"); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -138,7 +138,7 @@ fn test_attribute_position_simple() { | |||||||
|     s.terms_matching_strategy(TermsMatchingStrategy::All); |     s.terms_matching_strategy(TermsMatchingStrategy::All); | ||||||
|     s.query("quick brown"); |     s.query("quick brown"); | ||||||
|     let SearchResult { documents_ids, .. } = s.execute().unwrap(); |     let SearchResult { documents_ids, .. } = s.execute().unwrap(); | ||||||
|     insta::assert_snapshot!(format!("{documents_ids:?}"), @"[10, 11, 12, 13, 2, 3, 4, 1, 0, 6, 8, 7, 9, 5]"); |     insta::assert_snapshot!(format!("{documents_ids:?}"), @"[10, 12, 11, 13, 3, 4, 2, 0, 1, 6, 8, 7, 9, 5]"); | ||||||
| } | } | ||||||
| #[test] | #[test] | ||||||
| fn test_attribute_position_repeated() { | fn test_attribute_position_repeated() { | ||||||
| @@ -163,7 +163,7 @@ fn test_attribute_position_different_fields() { | |||||||
|     s.terms_matching_strategy(TermsMatchingStrategy::All); |     s.terms_matching_strategy(TermsMatchingStrategy::All); | ||||||
|     s.query("quick brown"); |     s.query("quick brown"); | ||||||
|     let SearchResult { documents_ids, .. } = s.execute().unwrap(); |     let SearchResult { documents_ids, .. } = s.execute().unwrap(); | ||||||
|     insta::assert_snapshot!(format!("{documents_ids:?}"), @"[10, 11, 12, 13, 2, 3, 4, 1, 0, 6, 8, 7, 9, 5]"); |     insta::assert_snapshot!(format!("{documents_ids:?}"), @"[10, 12, 11, 13, 3, 4, 2, 0, 1, 6, 8, 7, 9, 5]"); | ||||||
| } | } | ||||||
|  |  | ||||||
| #[test] | #[test] | ||||||
| @@ -176,5 +176,5 @@ fn test_attribute_position_ngrams() { | |||||||
|     s.terms_matching_strategy(TermsMatchingStrategy::All); |     s.terms_matching_strategy(TermsMatchingStrategy::All); | ||||||
|     s.query("quick brown"); |     s.query("quick brown"); | ||||||
|     let SearchResult { documents_ids, .. } = s.execute().unwrap(); |     let SearchResult { documents_ids, .. } = s.execute().unwrap(); | ||||||
|     insta::assert_snapshot!(format!("{documents_ids:?}"), @"[10, 11, 12, 13, 2, 3, 4, 1, 0, 6, 8, 7, 9, 5]"); |     insta::assert_snapshot!(format!("{documents_ids:?}"), @"[10, 12, 11, 13, 3, 4, 2, 0, 1, 6, 8, 7, 9, 5]"); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -270,13 +270,13 @@ fn test_proximity_simple() { | |||||||
|     s.terms_matching_strategy(TermsMatchingStrategy::All); |     s.terms_matching_strategy(TermsMatchingStrategy::All); | ||||||
|     s.query("the quick brown fox jumps over the lazy dog"); |     s.query("the quick brown fox jumps over the lazy dog"); | ||||||
|     let SearchResult { documents_ids, .. } = s.execute().unwrap(); |     let SearchResult { documents_ids, .. } = s.execute().unwrap(); | ||||||
|     insta::assert_snapshot!(format!("{documents_ids:?}"), @"[4, 9, 10, 7, 6, 5, 2, 3, 0, 1]"); |     insta::assert_snapshot!(format!("{documents_ids:?}"), @"[9, 10, 4, 7, 6, 5, 2, 3, 0, 1]"); | ||||||
|     let texts = collect_field_values(&index, &txn, "text", &documents_ids); |     let texts = collect_field_values(&index, &txn, "text", &documents_ids); | ||||||
|     insta::assert_debug_snapshot!(texts, @r###" |     insta::assert_debug_snapshot!(texts, @r###" | ||||||
|     [ |     [ | ||||||
|         "\"the quickbrown fox jumps over the lazy dog\"", |  | ||||||
|         "\"the quack brown fox jumps over the lazy dog\"", |         "\"the quack brown fox jumps over the lazy dog\"", | ||||||
|         "\"the quick brown fox jumps over the lazy dog\"", |         "\"the quick brown fox jumps over the lazy dog\"", | ||||||
|  |         "\"the quickbrown fox jumps over the lazy dog\"", | ||||||
|         "\"the really quick brown fox jumps over the lazy dog\"", |         "\"the really quick brown fox jumps over the lazy dog\"", | ||||||
|         "\"the really quick brown fox jumps over the very lazy dog\"", |         "\"the really quick brown fox jumps over the very lazy dog\"", | ||||||
|         "\"brown quick fox jumps over the lazy dog\"", |         "\"brown quick fox jumps over the lazy dog\"", | ||||||
|   | |||||||
| @@ -68,7 +68,7 @@ | |||||||
|     "word_rank": 0, |     "word_rank": 0, | ||||||
|     "typo_rank": 1, |     "typo_rank": 1, | ||||||
|     "proximity_rank": 16, |     "proximity_rank": 16, | ||||||
|     "attribute_rank": 208, |     "attribute_rank": 209, | ||||||
|     "exact_rank": 5, |     "exact_rank": 5, | ||||||
|     "asc_desc_rank": 3, |     "asc_desc_rank": 3, | ||||||
|     "sort_by_rank": 2, |     "sort_by_rank": 2, | ||||||
| @@ -155,7 +155,7 @@ | |||||||
|     "word_rank": 1, |     "word_rank": 1, | ||||||
|     "typo_rank": 0, |     "typo_rank": 0, | ||||||
|     "proximity_rank": 1, |     "proximity_rank": 1, | ||||||
|     "attribute_rank": 1, |     "attribute_rank": 2, | ||||||
|     "exact_rank": 3, |     "exact_rank": 3, | ||||||
|     "asc_desc_rank": 4, |     "asc_desc_rank": 4, | ||||||
|     "sort_by_rank": 1, |     "sort_by_rank": 1, | ||||||
| @@ -199,7 +199,7 @@ | |||||||
|     "word_rank": 1, |     "word_rank": 1, | ||||||
|     "typo_rank": 0, |     "typo_rank": 0, | ||||||
|     "proximity_rank": 1, |     "proximity_rank": 1, | ||||||
|     "attribute_rank": 2, |     "attribute_rank": 1, | ||||||
|     "exact_rank": 3, |     "exact_rank": 3, | ||||||
|     "asc_desc_rank": 2, |     "asc_desc_rank": 2, | ||||||
|     "sort_by_rank": 1, |     "sort_by_rank": 1, | ||||||
| @@ -220,7 +220,7 @@ | |||||||
|     "word_rank": 0, |     "word_rank": 0, | ||||||
|     "typo_rank": 2, |     "typo_rank": 2, | ||||||
|     "proximity_rank": 10, |     "proximity_rank": 10, | ||||||
|     "attribute_rank": 209, |     "attribute_rank": 208, | ||||||
|     "exact_rank": 6, |     "exact_rank": 6, | ||||||
|     "asc_desc_rank": 1, |     "asc_desc_rank": 1, | ||||||
|     "sort_by_rank": 2, |     "sort_by_rank": 2, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user