diff options
author | Geir Storli <geirst@yahooinc.com> | 2023-01-13 10:23:02 +0000 |
---|---|---|
committer | Geir Storli <geirst@yahooinc.com> | 2023-01-13 10:23:02 +0000 |
commit | 358e6545821c23470c99d5875d1fa61e40a004b8 (patch) | |
tree | 25bf9ad2b578ccfe7a1052a126db16e3e70b1d71 /searchcore | |
parent | 697182201491bf75fdd8e5a630208ae8b374b4fd (diff) |
Imported attributes can also represent virtual fields.
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp | 4 | ||||
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/matching/indexenvironment.cpp | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp b/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp index 404dc5d42e9..9acc6eed669 100644 --- a/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp +++ b/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp @@ -155,8 +155,8 @@ Schema::UP schema_with_virtual_fields() { result->addAttributeField(SAF("person_map.key", DataType::INT32, CollectionType::ARRAY)); result->addAttributeField(SAF("person_map.value.name", DataType::STRING, CollectionType::ARRAY)); result->addAttributeField(SAF("person_map.value.year", DataType::INT32, CollectionType::ARRAY)); - result->addAttributeField(SAF("int_map.key", DataType::INT32, CollectionType::ARRAY)); - result->addAttributeField(SAF("int_map.value", DataType::INT32, CollectionType::ARRAY)); + result->addImportedAttributeField(SAF("int_map.key", DataType::INT32, CollectionType::ARRAY)); + result->addImportedAttributeField(SAF("int_map.value", DataType::INT32, CollectionType::ARRAY)); return result; } diff --git a/searchcore/src/vespa/searchcore/proton/matching/indexenvironment.cpp b/searchcore/src/vespa/searchcore/proton/matching/indexenvironment.cpp index 488430b7fe2..6638b238e03 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/indexenvironment.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/indexenvironment.cpp @@ -25,14 +25,14 @@ consider_field_for_extraction(const vespalib::string& field_name, StringSet& vir } StringSet -extract_virtual_fields(const search::index::Schema& schema) +extract_virtual_fields(const std::vector<search::fef::FieldInfo>& fields) { - // Fields that are represented by a set of attributes in the backend are considered virtual fields. + // Fields that are represented by a set of attributes (normal and imported) in the backend are considered virtual fields. // Currently, this is map or array of struct fields (from the SD file) with struct-field attributes. + // These attributes have '.' in their names, example: my_map.key and my_map.value represent a map<int, string>. StringSet result; - for (uint32_t i = 0; i < schema.getNumAttributeFields(); ++i) { - const auto& field = schema.getAttributeField(i); - consider_field_for_extraction(field.getName(), result); + for (const auto& field : fields) { + consider_field_for_extraction(field.name(), result); } return result; } @@ -82,7 +82,7 @@ IndexEnvironment::extractFields(const search::index::Schema &schema) fieldInfo.setFilter(true); insertField(fieldInfo); } - for (const auto& field : extract_virtual_fields(schema)) { + for (const auto& field : extract_virtual_fields(_fields)) { FieldInfo info(FieldType::VIRTUAL, FieldInfo::CollectionType::ARRAY, field, _fields.size()); info.set_data_type(FieldInfo::DataType::COMBINED); insertField(info); |