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
Return 409 status code when document with given ID already exists.
Kishore Nallanc16513005b31
diff --git a/src/collection.cpp b/src/collection.cppindex f8439897..38c65756 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -86,7 +86,7 @@ Option<nlohmann::json> Collection::add(const std::string & json_str) {// we need to check if document ID already exists before attempting to indexif(doc_option.ok()) {- return Option<nlohmann::json>(400, std::string("A document with id ") + doc_id + " already exists.");+ return Option<nlohmann::json>(409, std::string("A document with id ") + doc_id + " already exists.");}const Option<uint32_t> & index_memory_op = index_in_memory(document, seq_id);diff --git a/test/collection_test.cpp b/test/collection_test.cppindex 8f0501ca..60a5ede0 100644--- a/test/collection_test.cpp+++ b/test/collection_test.cpp@@ -1485,7 +1485,7 @@ TEST_F(CollectionTest, IndexingWithBadData) {ASSERT_TRUE(add_op.ok());add_op = sample_collection->add(doc);ASSERT_FALSE(add_op.ok());- ASSERT_EQ(400, add_op.code());+ ASSERT_EQ(409, add_op.code());ASSERT_STREQ("A document with id 100 already exists.", add_op.error().c_str());collectionManager.drop_collection("sample_collection");