diff --git a/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java b/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java index 70942372d2b..6f9071d1d6b 100644 --- a/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java +++ b/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java @@ -110,10 +110,11 @@ static private boolean isPrimitiveAttribute(AttributesConfig.Attribute attribute datatype == AttributesConfig.Attribute.Datatype.DOUBLE; } - static private boolean isSingleRawOrBoolAttribute(AttributesConfig.Attribute attribute) { + static private boolean isSingleRawBoolOrReferenceAttribute(AttributesConfig.Attribute attribute) { var datatype = attribute.datatype(); return (datatype == AttributesConfig.Attribute.Datatype.RAW || - datatype == AttributesConfig.Attribute.Datatype.BOOL) && + datatype == AttributesConfig.Attribute.Datatype.BOOL || + datatype == AttributesConfig.Attribute.Datatype.REFERENCE) && attribute.collectiontype() == AttributesConfig.Attribute.Collectiontype.SINGLE; } @@ -122,7 +123,7 @@ private void verifyHasAttribute(String attributeName, boolean isMapLookup) { if (attribute == null) { throw new UnavailableAttributeException(clusterName, attributeName); } - if (isPrimitiveAttribute(attribute) || (!isMapLookup && isSingleRawOrBoolAttribute(attribute))) { + if (isPrimitiveAttribute(attribute) || (!isMapLookup && isSingleRawBoolOrReferenceAttribute(attribute))) { return; } throw new IllegalInputException("Grouping request references attribute '" + diff --git a/container-search/src/test/java/com/yahoo/search/grouping/GroupingValidatorTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/GroupingValidatorTestCase.java index de3254d85ad..04006f7ecde 100644 --- a/container-search/src/test/java/com/yahoo/search/grouping/GroupingValidatorTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/grouping/GroupingValidatorTestCase.java @@ -178,8 +178,8 @@ void predicate_attribute_throws() { } @Test - void reference_attribute_throws() { - unsupported_attribute_type_throws("reference", AttributesConfig.Attribute.Datatype.REFERENCE, "reference"); + void reference_attribute_is_ok() { + validate_attribute_type("reference", AttributesConfig.Attribute.Datatype.REFERENCE); } @Test