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
Better guards for top_k truncation.
Kishore Nallanf8e6468a7b2e
diff --git a/src/collection.cpp b/src/collection.cppindex 5d92b5b9..50aa82fe 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -4953,9 +4953,13 @@ void Collection::hide_credential(nlohmann::json& json, const std::string& creden}}Option<bool> Collection::truncate_after_top_k(const string &field_name, size_t k) {+ std::shared_lock slock(mutex);+std::vector<uint32_t> seq_ids;auto op = index->seq_ids_outside_top_k(field_name, k, seq_ids);+ slock.unlock();+if(!op.ok()) {return op;}diff --git a/src/index.cpp b/src/index.cppindex 2f8be825..84e9f6ed 100644--- a/src/index.cpp+++ b/src/index.cpp@@ -6315,9 +6315,10 @@ size_t Index::num_seq_ids() const {Option<bool> Index::seq_ids_outside_top_k(const std::string& field_name, size_t k,std::vector<uint32_t>& outside_seq_ids) {+ std::shared_lock lock(mutex);auto field_it = numerical_index.find(field_name);- if(field_it == sort_index.end()) {+ if(field_it == numerical_index.end()) {return Option<bool>(400, "Field not found in numerical index.");}