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
Increment seq id only for valid docs during indexing.
kishorenc9716aa5b5506
diff --git a/src/collection.cpp b/src/collection.cppindex 4abfba74..db4e802a 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -111,21 +111,23 @@ Option<uint32_t> Collection::to_doc(const std::string & json_str, nlohmann::jsonreturn Option<uint32_t>(400, "Bad JSON: not a properly formed document.");}- uint32_t seq_id = get_next_seq_id();- std::string seq_id_str = std::to_string(seq_id);-if(document.count("id") == 0) {- document["id"] = seq_id_str;- } else if(!document["id"].is_string()) {- return Option<uint32_t>(400, "Document's `id` field should be a string.");- }+ uint32_t seq_id = get_next_seq_id();+ document["id"] = std::to_string(seq_id);+ return Option<uint32_t>(seq_id);+ } else {+ if(!document["id"].is_string()) {+ return Option<uint32_t>(400, "Document's `id` field should be a string.");+ }- const std::string& doc_id = document["id"];- if(doc_exists(doc_id)) {- return Option<uint32_t>(409, std::string("A document with id ") + doc_id + " already exists.");- }+ const std::string& doc_id = document["id"];+ if(doc_exists(doc_id)) {+ return Option<uint32_t>(409, std::string("A document with id ") + doc_id + " already exists.");+ }- return Option<uint32_t>(seq_id);+ uint32_t seq_id = get_next_seq_id();+ return Option<uint32_t>(seq_id);+ }}nlohmann::json Collection::get_summary_json() {