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
Export + filter response must have no trailing newline.
Kishore Nallan40ca7e23f668
diff --git a/src/core_api_utils.cpp b/src/core_api_utils.cppindex 2d30844d..7c88adec 100644--- a/src/core_api_utils.cpp+++ b/src/core_api_utils.cpp@@ -102,5 +102,9 @@ Option<bool> stateful_export_docs(export_state_t* export_state, size_t batch_sizdone = done && (current_offset == export_state->index_ids[i].first);}+ if(done && !export_state->res_body->empty()) {+ export_state->res_body->pop_back();+ }+return Option<bool>(true);}\ No newline at end of filediff --git a/test/core_api_utils_test.cpp b/test/core_api_utils_test.cppindex 1bbea863..00de857a 100644--- a/test/core_api_utils_test.cpp+++ b/test/core_api_utils_test.cpp@@ -34,7 +34,6 @@ protected:}};-TEST_F(CoreAPIUtilsTest, StatefulRemoveDocs) {Collection *coll1;@@ -497,3 +496,43 @@ TEST_F(CoreAPIUtilsTest, MultiSearchWithPresetShouldUsePresetForAuth) {ASSERT_EQ("bar", collections[1].collection);ASSERT_EQ(2, embedded_params_vec.size());}++TEST_F(CoreAPIUtilsTest, ExportWithFilter) {+ Collection *coll1;+ std::vector<field> fields = {field("title", field_types::STRING, false),+ field("points", field_types::INT32, false),};++ coll1 = collectionManager.get_collection("coll1").get();+ if(coll1 == nullptr) {+ coll1 = collectionManager.create_collection("coll1", 2, fields, "points").get();+ }++ for(size_t i=0; i<4; i++) {+ nlohmann::json doc;+ doc["id"] = std::to_string(i);+ doc["title"] = "Title " + std::to_string(i);+ doc["points"] = i;+ coll1->add(doc.dump());+ }++ bool done;+ std::string res_body;++ export_state_t export_state;+ coll1->get_filter_ids("points:>=0", export_state.index_ids);+ for(size_t i=0; i<export_state.index_ids.size(); i++) {+ export_state.offsets.push_back(0);+ }++ export_state.collection = coll1;+ export_state.res_body = &res_body;++ stateful_export_docs(&export_state, 2, done);+ ASSERT_FALSE(done);+ ASSERT_EQ('\n', export_state.res_body->back());++ // should not have trailing newline character for the last line+ stateful_export_docs(&export_state, 2, done);+ ASSERT_TRUE(done);+ ASSERT_EQ('}', export_state.res_body->back());+}