Persist optional field value and restore during restart.

This commit is contained in:
kishorenc 2020-03-06 07:38:22 +05:30
parent 6c8e62a61b
commit 1ab25b9d16
2 changed files with 4 additions and 1 deletions

View File

@ -22,6 +22,7 @@ namespace fields {
static const std::string name = "name";
static const std::string type = "type";
static const std::string facet = "facet";
static const std::string optional = "facet";
}
struct field {

View File

@ -16,7 +16,8 @@ Collection* CollectionManager::init_collection(const nlohmann::json & collection
nlohmann::json fields_map = collection_meta[COLLECTION_SEARCH_FIELDS_KEY];
for (nlohmann::json::iterator it = fields_map.begin(); it != fields_map.end(); ++it) {
fields.push_back({it.value()[fields::name], it.value()[fields::type], it.value()[fields::facet]});
fields.push_back({it.value()[fields::name], it.value()[fields::type],
it.value()[fields::facet], it.value()[fields::optional]});
}
std::string default_sorting_field = collection_meta[COLLECTION_DEFAULT_SORTING_FIELD_KEY].get<std::string>();
@ -218,6 +219,7 @@ Option<Collection*> CollectionManager::create_collection(const std::string name,
field_val[fields::name] = field.name;
field_val[fields::type] = field.type;
field_val[fields::facet] = field.facet;
field_val[fields::optional] = field.optional;
fields_json.push_back(field_val);
if(field.name == default_sorting_field && !(field.type == field_types::INT32 ||