Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Return polygon validation error.
Harpreet Sangarf8159bd2b8b0
diff --git a/src/filter_result_iterator.cpp b/src/filter_result_iterator.cppindex bf826ae4..40c2f936 100644--- a/src/filter_result_iterator.cpp+++ b/src/filter_result_iterator.cpp@@ -901,9 +901,9 @@ void filter_result_iterator_t::init() {S2Error error;if (loop->FindValidationError(&error)) {- LOG(ERROR) << "Query vertex is bad, skipping. Error: " << error;+ status = Option<bool>(400, "Polygon (" + filter_value + ") is invalid: " + error.text());delete loop;- continue;+ break;} else {query_region = loop;}diff --git a/test/collection_sorting_test.cpp b/test/collection_sorting_test.cppindex 95c255e9..abbea30c 100644--- a/test/collection_sorting_test.cpp+++ b/test/collection_sorting_test.cpp@@ -841,8 +841,9 @@ TEST_F(CollectionSortingTest, GeoPointSortingWithExcludeRadius) {res_op = coll1->search("*", {}, "loc: (28.7040592, 77.10249019999999, 28.7040592, ""77.10249019999999, 28.7040592, 77.10249019999999, 28.7040592, 77.10249019999999)",{}, geo_sort_fields, {0}, 10, 1, FREQUENCY);- ASSERT_TRUE(res_op.ok());- ASSERT_EQ(0, res_op.get()["found"].get<size_t>());+ ASSERT_FALSE(res_op.ok());+ ASSERT_EQ("Polygon (28.7040592, 77.10249019999999, 28.7040592, 77.10249019999999, 28.7040592, 77.10249019999999,"+ " 28.7040592, 77.10249019999999) is invalid: Edge 0 is degenerate (duplicate vertex)", res_op.error());// badly formatted exclusion filterdiff --git a/test/geo_filtering_old_test.cpp b/test/geo_filtering_old_test.cppindex f5f37684..61e61b42 100644--- a/test/geo_filtering_old_test.cpp+++ b/test/geo_filtering_old_test.cpp@@ -441,6 +441,18 @@ TEST_F(GeoFilteringOldTest, GeoPolygonFiltering) {ASSERT_EQ(3, results["found"].get<size_t>());ASSERT_EQ(3, results["hits"].size());+ auto search_op = coll1->search("*", {}, "loc: (10, 20, 11, 12, 14, 16, 10, 20, 11, 40)", {}, {}, {0}, 10, 1,+ FREQUENCY);+ ASSERT_FALSE(search_op.ok());+ ASSERT_EQ("Polygon (10, 20, 11, 12, 14, 16, 10, 20, 11, 40) is invalid: Edge 2 has duplicate vertex with edge 4",+ search_op.error());++ search_op = coll1->search("*", {}, "loc: (10, 20, 11, 12, 14, 16, 10, 20)", {}, {}, {0}, 10, 1,+ FREQUENCY);+ ASSERT_FALSE(search_op.ok());+ ASSERT_EQ("Polygon (10, 20, 11, 12, 14, 16, 10, 20) is invalid: Edge 3 is degenerate (duplicate vertex)",+ search_op.error());+collectionManager.drop_collection("coll1");}diff --git a/test/geo_filtering_test.cpp b/test/geo_filtering_test.cppindex 526d44ae..fbb498cb 100644--- a/test/geo_filtering_test.cpp+++ b/test/geo_filtering_test.cpp@@ -477,6 +477,18 @@ TEST_F(GeoFilteringTest, GeoPolygonFiltering) {ASSERT_FALSE(gop.ok());ASSERT_EQ("Unit must be either `km` or `mi`.", gop.error());+ auto search_op = coll1->search("*", {}, "loc: (10, 20, 11, 12, 14, 16, 10, 20, 11, 40)", {}, {}, {0}, 10, 1,+ FREQUENCY);+ ASSERT_FALSE(search_op.ok());+ ASSERT_EQ("Polygon (10, 20, 11, 12, 14, 16, 10, 20, 11, 40) is invalid: Edge 2 has duplicate vertex with edge 4",+ search_op.error());++ search_op = coll1->search("*", {}, "loc: (10, 20, 11, 12, 14, 16, 10, 20)", {}, {}, {0}, 10, 1,+ FREQUENCY);+ ASSERT_FALSE(search_op.ok());+ ASSERT_EQ("Polygon (10, 20, 11, 12, 14, 16, 10, 20) is invalid: Edge 3 is degenerate (duplicate vertex)",+ search_op.error());+collectionManager.drop_collection("coll1");}