From 189d4c3b70878dc23c6498a81917166506de8c8e Mon Sep 17 00:00:00 2001 From: Filip Bachul Date: Fri, 31 Mar 2023 23:44:21 +0200 Subject: [PATCH] add geoPoint integration tests --- meilisearch/tests/search/errors.rs | 53 ++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/meilisearch/tests/search/errors.rs b/meilisearch/tests/search/errors.rs index f91fc91db..4766914dd 100644 --- a/meilisearch/tests/search/errors.rs +++ b/meilisearch/tests/search/errors.rs @@ -760,6 +760,59 @@ async fn filter_reserved_attribute_string() { .await; } + +#[actix_rt::test] +async fn filter_reserved_geo_point_array() { + let server = Server::new().await; + let index = server.index("test"); + + index.update_settings(json!({"filterableAttributes": ["title"]})).await; + + let documents = DOCUMENTS.clone(); + index.add_documents(documents, None).await; + index.wait_task(1).await; + + let expected_response = json!({ + "message": "`_geoPoint` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` or `_geoBoundingBox([latitude, longitude], [latitude, longitude])` built-in rules to filter on `_geo` coordinates.\n1:18 _geoPoint = Glass", + "code": "invalid_search_filter", + "type": "invalid_request", + "link": "https://docs.meilisearch.com/errors#invalid_search_filter" + }); + index + .search(json!({"filter": ["_geoPoint = Glass"]}), |response, code| { + assert_eq!(response, expected_response); + assert_eq!(code, 400); + }) + .await; +} + +#[actix_rt::test] +async fn filter_reserved_geo_point_string() { + let server = Server::new().await; + let index = server.index("test"); + + index.update_settings(json!({"filterableAttributes": ["title"]})).await; + + let documents = DOCUMENTS.clone(); + index.add_documents(documents, None).await; + index.wait_task(1).await; + + let expected_response = json!({ + "message": "`_geoPoint` is a reserved keyword and thus can't be used as a filter expression. Use the `_geoRadius(latitude, longitude, distance)` or `_geoBoundingBox([latitude, longitude], [latitude, longitude])` built-in rules to filter on `_geo` coordinates.\n1:18 _geoPoint = Glass", + "code": "invalid_search_filter", + "type": "invalid_request", + "link": "https://docs.meilisearch.com/errors#invalid_search_filter" + }); + index + .search(json!({"filter": "_geoPoint = Glass"}), |response, code| { + assert_eq!(response, expected_response); + assert_eq!(code, 400); + }) + .await; +} + +//_geoPoint + #[actix_rt::test] async fn sort_geo_reserved_attribute() { let server = Server::new().await;