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

Don't require query fields for wildcard query.

kishorenc1c398fac7ef4
diff --git a/src/core_api.cpp b/src/core_api.cpp
index 8ba15bc2..18c96629 100644
--- a/src/core_api.cpp
+++ b/src/core_api.cpp
@@ -252,7 +252,7 @@ bool get_search(http_req & req, http_res & res) {
return false;
}
- if(req.params.count(QUERY_BY) == 0) {
+ if(req.params.count(QUERY_BY) == 0 && req.params[QUERY] != "*") {
res.set_400(std::string("Parameter `") + QUERY_BY + "` is required.");
return false;
}
diff --git a/test/collection_test.cpp b/test/collection_test.cpp
index f5c9bf09..dc904ce5 100644
--- a/test/collection_test.cpp
+++ b/test/collection_test.cpp
@@ -455,6 +455,12 @@ TEST_F(CollectionTest, WildcardQuery) {
std::string id = ids.at(i);
ASSERT_STREQ(id.c_str(), result_id.c_str());
}
+
+ // wildcard query should not require a search field
+ results_op = collection->search("*", {}, "", {}, sort_fields, 0, 3, 1, FREQUENCY, false).get();
+ ASSERT_TRUE(results_op.ok());
+ ASSERT_EQ(3, results["hits"].size());
+ ASSERT_EQ(25, results["found"].get<uint32_t>());
}
TEST_F(CollectionTest, PrefixSearching) {