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
Should not crash when an empty index is queried against.
Kishore Nallan57bff89a9725
diff --git a/src/art.cpp b/src/art.cppindex 316bffcf..aae8e286 100644--- a/src/art.cpp+++ b/src/art.cpp@@ -1332,6 +1332,9 @@ int art_fuzzy_search(art_tree *t, const unsigned char *term, const int term_len,art_leaf *l = (art_leaf *) LEAF_RAW(t->root);art_fuzzy_recurse(0, l->key[0], t->root, 0, term, term_len, irow, jrow, min_cost, max_cost, prefix, nodes);} else {+ if(t->root == NULL) {+ return 0;+ }art_fuzzy_children(0, t->root, 0, term, term_len, irow, jrow, min_cost, max_cost, prefix, nodes);}diff --git a/test/collection_test.cpp b/test/collection_test.cppindex aff6a647..659fd9c3 100644--- a/test/collection_test.cpp+++ b/test/collection_test.cpp@@ -847,4 +847,20 @@ TEST_F(CollectionTest, IndexingWithBadData) {ASSERT_STREQ("Rank field `average` must be an integer.", bad_rank_field_op.error().c_str());collectionManager.drop_collection("sample_collection");+}++TEST_F(CollectionTest, EmptyIndexShouldNotCrash) {+ Collection *empty_coll;++ std::vector<field> fields = {field("name", field_types::STRING)};+ facet_fields = {field("tags", field_types::STRING_ARRAY)};+ std::vector<std::string> rank_fields = {"age", "average"};++ empty_coll = collectionManager.get_collection("empty_coll");+ if(empty_coll == nullptr) {+ empty_coll = collectionManager.create_collection("empty_coll", fields, facet_fields, rank_fields, "age");+ }++ nlohmann::json results = empty_coll->search("a", {"name"}, "", {}, rank_fields, 0, 10, FREQUENCY, false);+ ASSERT_EQ(0, results["hits"].size());}\ No newline at end of file