diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2019-10-22 11:39:23 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2019-10-22 11:39:23 +0200 |
commit | 93c7ea2157c14b0b7cb2d689667d44933a21a136 (patch) | |
tree | 6d2d0937c482730fc4aef750fd63d8e1447cbb18 /searchcore | |
parent | 6566f3ff831fff8419ca32c692289b86448ac31c (diff) |
Extend AttributeAspectDelayer to handle matchedattributeelementsfilter
summary map override.
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp | 51 | ||||
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.cpp | 23 |
2 files changed, 68 insertions, 6 deletions
diff --git a/searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp b/searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp index 7141dc7baf7..6e73904e031 100644 --- a/searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_aspect_delayer/attribute_aspect_delayer_test.cpp @@ -101,15 +101,20 @@ AttributesConfig::Attribute make_fa(const AttributesConfig::Attribute &cfg) return attr; } -SummarymapConfig::Override make_attribute_override(const vespalib::string &name) +SummarymapConfig::Override make_attribute_override(const vespalib::string &name, const vespalib::string &source) { SummarymapConfig::Override override; override.field = name; override.command = "attribute"; - override.arguments = name; + override.arguments = source; return override; } +SummarymapConfig::Override make_attribute_override(const vespalib::string &name) +{ + return make_attribute_override(name, name); +} + SummarymapConfig::Override make_geopos_override(const vespalib::string &name) { SummarymapConfig::Override override; @@ -119,11 +124,35 @@ SummarymapConfig::Override make_geopos_override(const vespalib::string &name) return override; } -SummarymapConfig::Override make_attribute_combiner_override(const vespalib::string &name) +SummarymapConfig::Override make_attribute_combiner_override(const vespalib::string &name, const vespalib::string &source) { SummarymapConfig::Override override; override.field = name; override.command = "attributecombiner"; + override.arguments = source; + return override; +} + +SummarymapConfig::Override make_attribute_combiner_override(const vespalib::string &name) +{ + return make_attribute_combiner_override(name, ""); +} + +SummarymapConfig::Override make_matched_attribute_elements_filter_override(const vespalib::string &name, const vespalib::string &source) +{ + SummarymapConfig::Override override; + override.field = name; + override.command = "matchedattributeelementsfilter"; + override.arguments = source; + return override; +} + +SummarymapConfig::Override make_matched_elements_filter_override(const vespalib::string &name, const vespalib::string &source) +{ + SummarymapConfig::Override override; + override.field = name; + override.command = "matchedelementsfilter"; + override.arguments = source; return override; } @@ -243,6 +272,14 @@ TEST_F(DelayerTest, require_that_adding_attribute_aspect_is_delayed_if_field_typ assertSummarymapConfig({make_geopos_override("a")}); } +TEST_F(DelayerTest, require_that_adding_attribute_aspect_is_delayed_if_field_type_is_unchanged_mapped_summary) +{ + addFields({"a"}); + setup(attrCfg({}), smCfg({}), attrCfg({make_int32_sv_cfg()}), sCfg({make_summary_field("a_mapped", "integer")}), smCfg({make_attribute_override("a_mapped", "a")})); + assertAttributeConfig({}); + assertSummarymapConfig({}); +} + TEST_F(DelayerTest, require_that_adding_attribute_is_not_delayed_if_field_type_changed) { setup(attrCfg({}), smCfg({}), attrCfg({make_int32_sv_cfg()}), sCfg({make_summary_field("a", "integer")}), smCfg({make_attribute_override("a")})); @@ -390,6 +427,14 @@ TEST_F(DelayerTest, require_that_removing_attribute_aspect_from_struct_field_is_ assertSummarymapConfig({}); } +TEST_F(DelayerTest, require_that_adding_attribute_aspect_to_struct_field_is_delayed_if_field_type_is_unchanged_with_filtering_docsum) +{ + addFields({"array.a"}); + setup(attrCfg({}), smCfg({}), attrCfg({make_int32_sv_cfg("array.a")}), sCfg({make_summary_field("array", "jsonstring")}), smCfg({make_attribute_combiner_override("array"), make_matched_attribute_elements_filter_override("array_filtered", "array")})); + assertAttributeConfig({}); + assertSummarymapConfig({make_matched_elements_filter_override("array_filtered", "array")}); +} + } GTEST_MAIN_RUN_ALL_TESTS() diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.cpp index 4a3f99d5e8e..a8eed94aab2 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_aspect_delayer.cpp @@ -59,6 +59,14 @@ KnownSummaryFields::KnownSummaryFields(const SummaryConfig &summaryConfig) KnownSummaryFields::~KnownSummaryFields() = default; +vespalib::string source_field(const SummarymapConfig::Override &override) { + if (override.arguments == "") { + return override.field; + } else { + return override.arguments; + } +} + } AttributeAspectDelayer::AttributeAspectDelayer() @@ -134,15 +142,24 @@ handleNewAttributes(const AttributesConfig &oldAttributesConfig, } for (const auto &override : newSummarymapConfig.override) { if (override.command == "attribute") { - auto itr = delayed.find(override.field); + auto itr = delayed.find(source_field(override)); if (itr == delayed.end()) { summarymapConfig.override.emplace_back(override); } } else if (override.command == "attributecombiner") { - auto itr = delayedStruct.find(override.field); + auto itr = delayedStruct.find(source_field(override)); if (itr == delayedStruct.end()) { summarymapConfig.override.emplace_back(override); } + } else if (override.command == "matchedattributeelementsfilter") { + auto itr = delayedStruct.find(source_field(override)); + if (itr == delayedStruct.end()) { + summarymapConfig.override.emplace_back(override); + } else { + SummarymapConfig::Override mutated_override(override); + mutated_override.command = "matchedelementsfilter"; + summarymapConfig.override.emplace_back(mutated_override); + } } else { summarymapConfig.override.emplace_back(override); } @@ -178,7 +195,7 @@ handleOldAttributes(const AttributesConfig &oldAttributesConfig, } for (const auto &override : oldSummarymapConfig.override) { if (override.command == "attribute") { - auto itr = delayed.find(override.field); + auto itr = delayed.find(source_field(override)); if (itr != delayed.end() && knownSummaryFields.known(override.field)) { summarymapConfig.override.emplace_back(override); } |