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

Use topster hashmap if not grouping

ozanarmagane7d6b5673681
diff --git a/src/index.cpp b/src/index.cpp
index 65be8edc..ba57844c 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -3220,10 +3220,17 @@ Option<bool> Index::search(std::vector<query_tokens_t>& field_query_tokens, cons
auto& vec_result = vec_results[res_index];
auto seq_id = vec_result.first;
KV* found_kv = nullptr;
- for(auto& kv : kvs) {
- if(kv->key == seq_id) {
- found_kv = kv;
- break;
+ if(group_limit != 0) {
+ for(auto& kv : kvs) {
+ if(kv->key == seq_id) {
+ found_kv = kv;
+ break;
+ }
+ }
+ } else {
+ auto result_it = topster->kv_map.find(seq_id);
+ if(result_it != topster->kv_map.end()) {
+ found_kv = result_it->second;
}
}
if(found_kv) {