mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-31 07:56:28 +00:00 
			
		
		
		
	Merge #2543
2543: fix all the array on the search get route and improve the tests r=curquiza a=irevoire fix #2527 Co-authored-by: Tamo <tamo@meilisearch.com>
This commit is contained in:
		| @@ -221,7 +221,7 @@ impl Index<'_> { | ||||
|     } | ||||
|  | ||||
|     pub async fn search_get(&self, query: Value) -> (Value, StatusCode) { | ||||
|         let params = serde_url_params::to_string(&query).unwrap(); | ||||
|         let params = yaup::to_string(&query).unwrap(); | ||||
|         let url = format!("/indexes/{}/search?{}", encode(self.uid.as_ref()), params); | ||||
|         self.service.get(url).await | ||||
|     } | ||||
|   | ||||
| @@ -45,26 +45,18 @@ async fn search_invalid_highlight_and_crop_tags() { | ||||
|  | ||||
|     for field in fields { | ||||
|         // object | ||||
|         index | ||||
|             .search( | ||||
|                 json!({field.to_string(): {"marker": "<crop>"}}), | ||||
|                 |response, code| { | ||||
|                     assert_eq!(code, 400, "field {} passing object: {}", &field, response); | ||||
|                     assert_eq!(response["code"], "bad_request"); | ||||
|                 }, | ||||
|             ) | ||||
|         let (response, code) = index | ||||
|             .search_post(json!({field.to_string(): {"marker": "<crop>"}})) | ||||
|             .await; | ||||
|         assert_eq!(code, 400, "field {} passing object: {}", &field, response); | ||||
|         assert_eq!(response["code"], "bad_request"); | ||||
|  | ||||
|         // array | ||||
|         index | ||||
|             .search( | ||||
|                 json!({field.to_string(): ["marker", "<crop>"]}), | ||||
|                 |response, code| { | ||||
|                     assert_eq!(code, 400, "field {} passing array: {}", &field, response); | ||||
|                     assert_eq!(response["code"], "bad_request"); | ||||
|                 }, | ||||
|             ) | ||||
|         let (response, code) = index | ||||
|             .search_post(json!({field.to_string(): ["marker", "<crop>"]})) | ||||
|             .await; | ||||
|         assert_eq!(code, 400, "field {} passing array: {}", &field, response); | ||||
|         assert_eq!(response["code"], "bad_request"); | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -15,20 +15,23 @@ async fn formatted_contain_wildcard() { | ||||
|     index.add_documents(documents, None).await; | ||||
|     index.wait_task(1).await; | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "q": "pesti", "attributesToRetrieve": ["father", "mother"], "attributesToHighlight": ["father", "mother", "*"], "attributesToCrop": ["doggos"], "showMatchesPosition": true })) | ||||
|         .await; | ||||
|     assert_eq!(code, 200, "{}", response); | ||||
|     assert_eq!( | ||||
|         response["hits"][0], | ||||
|         json!({ | ||||
|             "_formatted": { | ||||
|                 "id": "852", | ||||
|                 "cattos": "<em>pesti</em>", | ||||
|             }, | ||||
|             "_matchesPosition": {"cattos": [{"start": 0, "length": 5}]}, | ||||
|         }) | ||||
|     ); | ||||
|     index.search(json!({ "q": "pesti", "attributesToRetrieve": ["father", "mother"], "attributesToHighlight": ["father", "mother", "*"], "attributesToCrop": ["doggos"], "showMatchesPosition": true }), | ||||
|         |response, code| | ||||
|         { | ||||
|             assert_eq!(code, 200, "{}", response); | ||||
|             assert_eq!( | ||||
|                 response["hits"][0], | ||||
|                 json!({ | ||||
|                     "_formatted": { | ||||
|                         "id": "852", | ||||
|                         "cattos": "<em>pesti</em>", | ||||
|                     }, | ||||
|                     "_matchesPosition": {"cattos": [{"start": 0, "length": 5}]}, | ||||
|                 }) | ||||
|             ); | ||||
|         } | ||||
|     ) | ||||
|     .await; | ||||
|  | ||||
|     let (response, code) = index | ||||
|         .search_post(json!({ "q": "pesti", "attributesToRetrieve": ["*"] })) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user