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 json object rather than string for convenience.

Kishore Nallan9f788546c854
diff --git a/include/collection.h b/include/collection.h
index 853070ab..3960bd0e 100644
--- a/include/collection.h
+++ b/include/collection.h
@@ -66,7 +66,7 @@ struct override_t {
}
}
- std::string to_json_str() const {
+ nlohmann::json to_json() const {
nlohmann::json override;
override["id"] = id;
override["rule"]["query"] = rule.query;
@@ -88,7 +88,7 @@ struct override_t {
override["excludes"].push_back(exclude);
}
- return override.dump();
+ return override;
}
};
diff --git a/src/collection.cpp b/src/collection.cpp
index a0240816..131daa42 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -932,7 +932,7 @@ Option<uint32_t> Collection::add_override(const override_t & override) {
return Option<uint32_t>(409, "There is already another entry with that `id`.");
}
- bool inserted = store->insert(Collection::get_override_key(name, override.id), override.to_json_str());
+ bool inserted = store->insert(Collection::get_override_key(name, override.id), override.to_json().dump());
if(!inserted) {
return Option<uint32_t>(500, "Error while storing the override on disk.");
}