mirror of
https://github.com/typesense/typesense.git
synced 2025-05-19 05:08:43 +08:00
Persist optional field value and restore during restart.
This commit is contained in:
parent
6c8e62a61b
commit
1ab25b9d16
@ -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 {
|
||||
|
@ -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 ||
|
||||
|
Loading…
x
Reference in New Issue
Block a user