aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-02-08 12:24:26 +0100
committerJon Bratseth <bratseth@gmail.com>2022-02-08 12:24:26 +0100
commitba895eb72333231b976274e5f68e2ce80c7c3bbd (patch)
treea7f11f020f7acda71edd5f2dfba9ad745beef975 /container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java
parentad3b8a05ccc2d0ece6f6cf93e9347fbaa84e1476 (diff)
Handle query profile values in type checking
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java')
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java24
1 files changed, 18 insertions, 6 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java
index 90d9eab687d..878a937ec67 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileProperties.java
@@ -116,18 +116,30 @@ public class QueryProfileProperties extends Properties {
FieldDescription fieldDescription = type.getField(localName);
if (fieldDescription == null && type.isStrict())
throw new IllegalInputException("'" + localName + "' is not declared in " + type + ", and the type is strict");
-
// TODO: In addition to strictness, check legality along the way
if (fieldDescription != null) {
if (i == name.size() - 1) { // at the end of the path, check the assignment type
- value = fieldDescription.getType().convertFrom(value, new ConversionContext(localName,
- profile.getRegistry(),
- embedder,
- context));
- if (value == null)
+ var conversionContext = new ConversionContext(localName, profile.getRegistry(), embedder, context);
+ var convertedValue = fieldDescription.getType().convertFrom(value, conversionContext);
+ if (convertedValue == null
+ && fieldDescription.getType() instanceof QueryProfileFieldType
+ && ((QueryProfileFieldType) fieldDescription.getType()).getQueryProfileType() != null) {
+ // Try the value of the query profile itself instead
+ var queryProfileValueDescription = ((QueryProfileFieldType) fieldDescription.getType()).getQueryProfileType().getField("");
+ if (queryProfileValueDescription != null) {
+ convertedValue = queryProfileValueDescription.getType().convertFrom(value, conversionContext);
+ if (convertedValue == null)
+ throw new IllegalInputException("'" + value + "' is neither a " +
+ fieldDescription.getType().toInstanceDescription() + " nor a " +
+ queryProfileValueDescription.getType().toInstanceDescription());
+ }
+ }
+ else if (convertedValue == null)
throw new IllegalInputException("'" + value + "' is not a " +
fieldDescription.getType().toInstanceDescription());
+
+ value = convertedValue;
}
else if (fieldDescription.getType() instanceof QueryProfileFieldType) {
// If a type is specified, use that instead of the type implied by the name