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
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Remove pre-sorting of index topsters.
kishorence5fa36a0b000
diff --git a/src/collection.cpp b/src/collection.cppindex a524aee2..b5260096 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -1180,22 +1180,19 @@ void Collection::populate_result_kvs(Topster *topster, std::vector<std::vector<K}}-void Collection::aggregate_topster(size_t query_index, Topster &topster, Topster *index_topster) const {+void Collection::aggregate_topster(size_t query_index, Topster& agg_topster, Topster* index_topster) const {if(index_topster->distinct) {for(auto &group_topster_entry: index_topster->group_kv_map) {Topster* group_topster = group_topster_entry.second;- const std::vector<KV*> group_kvs(group_topster->kvs, group_topster->kvs+group_topster->size);- for(KV* kv: group_kvs) {- kv->query_index += query_index;- topster.add(kv);+ for(const auto& map_kv: group_topster->kv_map) {+ map_kv.second->query_index += query_index;+ agg_topster.add(map_kv.second);}}-} else {- for(uint32_t t = 0; t < index_topster->size; t++) {- KV* kv = index_topster->getKV(t);- kv->query_index += query_index;- topster.add(kv);+ for(const auto& map_kv: index_topster->kv_map) {+ map_kv.second->query_index += query_index;+ agg_topster.add(map_kv.second);}}}diff --git a/src/index.cpp b/src/index.cppindex 65d2d6eb..de895219 100644--- a/src/index.cpp+++ b/src/index.cpp@@ -1555,10 +1555,6 @@ void Index::search(Option<uint32_t> & outcome,do_facets(facets, facet_query, all_result_ids, all_result_ids_len);do_facets(facets, facet_query, &included_ids[0], included_ids.size());- // must be sorted before iterated upon to remove "empty" array entries- topster->sort();- curated_topster->sort();-all_result_ids_len += curated_topster->size;delete [] filter_ids;diff --git a/test/collection_test.cpp b/test/collection_test.cppindex f35e6beb..fa783292 100644--- a/test/collection_test.cpp+++ b/test/collection_test.cpp@@ -2698,11 +2698,13 @@ TEST_F(CollectionTest, MultiFieldMatchRanking) {auto results = coll1->search("taylor swift style",{"artist", "title"}, "", {}, {}, 0, 3, 1, FREQUENCY, true, 5).get();- LOG(INFO) << results;-ASSERT_EQ(10, results["found"].get<size_t>());ASSERT_EQ(3, results["hits"].size());+ ASSERT_STREQ("0", results["hits"][0]["document"]["id"].get<std::string>().c_str());+ ASSERT_STREQ("9", results["hits"][1]["document"]["id"].get<std::string>().c_str());+ ASSERT_STREQ("8", results["hits"][2]["document"]["id"].get<std::string>().c_str());+collectionManager.drop_collection("coll1");}