summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/searchdefinition/processing
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-02-25 10:04:38 +0100
committerJon Bratseth <bratseth@gmail.com>2022-02-25 10:04:38 +0100
commitb3fe47f779805ee472d8f110af54f16e8a0caa76 (patch)
treee4144c52d9f184b330ba5716811b223ed31a6bbf /config-model/src/main/java/com/yahoo/searchdefinition/processing
parent9c4ec908885fce1220574efd6018672e65d4360c (diff)
Add strict type checking option to query profiles
Diffstat (limited to 'config-model/src/main/java/com/yahoo/searchdefinition/processing')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java
index e6adb8b683b..4154526d950 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java
@@ -86,13 +86,17 @@ public class RankingExpressionTypeResolver extends Processor {
profile.getSummaryFeatures().forEach(f -> resolveType(f, "summary feature " + f, context));
ensureValidDouble(profile.getFirstPhaseRanking(), "first-phase expression", context);
ensureValidDouble(profile.getSecondPhaseRanking(), "second-phase expression", context);
- if ( context.tensorsAreUsed() &&
- ! context.queryFeaturesNotDeclared().isEmpty() &&
- ! warnedAbout.containsAll(context.queryFeaturesNotDeclared())) {
- deployLogger.logApplicationPackage(Level.WARNING, "The following query features used in '" + profile.name() +
- "' are not declared in query profile " +
- "types and will be interpreted as scalars, not tensors: " +
- context.queryFeaturesNotDeclared());
+ if ( ( context.tensorsAreUsed() || profile.isStrict())
+ && ! context.queryFeaturesNotDeclared().isEmpty()
+ && ! warnedAbout.containsAll(context.queryFeaturesNotDeclared())) {
+ if (profile.isStrict())
+ throw new IllegalArgumentException(profile + " is strict but is missing a query profile type " +
+ "declaration of features " + context.queryFeaturesNotDeclared());
+ else
+ deployLogger.logApplicationPackage(Level.WARNING, "The following query features used in " + profile +
+ " are not declared in query profile " +
+ "types and will be interpreted as scalars, not tensors: " +
+ context.queryFeaturesNotDeclared());
warnedAbout.addAll(context.queryFeaturesNotDeclared());
}
}