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

Fix fuzzy search perf regression.

Kishore Nallan27ddda57929a
diff --git a/src/art.cpp b/src/art.cpp
index 5260aac5..0114fcd4 100644
--- a/src/art.cpp
+++ b/src/art.cpp
@@ -1294,7 +1294,7 @@ static inline int fuzzy_search_state(const bool prefix, int key_index, bool last
cost = cost_row[key_len];
}
- int bounded_cost = (cost <= 2) ? (max_cost + 1) : max_cost;
+ int bounded_cost = (max_cost == 0) ? max_cost : (max_cost + 1);
return (cost > bounded_cost) ? -1 : 0;
}
diff --git a/test/art_test.cpp b/test/art_test.cpp
index 0f790c1f..f81a9330 100644
--- a/test/art_test.cpp
+++ b/test/art_test.cpp
@@ -735,7 +735,7 @@ TEST(ArtTest, test_art_fuzzy_search) {
leaves.clear();
art_fuzzy_search(&t, (const unsigned char *) "antisocao", strlen("antisocao"), 0, 2, 10, FREQUENCY, true, nullptr, 0, leaves);
- ASSERT_EQ(6, leaves.size());
+ ASSERT_EQ(7, leaves.size());
long long int timeMillis = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::high_resolution_clock::now() - begin).count();