diff options
author | Arne Juul <arnej@yahooinc.com> | 2023-03-08 14:02:29 +0000 |
---|---|---|
committer | Arne Juul <arnej@yahooinc.com> | 2023-03-08 15:10:35 +0000 |
commit | 072143c16fa4e3c7b085e29cfa1bc29261680959 (patch) | |
tree | 2a0455aa653999a26e4c1424f92a0142c1d045ba /config-model | |
parent | fd934051f923c8b0a2b2692194e92b787e7d45c9 (diff) |
handle more complex features and functions wrapped in rankingExpression(foo)
Diffstat (limited to 'config-model')
5 files changed, 44 insertions, 8 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/expressiontransforms/InputRecorder.java b/config-model/src/main/java/com/yahoo/schema/expressiontransforms/InputRecorder.java index b0f63ebb732..515745cb6bc 100644 --- a/config-model/src/main/java/com/yahoo/schema/expressiontransforms/InputRecorder.java +++ b/config-model/src/main/java/com/yahoo/schema/expressiontransforms/InputRecorder.java @@ -46,7 +46,12 @@ public class InputRecorder extends ExpressionTransformer<RankProfileTransformCon Reference ref = feature.reference(); String name = ref.name(); var args = ref.arguments(); - if (args.size() == 0) { + boolean simpleFunctionOrIdentifier = (args.size() == 0) && (ref.output() == null); + if (ref.isSimpleRankingExpressionWrapper()) { + name = ref.simpleArgument().get(); + simpleFunctionOrIdentifier = true; + } + if (simpleFunctionOrIdentifier) { var f = context.rankProfile().getFunctions().get(name); if (f != null && f.function().arguments().size() == 0) { transform(f.function().getBody().getRoot(), context); @@ -55,7 +60,7 @@ public class InputRecorder extends ExpressionTransformer<RankProfileTransformCon neededInputs.add(feature.toString()); return; } - if (args.size() == 1) { + if (FeatureNames.isSimpleFeature(ref)) { if (FeatureNames.isAttributeFeature(ref)) { neededInputs.add(feature.toString()); return; @@ -96,6 +101,6 @@ public class InputRecorder extends ExpressionTransformer<RankProfileTransformCon } return; } - throw new IllegalArgumentException("cannot handle feature: " + feature); + neededInputs.add(feature.toString()); } } diff --git a/config-model/src/test/derived/globalphase_onnx_inside/rank-profiles.cfg b/config-model/src/test/derived/globalphase_onnx_inside/rank-profiles.cfg index 35bb1ccc3d2..1e9cf8ce0e9 100644 --- a/config-model/src/test/derived/globalphase_onnx_inside/rank-profiles.cfg +++ b/config-model/src/test/derived/globalphase_onnx_inside/rank-profiles.cfg @@ -3,6 +3,18 @@ rankprofile[].fef.property[].name "rankingExpression(handicap).rankingScript" rankprofile[].fef.property[].value "query(yy)" rankprofile[].fef.property[].name "rankingExpression(handicap).type" rankprofile[].fef.property[].value "tensor(d0[2])" +rankprofile[].fef.property[].name "rankingExpression(indirect_a).rankingScript" +rankprofile[].fef.property[].value "attribute(aa)" +rankprofile[].fef.property[].name "rankingExpression(indirect_a).type" +rankprofile[].fef.property[].value "tensor(d1[3])" +rankprofile[].fef.property[].name "rankingExpression(indirect_x).rankingScript" +rankprofile[].fef.property[].value "constant(xx)" +rankprofile[].fef.property[].name "rankingExpression(indirect_x).type" +rankprofile[].fef.property[].value "tensor(d0[2],d1[3])" +rankprofile[].fef.property[].name "rankingExpression(indirect_b).rankingScript" +rankprofile[].fef.property[].value "query(bb)" +rankprofile[].fef.property[].name "rankingExpression(indirect_b).type" +rankprofile[].fef.property[].value "tensor(d0[2])" rankprofile[].fef.property[].name "vespa.rank.firstphase" rankprofile[].fef.property[].value "rankingExpression(firstphase)" rankprofile[].fef.property[].name "rankingExpression(firstphase).rankingScript" diff --git a/config-model/src/test/derived/globalphase_onnx_inside/test.sd b/config-model/src/test/derived/globalphase_onnx_inside/test.sd index c38e318ce6b..405a65ceb06 100644 --- a/config-model/src/test/derived/globalphase_onnx_inside/test.sd +++ b/config-model/src/test/derived/globalphase_onnx_inside/test.sd @@ -22,9 +22,9 @@ schema test { } onnx-model inside { file: files/ax_plus_b.onnx - input vector_A: attribute(aa) - input matrix_X: constant(xx) - input vector_B: query(bb) + input vector_A: indirect_a + input matrix_X: indirect_x + input vector_B: indirect_b output vector_Y: foobar } first-phase { @@ -37,6 +37,15 @@ schema test { rerank-count: 13 expression: sum(constant(ww) * (onnx(inside).foobar - handicap)) } + function indirect_a() { + expression: attribute(aa) + } + function indirect_x() { + expression: constant(xx) + } + function indirect_b() { + expression: query(bb) + } } } diff --git a/config-model/src/test/derived/rankingexpression/rank-profiles.cfg b/config-model/src/test/derived/rankingexpression/rank-profiles.cfg index 202669ae049..3db3f437698 100644 --- a/config-model/src/test/derived/rankingexpression/rank-profiles.cfg +++ b/config-model/src/test/derived/rankingexpression/rank-profiles.cfg @@ -410,7 +410,15 @@ rankprofile[].fef.property[].value "attribute(foo1)" rankprofile[].fef.property[].name "vespa.rank.globalphase" rankprofile[].fef.property[].value "rankingExpression(globalphase)" rankprofile[].fef.property[].name "rankingExpression(globalphase).rankingScript" -rankprofile[].fef.property[].value "rankingExpression(myplus) + reduce(rankingExpression(mymul), sum) + firstPhase" +rankprofile[].fef.property[].value "rankingExpression(myplus) + reduce(rankingExpression(mymul), sum) + firstPhase + term(0).significance + fieldLength(artist) + fieldTermMatch(title,0).occurrences + termDistance(title,1,2).reverse + closeness(field,t1)" +rankprofile[].fef.property[].name "vespa.match.feature" +rankprofile[].fef.property[].value "fieldLength(artist)" +rankprofile[].fef.property[].name "vespa.match.feature" +rankprofile[].fef.property[].value "term(0).significance" +rankprofile[].fef.property[].name "vespa.match.feature" +rankprofile[].fef.property[].value "closeness(field,t1)" +rankprofile[].fef.property[].name "vespa.match.feature" +rankprofile[].fef.property[].value "termDistance(title,1,2).reverse" rankprofile[].fef.property[].name "vespa.match.feature" rankprofile[].fef.property[].value "firstPhase" rankprofile[].fef.property[].name "vespa.match.feature" @@ -418,6 +426,8 @@ rankprofile[].fef.property[].value "attribute(t1)" rankprofile[].fef.property[].name "vespa.match.feature" rankprofile[].fef.property[].value "attribute(foo1)" rankprofile[].fef.property[].name "vespa.match.feature" +rankprofile[].fef.property[].value "fieldTermMatch(title,0).occurrences" +rankprofile[].fef.property[].name "vespa.match.feature" rankprofile[].fef.property[].value "attribute(foo2)" rankprofile[].fef.property[].name "vespa.globalphase.rerankcount" rankprofile[].fef.property[].value "42" diff --git a/config-model/src/test/derived/rankingexpression/rankexpression.sd b/config-model/src/test/derived/rankingexpression/rankexpression.sd index 015767e3070..499fe8a3539 100644 --- a/config-model/src/test/derived/rankingexpression/rankexpression.sd +++ b/config-model/src/test/derived/rankingexpression/rankexpression.sd @@ -380,7 +380,7 @@ schema rankexpression { expression: attribute(foo1) } global-phase { - expression: myplus()+sum(mymul())+firstPhase + expression: myplus()+sum(mymul())+firstPhase + term(0).significance + fieldLength(artist) + fieldTermMatch(title,0).occurrences + termDistance(title,1,2).reverse + closeness(field, t1) rerank-count: 42 } } |