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

intialize iterator per facet field

krunalc7c099b8b4b4
diff --git a/src/index.cpp b/src/index.cpp
index 962a307f..a5882ee4 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -1289,9 +1289,6 @@ void Index::do_facets(std::vector<facet> & facets, facet_query_t & facet_query,
}
std::vector<group_by_field_it_t> group_by_field_it_vec;
- if (group_limit != 0) {
- group_by_field_it_vec = get_group_by_field_iterators(group_by_fields);
- }
size_t total_docs = seq_ids->num_ids();
// assumed that facet fields have already been validated upstream
@@ -1369,6 +1366,10 @@ void Index::do_facets(std::vector<facet> & facets, facet_query_t & facet_query,
posting_list_t::iterator_t facet_index_it = facet_index->new_iterator();
std::vector<uint32_t> facet_hashes;
+ if (group_limit != 0) {
+ group_by_field_it_vec = get_group_by_field_iterators(group_by_fields);
+ }
+
for(size_t i = 0; i < results_size; i++) {
// if sampling is enabled, we will skip a portion of the results to speed up things
if(estimate_facets) {
@@ -1464,10 +1465,6 @@ void Index::do_facets(std::vector<facet> & facets, facet_query_t & facet_query,
}
}
}
- //reset iterator position
- for(auto& kv : group_by_field_it_vec) {
- kv.it.set_index(0);
- }
}
}