summaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to 'config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java')
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java45
1 files changed, 42 insertions, 3 deletions
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",
"}"));