diff options
Diffstat (limited to 'config-model/src/test')
4 files changed, 52 insertions, 4 deletions
diff --git a/config-model/src/test/derived/importedfields/child.sd b/config-model/src/test/derived/importedfields/child.sd index d541ba8fc8c..95fe44d333a 100644 --- a/config-model/src/test/derived/importedfields/child.sd +++ b/config-model/src/test/derived/importedfields/child.sd @@ -23,5 +23,9 @@ search child { summary my_int_array_field type array<int> {} summary my_int_wset_field type weightedset<int> {} summary my_ancient_int_field type int {} + summary my_filtered_int_array_field type array<int> { + source: my_int_array_field + matched-elements-only + } } } diff --git a/config-model/src/test/derived/importedfields/summary.cfg b/config-model/src/test/derived/importedfields/summary.cfg index 68ad270a314..f95949cfa62 100644 --- a/config-model/src/test/derived/importedfields/summary.cfg +++ b/config-model/src/test/derived/importedfields/summary.cfg @@ -9,7 +9,7 @@ classes[].fields[].name "summaryfeatures" classes[].fields[].type "featuredata" classes[].fields[].name "documentid" classes[].fields[].type "longstring" -classes[].id 1660388492 +classes[].id 159551552 classes[].name "mysummary" classes[].fields[].name "a_ref" classes[].fields[].type "longstring" @@ -25,6 +25,8 @@ classes[].fields[].name "my_int_wset_field" classes[].fields[].type "jsonstring" classes[].fields[].name "my_ancient_int_field" classes[].fields[].type "integer" +classes[].fields[].name "my_filtered_int_array_field" +classes[].fields[].type "jsonstring" classes[].fields[].name "rankfeatures" classes[].fields[].type "featuredata" classes[].fields[].name "summaryfeatures" diff --git a/config-model/src/test/derived/importedfields/summarymap.cfg b/config-model/src/test/derived/importedfields/summarymap.cfg index d038e2313a8..03ae5e2676e 100644 --- a/config-model/src/test/derived/importedfields/summarymap.cfg +++ b/config-model/src/test/derived/importedfields/summarymap.cfg @@ -14,6 +14,9 @@ override[].arguments "my_int_wset_field" override[].field "my_ancient_int_field" override[].command "attribute" override[].arguments "my_ancient_int_field" +override[].field "my_filtered_int_array_field" +override[].command "matchedattributeelementsfilter" +override[].arguments "my_int_array_field" override[].field "rankfeatures" override[].command "rankfeatures" override[].arguments "" diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java index 3b6918c04ae..0ef696df6cf 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java @@ -75,7 +75,7 @@ public class MatchedElementsOnlyResolverTestCase { } @Test - public void explicit_summary_field_can_use_filter_transform_with_reference_to_source_field() throws ParseException { + public void explicit_complex_summary_field_can_use_filter_transform_with_reference_to_source_field() throws ParseException { String documentSummary = joinLines("document-summary my_summary {", " summary my_filter_field type map<string, string> {", " source: my_field", @@ -108,12 +108,51 @@ public class MatchedElementsOnlyResolverTestCase { } @Test + public void primitive_array_attribute_field_gets_attribute_transform() throws ParseException { + assertSummaryField(joinLines("field my_field type array<string> {", + " indexing: attribute | summary", + " summary: matched-elements-only", + "}"), + "my_field", SummaryTransform.MATCHED_ATTRIBUTE_ELEMENTS_FILTER); + } + + @Test + public void primitive_weighted_set_attribute_field_gets_attribute_transform() throws ParseException { + assertSummaryField(joinLines("field my_field type weightedset<string> {", + " indexing: attribute | summary", + " summary: matched-elements-only", + "}"), + "my_field", SummaryTransform.MATCHED_ATTRIBUTE_ELEMENTS_FILTER); + } + + @Test + public void explicit_summary_field_can_use_filter_transform_with_reference_to_attribute_source_field() throws ParseException { + String documentSummary = joinLines("document-summary my_summary {", + " summary my_filter_field type array<string> {", + " source: my_field", + " matched-elements-only", + " }", + "}"); + + var search = buildSearch(joinLines("field my_field type array<string> {", + " indexing: attribute | summary", + "}"), + documentSummary); + assertSummaryField(search.getSummaryField("my_filter_field"), + SummaryTransform.MATCHED_ATTRIBUTE_ELEMENTS_FILTER, "my_field"); + assertSummaryField(search.getSummaryField("my_field"), + SummaryTransform.ATTRIBUTE, "my_field"); + } + + @Test public void unsupported_field_type_throws() throws ParseException { exceptionRule.expect(IllegalArgumentException.class); exceptionRule.expectMessage("For search 'test', document summary 'default', summary field 'my_field': " + "'matched-elements-only' is not supported for this field type. " + - "Supported field types are array of simple struct, map of primitive type to simple struct, and map of primitive type to primitive type"); - buildSearch(joinLines("field my_field type string {", + "Supported field types are: array attribute, weighted set attribute, " + + "array of simple struct, map of primitive type to simple struct, " + + "and map of primitive type to primitive type"); + buildSearch(joinLines("field my_field type array<string> {", " indexing: summary", " summary: matched-elements-only", "}")); |