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

Minor refactor.

Kishore Nallanc39fd39f2dc5
diff --git a/TODO.md b/TODO.md
index db07025b..4d8e36b1 100644
--- a/TODO.md
+++ b/TODO.md
@@ -96,6 +96,7 @@
- ~~gzip compress responses~~
- ~~Have a LOG(ERROR) level~~
- ~~Handle SIGTERM which is sent when process is killed~~
+- Log operations
- Parameterize replica's MAX_UPDATES_TO_SEND
- NOT operator support
- > INT32_MAX validation for float field
diff --git a/src/index.cpp b/src/index.cpp
index 429260ad..12ce2177 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -628,7 +628,6 @@ void Index::search_field(std::string & query, const std::string & field, uint32_
StringUtils::split(query, tokens, " ");
const size_t max_cost = (num_typos < 0 || num_typos > 2) ? 2 : num_typos;
- const size_t max_results = Index::SEARCH_LIMIT_NUM;
size_t total_results = topster.size;
@@ -736,9 +735,9 @@ void Index::search_field(std::string & query, const std::string & field, uint32_
// If all tokens were found, go ahead and search for candidates with what we have so far
search_candidates(filter_ids, filter_ids_length, facets, sort_fields, token_candidates_vec,
token_order, searched_queries, topster, total_results, all_result_ids, all_result_ids_len,
- max_results, prefix);
+ Index::SEARCH_LIMIT_NUM, prefix);
- if (total_results >= max_results) {
+ if (total_results >= Index::SEARCH_LIMIT_NUM) {
// If we don't find enough results, we continue outerloop (looking at tokens with greater cost)
break;
}
@@ -748,7 +747,7 @@ void Index::search_field(std::string & query, const std::string & field, uint32_
}
// When there are not enough overall results and atleast one token has results
- if(topster.size < max_results && token_to_count.size() > 1) {
+ if(topster.size < Index::SEARCH_LIMIT_NUM && token_to_count.size() > 1) {
// Drop token with least hits and try searching again
std::string truncated_query;