mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-31 07:56:28 +00:00 
			
		
		
		
	add more tests on the formatted route
This commit is contained in:
		
							
								
								
									
										4
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							| @@ -3986,9 +3986,9 @@ checksum = "b6d12cb7a57bbf2ab670ed9545bae3648048547f9039279a89ce000208e585c1" | ||||
|  | ||||
| [[package]] | ||||
| name = "yaup" | ||||
| version = "0.1.0" | ||||
| version = "0.2.0" | ||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||||
| checksum = "7f8e1d3d18db742c8b9ad2f5f3c5bf5b63aa67b9933617c8f8350d39a3c173c6" | ||||
| checksum = "3bc9ef6963f7e857050aabf31ebc44184f278bcfec4c3671552c1a916b152b45" | ||||
| dependencies = [ | ||||
|  "serde", | ||||
|  "url", | ||||
|   | ||||
| @@ -84,7 +84,7 @@ assert-json-diff = "2.0.1" | ||||
| manifest-dir-macros = "0.1.14" | ||||
| maplit = "1.0.2" | ||||
| urlencoding = "2.1.0" | ||||
| yaup = "0.1.0" | ||||
| yaup = "0.2.0" | ||||
|  | ||||
| [features] | ||||
| default = ["analytics", "mini-dashboard"] | ||||
|   | ||||
| @@ -107,7 +107,7 @@ async fn filter_invalid_syntax_array() { | ||||
|         "link": "https://docs.meilisearch.com/errors#invalid_filter" | ||||
|     }); | ||||
|     index | ||||
|         .search(json!({"filter": [["title & Glass"]]}), |response, code| { | ||||
|         .search(json!({"filter": ["title & Glass"]}), |response, code| { | ||||
|             assert_eq!(response, expected_response); | ||||
|             assert_eq!(code, 400); | ||||
|         }) | ||||
| @@ -164,7 +164,7 @@ async fn filter_invalid_attribute_array() { | ||||
|         "link": "https://docs.meilisearch.com/errors#invalid_filter" | ||||
|     }); | ||||
|     index | ||||
|         .search(json!({"filter": [["many = Glass"]]}), |response, code| { | ||||
|         .search(json!({"filter": ["many = Glass"]}), |response, code| { | ||||
|             assert_eq!(response, expected_response); | ||||
|             assert_eq!(code, 400); | ||||
|         }) | ||||
| @@ -218,7 +218,7 @@ async fn filter_reserved_geo_attribute_array() { | ||||
|         "link": "https://docs.meilisearch.com/errors#invalid_filter" | ||||
|     }); | ||||
|     index | ||||
|         .search(json!({"filter": [["_geo = Glass"]]}), |response, code| { | ||||
|         .search(json!({"filter": ["_geo = Glass"]}), |response, code| { | ||||
|             assert_eq!(response, expected_response); | ||||
|             assert_eq!(code, 400); | ||||
|         }) | ||||
| @@ -273,7 +273,7 @@ async fn filter_reserved_attribute_array() { | ||||
|     }); | ||||
|     index | ||||
|         .search( | ||||
|             json!({"filter": [["_geoDistance = Glass"]]}), | ||||
|             json!({"filter": ["_geoDistance = Glass"]}), | ||||
|             |response, code| { | ||||
|                 assert_eq!(response, expected_response); | ||||
|                 assert_eq!(code, 400); | ||||
|   | ||||
| @@ -33,70 +33,82 @@ async fn formatted_contain_wildcard() { | ||||
|     ) | ||||
|     .await; | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "q": "pesti", "attributesToRetrieve": ["*"] })) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "id": 852, | ||||
|             "cattos": "pesti", | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post( | ||||
|             json!({ "q": "pesti", "attributesToRetrieve": ["*"], "attributesToHighlight": ["id"], "showMatchesPosition": true }), | ||||
|         ) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "id": 852, | ||||
|             "cattos": "pesti", | ||||
|             "_formatted": { | ||||
|                 "id": "852", | ||||
|                 "cattos": "pesti", | ||||
|     index | ||||
|         .search( | ||||
|             json!({ "q": "pesti", "attributesToRetrieve": ["*"] }), | ||||
|             |response, code| { | ||||
|                 assert_eq!(code, 200, "{}", response); | ||||
|                 assert_eq!( | ||||
|                     response["hits"][0], | ||||
|                     json!({ | ||||
|                         "id": 852, | ||||
|                         "cattos": "pesti", | ||||
|                     }) | ||||
|                 ); | ||||
|             }, | ||||
|             "_matchesPosition": {"cattos": [{"start": 0, "length": 5}]}, | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post( | ||||
|             json!({ "q": "pesti", "attributesToRetrieve": ["*"], "attributesToCrop": ["*"] }), | ||||
|         ) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "id": 852, | ||||
|             "cattos": "pesti", | ||||
|             "_formatted": { | ||||
|                 "id": "852", | ||||
|                 "cattos": "pesti", | ||||
|             } | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "q": "pesti", "attributesToCrop": ["*"] })) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "id": 852, | ||||
|             "cattos": "pesti", | ||||
|             "_formatted": { | ||||
|                 "id": "852", | ||||
|                 "cattos": "pesti", | ||||
|     index | ||||
|         .search( | ||||
|             json!({ "q": "pesti", "attributesToRetrieve": ["*"], "attributesToHighlight": ["id"], "showMatchesPosition": true }), | ||||
|             |response, code| { | ||||
|                 assert_eq!(code, 200, "{}", response); | ||||
|                 assert_eq!( | ||||
|                     response["hits"][0], | ||||
|                     json!({ | ||||
|                         "id": 852, | ||||
|                         "cattos": "pesti", | ||||
|                         "_formatted": { | ||||
|                             "id": "852", | ||||
|                             "cattos": "pesti", | ||||
|                         }, | ||||
|                         "_matchesPosition": {"cattos": [{"start": 0, "length": 5}]}, | ||||
|                     }) | ||||
|                 ); | ||||
|             } | ||||
|         }) | ||||
|     ); | ||||
|         ) | ||||
|         .await; | ||||
|  | ||||
|     index | ||||
|         .search( | ||||
|             json!({ "q": "pesti", "attributesToRetrieve": ["*"], "attributesToCrop": ["*"] }), | ||||
|             |response, code| { | ||||
|                 assert_eq!(code, 200, "{}", response); | ||||
|                 assert_eq!( | ||||
|                     response["hits"][0], | ||||
|                     json!({ | ||||
|                         "id": 852, | ||||
|                         "cattos": "pesti", | ||||
|                         "_formatted": { | ||||
|                             "id": "852", | ||||
|                             "cattos": "pesti", | ||||
|                         } | ||||
|                     }) | ||||
|                 ); | ||||
|             }, | ||||
|         ) | ||||
|         .await; | ||||
|  | ||||
|     index | ||||
|         .search( | ||||
|             json!({ "q": "pesti", "attributesToCrop": ["*"] }), | ||||
|             |response, code| { | ||||
|                 assert_eq!(code, 200, "{}", response); | ||||
|                 assert_eq!( | ||||
|                     response["hits"][0], | ||||
|                     json!({ | ||||
|                         "id": 852, | ||||
|                         "cattos": "pesti", | ||||
|                         "_formatted": { | ||||
|                             "id": "852", | ||||
|                             "cattos": "pesti", | ||||
|                         } | ||||
|                     }) | ||||
|                 ); | ||||
|             }, | ||||
|         ) | ||||
|         .await; | ||||
| } | ||||
|  | ||||
| #[actix_rt::test] | ||||
| @@ -108,108 +120,122 @@ async fn format_nested() { | ||||
|     index.add_documents(documents, None).await; | ||||
|     index.wait_task(0).await; | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "q": "pesti", "attributesToRetrieve": ["doggos"] })) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "doggos": [ | ||||
|                 { | ||||
|                     "name": "bobby", | ||||
|                     "age": 2, | ||||
|                 }, | ||||
|                 { | ||||
|                     "name": "buddy", | ||||
|                     "age": 4, | ||||
|                 }, | ||||
|             ], | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "q": "pesti", "attributesToRetrieve": ["doggos.name"] })) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "doggos": [ | ||||
|                 { | ||||
|                     "name": "bobby", | ||||
|                 }, | ||||
|                 { | ||||
|                     "name": "buddy", | ||||
|                 }, | ||||
|             ], | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post( | ||||
|             json!({ "q": "bobby", "attributesToRetrieve": ["doggos.name"], "showMatchesPosition": true }), | ||||
|     index | ||||
|         .search( | ||||
|             json!({ "q": "pesti", "attributesToRetrieve": ["doggos"] }), | ||||
|             |response, code| { | ||||
|                 assert_eq!(code, 200, "{}", response); | ||||
|                 assert_eq!( | ||||
|                     response["hits"][0], | ||||
|                     json!({ | ||||
|                         "doggos": [ | ||||
|                             { | ||||
|                                 "name": "bobby", | ||||
|                                 "age": 2, | ||||
|                             }, | ||||
|                             { | ||||
|                                 "name": "buddy", | ||||
|                                 "age": 4, | ||||
|                             }, | ||||
|                         ], | ||||
|                     }) | ||||
|                 ); | ||||
|             }, | ||||
|         ) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "doggos": [ | ||||
|                 { | ||||
|                     "name": "bobby", | ||||
|                 }, | ||||
|                 { | ||||
|                     "name": "buddy", | ||||
|                 }, | ||||
|             ], | ||||
|             "_matchesPosition": {"doggos.name": [{"start": 0, "length": 5}]}, | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "q": "pesti", "attributesToRetrieve": [], "attributesToHighlight": ["doggos.name"] })) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "_formatted": { | ||||
|                 "doggos": [ | ||||
|                     { | ||||
|                         "name": "bobby", | ||||
|                     }, | ||||
|                     { | ||||
|                         "name": "buddy", | ||||
|                     }, | ||||
|                 ], | ||||
|     index | ||||
|         .search( | ||||
|             json!({ "q": "pesti", "attributesToRetrieve": ["doggos.name"] }), | ||||
|             |response, code| { | ||||
|                 assert_eq!(code, 200, "{}", response); | ||||
|                 assert_eq!( | ||||
|                     response["hits"][0], | ||||
|                     json!({ | ||||
|                         "doggos": [ | ||||
|                             { | ||||
|                                 "name": "bobby", | ||||
|                             }, | ||||
|                             { | ||||
|                                 "name": "buddy", | ||||
|                             }, | ||||
|                         ], | ||||
|                     }) | ||||
|                 ); | ||||
|             }, | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "q": "pesti", "attributesToRetrieve": [], "attributesToCrop": ["doggos.name"] })) | ||||
|         ) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "_formatted": { | ||||
|                 "doggos": [ | ||||
|                     { | ||||
|                         "name": "bobby", | ||||
|                     }, | ||||
|                     { | ||||
|                         "name": "buddy", | ||||
|                     }, | ||||
|                 ], | ||||
|             }, | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "q": "pesti", "attributesToRetrieve": ["doggos.name"], "attributesToHighlight": ["doggos.age"] })) | ||||
|     index | ||||
|         .search( | ||||
|             json!({ "q": "bobby", "attributesToRetrieve": ["doggos.name"], "showMatchesPosition": true }), | ||||
|             |response, code| { | ||||
|                 assert_eq!(code, 200, "{}", response); | ||||
|                 assert_eq!( | ||||
|                     response["hits"][0], | ||||
|                     json!({ | ||||
|                         "doggos": [ | ||||
|                             { | ||||
|                                 "name": "bobby", | ||||
|                             }, | ||||
|                             { | ||||
|                                 "name": "buddy", | ||||
|                             }, | ||||
|                         ], | ||||
|                         "_matchesPosition": {"doggos.name": [{"start": 0, "length": 5}]}, | ||||
|                     }) | ||||
|                 ); | ||||
|             } | ||||
|         ) | ||||
|         .await; | ||||
|  | ||||
|     index | ||||
|         .search(json!({ "q": "pesti", "attributesToRetrieve": [], "attributesToHighlight": ["doggos.name"] }), | ||||
|         |response, code| { | ||||
|             assert_eq!(code, 200, "{}", response); | ||||
|             assert_eq!( | ||||
|                 response["hits"][0], | ||||
|                 json!({ | ||||
|                     "_formatted": { | ||||
|                         "doggos": [ | ||||
|                             { | ||||
|                                 "name": "bobby", | ||||
|                             }, | ||||
|                             { | ||||
|                                 "name": "buddy", | ||||
|                             }, | ||||
|                         ], | ||||
|                     }, | ||||
|                 }) | ||||
|             ); | ||||
|         }) | ||||
|         .await; | ||||
|  | ||||
|     index | ||||
|         .search(json!({ "q": "pesti", "attributesToRetrieve": [], "attributesToCrop": ["doggos.name"] }), | ||||
|         |response, code| { | ||||
|             assert_eq!(code, 200, "{}", response); | ||||
|             assert_eq!( | ||||
|                 response["hits"][0], | ||||
|                 json!({ | ||||
|                     "_formatted": { | ||||
|                         "doggos": [ | ||||
|                             { | ||||
|                                 "name": "bobby", | ||||
|                             }, | ||||
|                             { | ||||
|                                 "name": "buddy", | ||||
|                             }, | ||||
|                         ], | ||||
|                     }, | ||||
|                 }) | ||||
|             ); | ||||
|         }) | ||||
|         .await; | ||||
|  | ||||
|     index | ||||
|         .search(json!({ "q": "pesti", "attributesToRetrieve": ["doggos.name"], "attributesToHighlight": ["doggos.age"] }), | ||||
|         |response, code| { | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
| @@ -236,11 +262,13 @@ async fn format_nested() { | ||||
|             }, | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "q": "pesti", "attributesToRetrieve": [], "attributesToHighlight": ["doggos.age"], "attributesToCrop": ["doggos.name"] })) | ||||
|         }) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|  | ||||
|     index | ||||
|         .search(json!({ "q": "pesti", "attributesToRetrieve": [], "attributesToHighlight": ["doggos.age"], "attributesToCrop": ["doggos.name"] }), | ||||
|         |response, code| { | ||||
|                 assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
| @@ -258,6 +286,9 @@ async fn format_nested() { | ||||
|             }, | ||||
|         }) | ||||
|     ); | ||||
|             } | ||||
|         ) | ||||
|         .await; | ||||
| } | ||||
|  | ||||
| #[actix_rt::test] | ||||
| @@ -274,9 +305,9 @@ async fn displayedattr_2_smol() { | ||||
|     index.add_documents(documents, None).await; | ||||
|     index.wait_task(1).await; | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "attributesToRetrieve": ["father", "id"], "attributesToHighlight": ["mother"], "attributesToCrop": ["cattos"] })) | ||||
|         .await; | ||||
|     index | ||||
|         .search(json!({ "attributesToRetrieve": ["father", "id"], "attributesToHighlight": ["mother"], "attributesToCrop": ["cattos"] }), | ||||
|         |response, code| { | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
| @@ -284,119 +315,157 @@ async fn displayedattr_2_smol() { | ||||
|             "id": 852, | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "attributesToRetrieve": ["id"] })) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "id": 852, | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "attributesToHighlight": ["id"] })) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "id": 852, | ||||
|             "_formatted": { | ||||
|                 "id": "852", | ||||
|             } | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "attributesToCrop": ["id"] })) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "id": 852, | ||||
|             "_formatted": { | ||||
|                 "id": "852", | ||||
|             } | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "attributesToHighlight": ["id"], "attributesToCrop": ["id"] })) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "id": 852, | ||||
|             "_formatted": { | ||||
|                 "id": "852", | ||||
|             } | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "attributesToHighlight": ["cattos"] })) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "id": 852, | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "attributesToCrop": ["cattos"] })) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "id": 852, | ||||
|         }) | ||||
|     ); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "attributesToRetrieve": ["cattos"] })) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!(response["hits"][0], json!({})); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post( | ||||
|             json!({ "attributesToRetrieve": ["cattos"], "attributesToHighlight": ["cattos"], "attributesToCrop": ["cattos"] }), | ||||
|     index | ||||
|         .search( | ||||
|             json!({ "attributesToRetrieve": ["id"] }), | ||||
|             |response, code| { | ||||
|                 assert_eq!(code, 200, "{}", response); | ||||
|                 assert_eq!( | ||||
|                     response["hits"][0], | ||||
|                     json!({ | ||||
|                         "id": 852, | ||||
|                     }) | ||||
|                 ); | ||||
|             }, | ||||
|         ) | ||||
|         .await; | ||||
|  | ||||
|     index | ||||
|         .search( | ||||
|             json!({ "attributesToHighlight": ["id"] }), | ||||
|             |response, code| { | ||||
|                 assert_eq!(code, 200, "{}", response); | ||||
|                 assert_eq!( | ||||
|                     response["hits"][0], | ||||
|                     json!({ | ||||
|                         "id": 852, | ||||
|                         "_formatted": { | ||||
|                             "id": "852", | ||||
|                         } | ||||
|                     }) | ||||
|                 ); | ||||
|             }, | ||||
|         ) | ||||
|         .await; | ||||
|  | ||||
|     index | ||||
|         .search(json!({ "attributesToCrop": ["id"] }), |response, code| { | ||||
|             assert_eq!(code, 200, "{}", response); | ||||
|             assert_eq!( | ||||
|                 response["hits"][0], | ||||
|                 json!({ | ||||
|                     "id": 852, | ||||
|                     "_formatted": { | ||||
|                         "id": "852", | ||||
|                     } | ||||
|                 }) | ||||
|             ); | ||||
|         }) | ||||
|         .await; | ||||
|  | ||||
|     index | ||||
|         .search( | ||||
|             json!({ "attributesToHighlight": ["id"], "attributesToCrop": ["id"] }), | ||||
|             |response, code| { | ||||
|                 assert_eq!(code, 200, "{}", response); | ||||
|                 assert_eq!( | ||||
|                     response["hits"][0], | ||||
|                     json!({ | ||||
|                         "id": 852, | ||||
|                         "_formatted": { | ||||
|                             "id": "852", | ||||
|                         } | ||||
|                     }) | ||||
|                 ); | ||||
|             }, | ||||
|         ) | ||||
|         .await; | ||||
|  | ||||
|     index | ||||
|         .search( | ||||
|             json!({ "attributesToHighlight": ["cattos"] }), | ||||
|             |response, code| { | ||||
|                 assert_eq!(code, 200, "{}", response); | ||||
|                 assert_eq!( | ||||
|                     response["hits"][0], | ||||
|                     json!({ | ||||
|                         "id": 852, | ||||
|                     }) | ||||
|                 ); | ||||
|             }, | ||||
|         ) | ||||
|         .await; | ||||
|  | ||||
|     index | ||||
|         .search( | ||||
|             json!({ "attributesToCrop": ["cattos"] }), | ||||
|             |response, code| { | ||||
|                 assert_eq!(code, 200, "{}", response); | ||||
|                 assert_eq!( | ||||
|                     response["hits"][0], | ||||
|                     json!({ | ||||
|                         "id": 852, | ||||
|                     }) | ||||
|                 ); | ||||
|             }, | ||||
|         ) | ||||
|         .await; | ||||
|  | ||||
|     index | ||||
|         .search( | ||||
|             json!({ "attributesToRetrieve": ["cattos"] }), | ||||
|             |response, code| { | ||||
|                 assert_eq!(code, 200, "{}", response); | ||||
|                 assert_eq!(response["hits"][0], json!({})); | ||||
|             }, | ||||
|         ) | ||||
|         .await; | ||||
|  | ||||
|     index | ||||
|         .search( | ||||
|             json!({ "attributesToRetrieve": ["cattos"], "attributesToHighlight": ["cattos"], "attributesToCrop": ["cattos"] }), | ||||
|             |response, code| { | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!(response["hits"][0], json!({})); | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "attributesToRetrieve": ["cattos"], "attributesToHighlight": ["id"] })) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "_formatted": { | ||||
|                 "id": "852", | ||||
|             } | ||||
|         }) | ||||
|     ); | ||||
|         ) | ||||
|         .await; | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "attributesToRetrieve": ["cattos"], "attributesToCrop": ["id"] })) | ||||
|     index | ||||
|         .search( | ||||
|             json!({ "attributesToRetrieve": ["cattos"], "attributesToHighlight": ["id"] }), | ||||
|             |response, code| { | ||||
|                 assert_eq!(code, 200, "{}", response); | ||||
|                 assert_eq!( | ||||
|                     response["hits"][0], | ||||
|                     json!({ | ||||
|                         "_formatted": { | ||||
|                             "id": "852", | ||||
|                         } | ||||
|                     }) | ||||
|                 ); | ||||
|             }, | ||||
|         ) | ||||
|         .await; | ||||
|  | ||||
|     index | ||||
|         .search( | ||||
|             json!({ "attributesToRetrieve": ["cattos"], "attributesToCrop": ["id"] }), | ||||
|             |response, code| { | ||||
|                 assert_eq!(code, 200, "{}", response); | ||||
|                 assert_eq!( | ||||
|                     response["hits"][0], | ||||
|                     json!({ | ||||
|                         "_formatted": { | ||||
|                             "id": "852", | ||||
|                         } | ||||
|                     }) | ||||
|                 ); | ||||
|             }, | ||||
|         ) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "_formatted": { | ||||
|                 "id": "852", | ||||
|             } | ||||
|         }) | ||||
|     ); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user