diff options
author | Arne Juul <arnej@verizonmedia.com> | 2020-05-19 09:57:59 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2020-05-19 09:57:59 +0000 |
commit | 45da1e2df5b46f36bfe480e059d2ce1a6098039b (patch) | |
tree | d8ababf7458f2cdc5d0b052877cff9d193a958ee /searchsummary/src | |
parent | 411eb04bf361b0ce82c134e32f79278c6a63b65d (diff) |
analyse config to detect map of scalar also
Diffstat (limited to 'searchsummary/src')
-rw-r--r-- | searchsummary/src/vespa/searchsummary/docsummary/struct_fields_resolver.cpp | 4 | ||||
-rw-r--r-- | searchsummary/src/vespa/searchsummary/docsummary/struct_fields_resolver.h | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/struct_fields_resolver.cpp b/searchsummary/src/vespa/searchsummary/docsummary/struct_fields_resolver.cpp index c29f0324ce2..749fc2941a6 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/struct_fields_resolver.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/struct_fields_resolver.cpp @@ -22,12 +22,14 @@ StructFieldsResolver::StructFieldsResolver(const vespalib::string& field_name, c _array_fields(), _array_attributes(), _has_map_key(false), + _has_map_value(false), _error(false) { std::vector<const search::attribute::IAttributeVector *> attrs; attr_ctx.getAttributeList(attrs); vespalib::string prefix = field_name + "."; _map_key_attribute = prefix + "key"; + vespalib::string map_value_attribute_name = prefix + "value"; vespalib::string value_prefix = prefix + "value."; for (const auto attr : attrs) { vespalib::string name = attr->getName(); @@ -45,6 +47,8 @@ StructFieldsResolver::StructFieldsResolver(const vespalib::string& field_name, c _array_fields.emplace_back(name.substr(prefix.size())); if (name == _map_key_attribute) { _has_map_key = true; + } else if (name == map_value_attribute_name) { + _has_map_value = true; } } } diff --git a/searchsummary/src/vespa/searchsummary/docsummary/struct_fields_resolver.h b/searchsummary/src/vespa/searchsummary/docsummary/struct_fields_resolver.h index 66d9fd69db4..b88e51a346b 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/struct_fields_resolver.h +++ b/searchsummary/src/vespa/searchsummary/docsummary/struct_fields_resolver.h @@ -26,12 +26,18 @@ private: StringVector _array_fields; StringVector _array_attributes; bool _has_map_key; + bool _has_map_value; bool _error; public: StructFieldsResolver(const vespalib::string& field_name, const search::attribute::IAttributeContext& attr_ctx, bool require_all_struct_fields_as_attributes); ~StructFieldsResolver(); + bool is_map_of_scalar() const { return (_has_map_key && + _has_map_value && + (_array_fields.size() == 2u) && + _map_value_fields.empty()); + } bool is_map_of_struct() const { return !_map_value_fields.empty(); } const vespalib::string& get_map_key_attribute() const { return _map_key_attribute; } const StringVector& get_map_value_fields() const { return _map_value_fields; } |