From 8eb38883b5e68ec60cc7ae460a6e8625d0ef4812 Mon Sep 17 00:00:00 2001 From: ozanarmagan Date: Wed, 27 Sep 2023 13:43:53 +0300 Subject: [PATCH] Use flattened KVs to find KV --- src/index.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/index.cpp b/src/index.cpp index 73a7ba59..321c4790 100644 --- a/src/index.cpp +++ b/src/index.cpp @@ -3220,19 +3220,10 @@ Option Index::search(std::vector& field_query_tokens, cons auto& vec_result = vec_results[res_index]; auto seq_id = vec_result.first; KV* found_kv = nullptr; - if(group_limit == 0) { - auto result_it = topster->kv_map.find(seq_id); - if(result_it != topster->kv_map.end()) { - found_kv = result_it->second; - } - } else { - auto g_topster_it = topster->group_kv_map.find(get_distinct_id(group_by_fields, seq_id)); - if(g_topster_it != topster->group_kv_map.end()) { - auto g_topster = g_topster_it->second; - auto result_it = g_topster->kv_map.find(seq_id); - if(result_it != g_topster->kv_map.end()) { - found_kv = result_it->second; - } + for(auto& kv : kvs) { + if(kv->seq_id == seq_id) { + found_kv = kv; + break; } } if(found_kv) {