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
Improve locking for synonym index.
Kishore Nallan525b75268c0d
diff --git a/src/synonym_index.cpp b/src/synonym_index.cppindex cfbde766..537423d3 100644--- a/src/synonym_index.cpp+++ b/src/synonym_index.cpp@@ -94,6 +94,7 @@ void SynonymIndex::synonym_reduction_internal(const std::vector<std::string>& tovoid SynonymIndex::synonym_reduction(const std::vector<std::string>& tokens,std::vector<std::vector<std::string>>& results) const {+ std::shared_lock lock(mutex);if(synonym_definitions.empty()) {return;}@@ -104,7 +105,9 @@ void SynonymIndex::synonym_reduction(const std::vector<std::string>& tokens,Option<bool> SynonymIndex::add_synonym(const std::string & collection_name, const synonym_t& synonym,bool write_to_store) {+ std::unique_lock write_lock(mutex);if(synonym_definitions.count(synonym.id) != 0) {+ write_lock.unlock();// first we have to delete existing entries so we can upsertOption<bool> rem_op = remove_synonym(collection_name, synonym.id);if(!rem_op.ok()) {@@ -112,7 +115,7 @@ Option<bool> SynonymIndex::add_synonym(const std::string & collection_name, cons}}- std::unique_lock write_lock(mutex);+ write_lock.lock();synonym_definitions[synonym.id] = synonym;if(!synonym.root.empty()) {