Skip to content

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

Allow even a single value with square bracket notation.

Harpreet Sangar43047f58f60d
diff --git a/src/filter.cpp b/src/filter.cpp
index f14edb60..c152d77f 100644
--- a/src/filter.cpp
+++ b/src/filter.cpp
@@ -182,7 +182,7 @@ Option<bool> filter::parse_geopoint_filter_value(string& raw_value, const string
}
filter_exp.comparators.push_back(LESS_THAN_EQUALS);
- bool is_multivalued = open_parenthesis_count > 1;
+ bool is_multivalued = raw_value[0] == '[';
size_t i = is_multivalued;
for (auto j = 0; j < open_parenthesis_count; j++) {
diff --git a/test/geo_filtering_test.cpp b/test/geo_filtering_test.cpp
index f8c187f9..0cd45d69 100644
--- a/test/geo_filtering_test.cpp
+++ b/test/geo_filtering_test.cpp
@@ -87,6 +87,7 @@ TEST_F(GeoFilteringTest, GeoPointFiltering) {
ASSERT_EQ("1", results["hits"][0]["document"]["id"].get<std::string>());
+ // Multiple queries can be clubbed using square brackets [ filterA, filterB, ... ]
results = coll1->search("*", {}, "loc: [([48.90615, 2.34358], radius: 1 km), ([48.8462, 2.34515], radius: 1 km)]",
{}, {}, {0}, 10, 1, FREQUENCY).get();
@@ -94,7 +95,7 @@ TEST_F(GeoFilteringTest, GeoPointFiltering) {
// pick location close to none of the spots
results = coll1->search("*",
- {}, "loc: ([48.910544830985785, 2.337218333651177], radius: 2 km)",
+ {}, "loc: [([48.910544830985785, 2.337218333651177], radius: 2 km)]",
{}, {}, {0}, 10, 1, FREQUENCY).get();
ASSERT_EQ(0, results["found"].get<size_t>());