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

making changes restricted to group query only

krunal131383b91c917409
diff --git a/include/topster.h b/include/topster.h
index 4dcb184d..b2052a9c 100644
--- a/include/topster.h
+++ b/include/topster.h
@@ -153,12 +153,7 @@ struct Topster {
}*/
int ret = 1;
- const auto& doc_seq_id_exists = (group_doc_seq_ids.find(kv->key) != group_doc_seq_ids.end());
- if(doc_seq_id_exists) {
- ret = 2;
- }
- group_doc_seq_ids.emplace(kv->key);
-
+
bool less_than_min_heap = (size >= MAX_SIZE) && is_smaller(kv, kvs[0]);
size_t heap_op_index = 0;
@@ -170,6 +165,14 @@ struct Topster {
bool SIFT_DOWN = true;
if(distinct) {
+ const auto& doc_seq_id_exists =
+ (group_doc_seq_ids.find(kv->key) != group_doc_seq_ids.end());
+
+ if(doc_seq_id_exists) {
+ ret = 2;
+ }
+ group_doc_seq_ids.emplace(kv->key);
+
// Grouping cannot be a streaming operation, so aggregate the KVs associated with every group.
auto kvs_it = group_kv_map.find(kv->distinct_key);
if(kvs_it != group_kv_map.end()) {