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

Fix `num_documents` & `facet` fields not returned when creating a new collection.

Kishore Nallan6cdbb29d4a5e
diff --git a/include/option.h b/include/option.h
index e1fb135e..94b2d899 100644
--- a/include/option.h
+++ b/include/option.h
@@ -32,7 +32,7 @@ public:
return is_ok;
}
- T get() {
+ T get() const {
return value;
}
diff --git a/src/api.cpp b/src/api.cpp
index eddf1689..7835276d 100644
--- a/src/api.cpp
+++ b/src/api.cpp
@@ -120,8 +120,15 @@ void post_create_collection(http_req & req, http_res & res) {
}
const std::string & default_sorting_field = req_json[DEFAULT_SORTING_FIELD].get<std::string>();
- collectionManager.create_collection(req_json["name"], fields, default_sorting_field);
- res.send_201(req.body);
+ const Option<Collection*> & collection_op =
+ collectionManager.create_collection(req_json["name"], fields, default_sorting_field);
+
+ if(collection_op.ok()) {
+ nlohmann::json json_response = collection_summary_json(collection_op.get());
+ return res.send_201(json_response.dump());
+ }
+
+ return res.send(collection_op.code(), collection_op.error());
}
void del_drop_collection(http_req & req, http_res & res) {