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

Add test case.

Harpreet Sangar06b46ab96100
diff --git a/src/numeric_range_trie.cpp b/src/numeric_range_trie.cpp
index 50cf3315..53090b5d 100644
--- a/src/numeric_range_trie.cpp
+++ b/src/numeric_range_trie.cpp
@@ -57,7 +57,10 @@ void NumericTrie::search_greater(const int32_t& value, const bool& inclusive, ui
if (value >= 0) {
uint32_t* positive_ids = nullptr;
- positive_trie->search_greater(inclusive ? value : value + 1, positive_ids, ids_length);
+ uint32_t positive_ids_length = 0;
+ positive_trie->search_greater(inclusive ? value : value + 1, positive_ids, positive_ids_length);
+
+ ids_length = positive_ids_length;
ids = positive_ids;
} else {
// Have to combine the results of >value from negative_trie and all the ids in positive_trie
diff --git a/test/numeric_range_trie_test.cpp b/test/numeric_range_trie_test.cpp
index 690209a8..bc47f35a 100644
--- a/test/numeric_range_trie_test.cpp
+++ b/test/numeric_range_trie_test.cpp
@@ -188,4 +188,9 @@ TEST_F(NumericRangeTrieTest, SearchGreater) {
for (uint32_t i = 5, j = 0; i < pairs.size(); i++, j++) {
ASSERT_EQ(pairs[i].second, ids[j]);
}
+
+ trie->search_greater(100000, false, ids, ids_length);
+ ids_guard.reset(ids);
+
+ ASSERT_EQ(0, ids_length);
}