Skip to content

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

return store value in collection_schema response (#1823)

Krunal Gandhi2f1dab72dd59
diff --git a/src/collection.cpp b/src/collection.cpp
index f658e359..de209e15 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -519,6 +519,7 @@ nlohmann::json Collection::get_summary_json() const {
field_json[fields::infix] = coll_field.infix;
field_json[fields::locale] = coll_field.locale;
field_json[fields::stem] = coll_field.stem;
+ field_json[fields::store] = coll_field.store;
if(coll_field.range_index) {
field_json[fields::range_index] = coll_field.range_index;
diff --git a/test/core_api_utils_test.cpp b/test/core_api_utils_test.cpp
index 1098aa9e..f6624313 100644
--- a/test/core_api_utils_test.cpp
+++ b/test/core_api_utils_test.cpp
@@ -1644,6 +1644,7 @@ TEST_F(CoreAPIUtilsTest, CollectionsPagination) {
"optional":false,
"sort":false,
"stem":false,
+ "store": true,
"type":"string"
}
],
@@ -2152,4 +2153,64 @@ TEST_F(CoreAPIUtilsTest, DocumentGetIncludeExcludeFields) {
ASSERT_TRUE(resp.contains("title"));
ASSERT_TRUE(resp.contains("rating"));
ASSERT_FALSE(resp.contains("id"));
+}
+
+TEST_F(CoreAPIUtilsTest, CollectionSchemaResponseWithStoreValue) {
+ auto schema = R"({
+ "name": "collection3",
+ "enable_nested_fields": true,
+ "fields": [
+ {"name": "title", "type": "string", "locale": "en", "store":false},
+ {"name": "points", "type": "int32"}
+ ],
+ "default_sorting_field": "points"
+ })"_json;
+
+ auto op = collectionManager.create_collection(schema);
+ ASSERT_TRUE(op.ok());
+
+ std::shared_ptr<http_req> req = std::make_shared<http_req>();
+ std::shared_ptr<http_res> res = std::make_shared<http_res>(nullptr);
+
+ req->params["collection"] = "collection3";
+ ASSERT_TRUE(get_collection_summary(req, res));
+
+ auto res_json = nlohmann::json::parse(res->body);
+
+ auto expected_json = R"({
+ "default_sorting_field":"points",
+ "enable_nested_fields":true,
+ "fields":[
+ {
+ "facet":false,
+ "index":true,
+ "infix":false,
+ "locale":"en",
+ "name":"title",
+ "optional":false,
+ "sort":false,
+ "stem":false,
+ "store":false,
+ "type":"string"
+ },
+ {
+ "facet":false,
+ "index":true,
+ "infix":false,
+ "locale":"",
+ "name":"points",
+ "optional":false,
+ "sort":true,
+ "stem":false,
+ "store":true,
+ "type":"int32"
+ }],
+ "name":"collection3",
+ "num_documents":0,
+ "symbols_to_index":[],
+ "token_separators":[]
+ })"_json;
+
+ expected_json["created_at"] = res_json["created_at"];
+ ASSERT_EQ(expected_json, res_json);
}
\ No newline at end of file