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
Fix document store flag bug (#1628)
Ozan Armağan748e3b625106
diff --git a/src/collection.cpp b/src/collection.cppindex 3cff1c81..b2fdc34e 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -778,7 +778,11 @@ void Collection::batch_index(std::vector<index_record>& index_records, std::vect} else {// remove flattened field values before storing on diskremove_flat_fields(index_record.doc);-+ for(auto& field: fields) {+ if(!field.store) {+ index_record.doc.erase(field.name);+ }+ }const std::string& seq_id_str = std::to_string(index_record.seq_id);const std::string& serialized_json = index_record.doc.dump(-1, ' ', false,nlohmann::detail::error_handler_t::ignore);diff --git a/test/collection_specific_more_test.cpp b/test/collection_specific_more_test.cppindex d29e6112..3f696605 100644--- a/test/collection_specific_more_test.cpp+++ b/test/collection_specific_more_test.cpp@@ -2985,4 +2985,31 @@ TEST_F(CollectionSpecificMoreTest, TestStemmingWithSynonym) {auto res = coll_stem->search("making", {"word"}, "", {}, {}, {0}, 10, 1, FREQUENCY, {true}, 0).get();ASSERT_EQ(1, res["hits"].size());ASSERT_EQ("foobar", res["hits"][0]["document"]["word"].get<std::string>());+}++TEST_F(CollectionSpecificMoreTest, TestFieldStore) {+ nlohmann::json schema = R"({+ "name": "words",+ "fields": [+ {"name": "word_to_store", "type": "string", "store": true },+ {"name": "word_not_to_store", "type": "string", "store": false }+ ]+ })"_json;++ auto coll_store_res = collectionManager.create_collection(schema);+ ASSERT_TRUE(coll_store_res.ok());++ auto coll_store = coll_store_res.get();++ nlohmann::json doc;+ doc["word_to_store"] = "store";+ doc["word_not_to_store"] = "not store";+ ASSERT_TRUE(coll_store->add(doc.dump()).ok());++ auto res = coll_store->search("*", {}, {}, {}, {}, {0}, 10, 1, FREQUENCY, {false}, 1);+ ASSERT_TRUE(res.ok());++ ASSERT_EQ(1, res.get()["hits"].size());+ ASSERT_EQ("store", res.get()["hits"][0]["document"]["word_to_store"].get<std::string>());+ ASSERT_TRUE(res.get()["hits"][0]["document"].count("word_not_to_store") == 0);}\ No newline at end of file