diff options
author | Arne Juul <arnej@yahooinc.com> | 2023-09-21 09:18:36 +0000 |
---|---|---|
committer | Arne Juul <arnej@yahooinc.com> | 2023-09-21 09:19:30 +0000 |
commit | 24d0dcef6280b5aa059d23f87c232ef6c6ac8502 (patch) | |
tree | b7c5b7d92ffde28f56cc9da439d539743f46dcfa /config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java | |
parent | 7faeffcc5901ae88c1c3d1814665d0db6ca1d900 (diff) |
declare types for more rank features
Diffstat (limited to 'config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java')
-rw-r--r-- | config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java b/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java index 29bd454cc62..5f1cd16c68e 100644 --- a/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java +++ b/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java @@ -19,6 +19,7 @@ import com.yahoo.searchlib.rankingexpression.Reference; import com.yahoo.searchlib.rankingexpression.parser.ParseException; import com.yahoo.searchlib.rankingexpression.rule.ReferenceNode; import com.yahoo.searchlib.rankingexpression.rule.SerializationContext; +import com.yahoo.tensor.evaluation.TypeContext; import com.yahoo.vespa.config.search.RankProfilesConfig; import static com.yahoo.searchlib.rankingexpression.Reference.wrapInRankingExpression; @@ -207,10 +208,8 @@ public class RawRankProfile implements RankProfilesConfig.Producer { Map<String, RankProfile.RankingExpressionFunction> functions = compiled.getFunctions(); List<ExpressionFunction> functionExpressions = functions.values().stream().map(RankProfile.RankingExpressionFunction::function).toList(); Map<String, String> functionProperties = new LinkedHashMap<>(); - SerializationContext functionSerializationContext = new SerializationContext(functionExpressions, - Map.of(), - compiled.typeContext(queryProfiles)); - + var typeContext = compiled.typeContext(queryProfiles); + SerializationContext functionSerializationContext = new SerializationContext(functionExpressions, Map.of(), typeContext); if (firstPhaseRanking != null) { functionProperties.putAll(firstPhaseRanking.getRankProperties(functionSerializationContext)); } @@ -220,6 +219,8 @@ public class RawRankProfile implements RankProfilesConfig.Producer { if (globalPhaseRanking != null) { functionProperties.putAll(globalPhaseRanking.getRankProperties(functionSerializationContext)); } + deriveFeatureDeclarations(matchFeatures, typeContext, functionProperties); + deriveFeatureDeclarations(summaryFeatures, typeContext, functionProperties); derivePropertiesAndFeaturesFromFunctions(functions, functionProperties, functionSerializationContext); deriveOnnxModelFunctionsAndFeatures(compiled); @@ -228,6 +229,19 @@ public class RawRankProfile implements RankProfilesConfig.Producer { deriveWeightProperties(compiled); } + private void deriveFeatureDeclarations(Collection<ReferenceNode> features, + TypeContext typeContext, + Map<String, String> functionProperties) + { + for (ReferenceNode feature : features) { + var tt = feature.type(typeContext); + if (tt != null && tt.rank() > 0) { + String k = "vespa.type.feature." + feature.getName() + feature.getArguments(); + functionProperties.put(k, tt.toString()); + } + } + } + private void deriveFilterFields(RankProfile rp) { filterFields.addAll(rp.allFilterFields()); } |