From 358e6545821c23470c99d5875d1fa61e40a004b8 Mon Sep 17 00:00:00 2001 From: Geir Storli Date: Fri, 13 Jan 2023 10:23:02 +0000 Subject: Imported attributes can also represent virtual fields. --- .../matching/index_environment/index_environment_test.cpp | 4 ++-- .../vespa/searchcore/proton/matching/indexenvironment.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'searchcore/src') 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& 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. 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); -- cgit v1.2.3