aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2023-01-13 16:44:51 +0000
committerGeir Storli <geirst@yahooinc.com>2023-01-13 16:44:51 +0000
commit391cf6ccb2afb755e0f2f47fbf71b00c4f085aa5 (patch)
treed32d93f1884e6d0269f0736215c6ac27f355a28b /searchcore
parentc10ebafc51406aa34e9488edb71c02b4aa709749 (diff)
Only attribute fields can represent virtual fields.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp20
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/indexenvironment.cpp4
2 files changed, 16 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 9acc6eed669..60c60f0a37e 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
@@ -17,6 +17,7 @@ using search::index::schema::DataType;
using vespalib::eval::ConstantValue;
using SAF = Schema::AttributeField;
using SIAF = Schema::ImportedAttributeField;
+using SIF = Schema::IndexField;
const vespalib::string my_expr_ref(
"this is my reference ranking expression.\n"
@@ -157,21 +158,26 @@ Schema::UP schema_with_virtual_fields() {
result->addAttributeField(SAF("person_map.value.year", DataType::INT32, CollectionType::ARRAY));
result->addImportedAttributeField(SAF("int_map.key", DataType::INT32, CollectionType::ARRAY));
result->addImportedAttributeField(SAF("int_map.value", DataType::INT32, CollectionType::ARRAY));
+ // Index fields do not represent virtual fields:
+ result->addIndexField(SIF("url.hostname", DataType::STRING, CollectionType::SINGLE));
+ result->addIndexField(SIF("url.port", DataType::STRING, CollectionType::SINGLE));
return result;
}
TEST_F("virtual fields are extracted in index environment", Fixture(schema_with_virtual_fields()))
{
- ASSERT_EQUAL(9u, f.env.getNumFields());
+ ASSERT_EQUAL(11u, f.env.getNumFields());
TEST_DO(f.assertAttributeField(0, "person_map.key", DataType::INT32, CollectionType::ARRAY));
TEST_DO(f.assertAttributeField(1, "person_map.value.name", DataType::STRING, CollectionType::ARRAY));
TEST_DO(f.assertAttributeField(2, "person_map.value.year", DataType::INT32, CollectionType::ARRAY));
- TEST_DO(f.assertAttributeField(3, "int_map.key", DataType::INT32, CollectionType::ARRAY));
- TEST_DO(f.assertAttributeField(4, "int_map.value", DataType::INT32, CollectionType::ARRAY));
- EXPECT_EQUAL("[documentmetastore]", f.env.getField(5)->name());
- TEST_DO(f.assert_virtual_field(6, "int_map"));
- TEST_DO(f.assert_virtual_field(7, "person_map"));
- TEST_DO(f.assert_virtual_field(8, "person_map.value"));
+ TEST_DO(f.assertField(3, "url.hostname", DataType::STRING, CollectionType::SINGLE));
+ TEST_DO(f.assertField(4, "url.port", DataType::STRING, CollectionType::SINGLE));
+ TEST_DO(f.assertAttributeField(5, "int_map.key", DataType::INT32, CollectionType::ARRAY));
+ TEST_DO(f.assertAttributeField(6, "int_map.value", DataType::INT32, CollectionType::ARRAY));
+ EXPECT_EQUAL("[documentmetastore]", f.env.getField(7)->name());
+ TEST_DO(f.assert_virtual_field(8, "int_map"));
+ TEST_DO(f.assert_virtual_field(9, "person_map"));
+ TEST_DO(f.assert_virtual_field(10, "person_map.value"));
}
TEST_F("require that onnx model config can be obtained", Fixture(buildEmptySchema())) {
diff --git a/searchcore/src/vespa/searchcore/proton/matching/indexenvironment.cpp b/searchcore/src/vespa/searchcore/proton/matching/indexenvironment.cpp
index 6638b238e03..6fceb0db87f 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/indexenvironment.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/indexenvironment.cpp
@@ -32,7 +32,9 @@ extract_virtual_fields(const std::vector<search::fef::FieldInfo>& fields)
// These attributes have '.' in their names, example: my_map.key and my_map.value represent a map<int, string>.
StringSet result;
for (const auto& field : fields) {
- consider_field_for_extraction(field.name(), result);
+ if (field.hasAttribute()) {
+ consider_field_for_extraction(field.name(), result);
+ }
}
return result;
}