diff options
15 files changed, 133 insertions, 101 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java index e1fe795d2b1..6541bd1757d 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java @@ -131,23 +131,23 @@ public class RankProfile implements Cloneable { private Boolean strict; - /** Global onnx models not tied to a search definition */ + /** Global onnx models not tied to a schema */ private final OnnxModels onnxModels; private final RankingConstants rankingConstants; private final ApplicationPackage applicationPackage; private final DeployLogger deployLogger; /** - * Creates a new rank profile for a particular search definition + * Creates a new rank profile for a particular schema * * @param name the name of the new profile - * @param schema the search definition owning this profile + * @param schema the schema owning this profile * @param rankProfileRegistry the {@link com.yahoo.searchdefinition.RankProfileRegistry} to use for storing * and looking up rank profiles. */ public RankProfile(String name, Schema schema, RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants) { this.name = Objects.requireNonNull(name, "name cannot be null"); - this.schema = Objects.requireNonNull(schema, "search cannot be null"); + this.schema = Objects.requireNonNull(schema, "schema cannot be null"); this.onnxModels = null; this.rankingConstants = rankingConstants; this.rankProfileRegistry = rankProfileRegistry; diff --git a/config-model/src/main/javacc/IntermediateParser.jj b/config-model/src/main/javacc/IntermediateParser.jj index 6ce261ebb8c..e4e4e68ecba 100644 --- a/config-model/src/main/javacc/IntermediateParser.jj +++ b/config-model/src/main/javacc/IntermediateParser.jj @@ -33,6 +33,7 @@ import com.yahoo.searchdefinition.document.HnswIndexParams; import com.yahoo.searchdefinition.document.Sorting; import com.yahoo.searchdefinition.document.Stemming; import com.yahoo.searchdefinition.document.SDField; +import com.yahoo.searchdefinition.FeatureNames; import com.yahoo.searchdefinition.fieldoperation.IndexingOperation; import com.yahoo.searchlib.rankingexpression.FeatureList; import com.yahoo.searchlib.rankingexpression.Reference; @@ -418,7 +419,7 @@ void rootSchemaItem(ParsedSchema schema) : { } | rawAsBase64(schema) | searchStemming(schema) | importField(schema) - | rankingConstant(schema) + | rankingConstant(schema) // Deprecated: TODO: Emit warning when on Vespa 8 | useDocument(schema) | rankProfile(schema) | documentSummary(schema) @@ -1767,7 +1768,7 @@ void rankingConstant(ParsedSchema schema) : { ( <CONSTANT> name = identifier() lbrace() (path = fileItem() { pathType = DistributableResource.PathType.FILE; } - | path = uriItem() { pathType = DistributableResource.PathType.URI; } + | path = uriItem() { pathType = DistributableResource.PathType.URI; } // Undocumented. TODO: Remove oin Vespa 8 | type = tensorTypeWithPrefix(rankingConstantErrorMessage(name)) (<NL>)* )+ <RBRACE> @@ -1811,7 +1812,7 @@ void rankProfile(ParsedSchema schema) : ( <MODEL> | <RANKPROFILE> ) name = identifierWithDash() { profile = new ParsedRankProfile(name); } [inheritsRankProfile(profile)] - lbrace() (rankProfileItem(profile) (<NL>)*)* <RBRACE> + lbrace() (rankProfileItem(schema, profile) (<NL>)*)* <RBRACE> { schema.addRankProfile(profile); } @@ -1823,7 +1824,7 @@ void rankProfile(ParsedSchema schema) : * * @param profile The rank profile to modify. */ -void rankProfileItem(ParsedRankProfile profile) : { } +void rankProfileItem(ParsedSchema schema, ParsedRankProfile profile) : { } { ( fieldRankType(profile) | fieldWeight(profile) @@ -1844,7 +1845,7 @@ void rankProfileItem(ParsedRankProfile profile) : { } | secondPhase(profile) | rankDegradation() | inputs(profile) - | constants(profile) + | constants(schema, profile) | matchFeatures(profile) | summaryFeatures(profile) | strict(profile) ) @@ -2075,15 +2076,15 @@ void inputs(ParsedRankProfile profile) : void input(ParsedRankProfile profile) : { Reference reference; - TensorType type; + TensorType type = TensorType.empty; Tensor defaultValue = null; } { - reference = queryFeature() type = inputType(reference) ( <COLON> (<NL>)* defaultValue = tensorValue(type) )? + reference = queryFeature() ( type = valueType(reference))? ( <COLON> (<NL>)* defaultValue = tensorValue(type) )? { profile.addInput(reference, new RankProfile.Input(reference, type, Optional.ofNullable(defaultValue))); } } -TensorType inputType(Reference reference) : +TensorType valueType(Reference reference) : { TensorType type; @@ -2423,17 +2424,54 @@ void rankDegradation() : /** * Consumes a set of constants available in ranking expressions in the enclosing profile. */ -void constants(ParsedRankProfile profile) : +void constants(ParsedSchema schema, ParsedRankProfile profile) : { String name; } { <CONSTANTS> <LBRACE> (<NL>)* - ( name = identifier() ( constantValue(profile, name) | - constantTensor(profile, name) ) (<NL>)* )* + ( constant(schema, profile) (<NL>)* )* <RBRACE> } +void constant(ParsedSchema schema, ParsedRankProfile profile) : +{ + Reference reference = null; + TensorType type = TensorType.empty; + Tensor value = null; + String valuePath = null; +} +{ + ( + reference = constantName() + ( + LOOKAHEAD(4) ( ( type = valueType(reference) )? <COLON> (<NL>)* ( value = tensorValue(type) | valuePath = fileItem()) + { + if (value != null) + profile.addConstant(reference.simpleArgument().get(), type.rank() == 0 ? Value.of(value.asDouble()) : Value.of(value)); + else + schema.addRankingConstant(new RankingConstant(reference.simpleArgument().get(), type, valuePath, DistributableResource.PathType.FILE)); // TODO JON: Move to RankProfile + } + ) + | // Deprecated forms (TODO: Add warning on Vespa 8): + ( constantValue(profile, reference.simpleArgument().get()) | constantTensor(profile, reference.simpleArgument().get()) ) + ) + ) +} + +/** Returns the reference "constant(name)" for both "constant(name)" and "name". */ +Reference constantName() : +{ + String name; +} +{ + ( <CONSTANT> "(" name = identifier() ")" ) + | + name = identifier() + { return FeatureNames.asConstantFeature(name); } +} + +// Deprecated form void constantValue(ParsedRankProfile profile, String name) : { Token value; @@ -2442,6 +2480,7 @@ void constantValue(ParsedRankProfile profile, String name) : <COLON> ( value = <DOUBLE> | value = <INTEGER> | value = <IDENTIFIER> ) { profile.addConstant(name, Value.parse(value.image)); } } +// Deprecated form void constantTensor(ParsedRankProfile profile, String name) : { String tensorString = ""; diff --git a/config-model/src/test/cfg/application/validation/ranking_constants_fail/schemas/simple.sd b/config-model/src/test/cfg/application/validation/ranking_constants_fail/schemas/simple.sd index c028228e557..0124a3f54fa 100644 --- a/config-model/src/test/cfg/application/validation/ranking_constants_fail/schemas/simple.sd +++ b/config-model/src/test/cfg/application/validation/ranking_constants_fail/schemas/simple.sd @@ -1,5 +1,6 @@ # Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -search simple { +schema simple { + document simple {} constant constant_tensor_1 { @@ -26,4 +27,5 @@ search simple { file: tensors/constant_tensor_5.json type: tensor(x[33], y[10], z[46]) } + } diff --git a/config-model/src/test/derived/neuralnet/rank-profiles.cfg b/config-model/src/test/derived/neuralnet/rank-profiles.cfg index 34133b2a8b6..779344c2d1f 100644 --- a/config-model/src/test/derived/neuralnet/rank-profiles.cfg +++ b/config-model/src/test/derived/neuralnet/rank-profiles.cfg @@ -1,16 +1,16 @@ rankprofile[].name "default" -rankprofile[].fef.property[].name "vespa.type.query.b_out" -rankprofile[].fef.property[].value "tensor(out[1])" rankprofile[].fef.property[].name "vespa.type.query.W_out" rankprofile[].fef.property[].value "tensor(out[9])" rankprofile[].fef.property[].name "vespa.type.query.b_0" rankprofile[].fef.property[].value "tensor(hidden[9])" -rankprofile[].fef.property[].name "vespa.type.query.b_1" -rankprofile[].fef.property[].value "tensor(out[9])" rankprofile[].fef.property[].name "vespa.type.query.W_1" rankprofile[].fef.property[].value "tensor(hidden[9],out[9])" +rankprofile[].fef.property[].name "vespa.type.query.b_1" +rankprofile[].fef.property[].value "tensor(out[9])" rankprofile[].fef.property[].name "vespa.type.query.W_0" rankprofile[].fef.property[].value "tensor(hidden[9],x[9])" +rankprofile[].fef.property[].name "vespa.type.query.b_out" +rankprofile[].fef.property[].value "tensor(out[1])" rankprofile[].name "unranked" rankprofile[].fef.property[].name "vespa.rank.firstphase" rankprofile[].fef.property[].value "value(0)" @@ -70,7 +70,7 @@ rankprofile[].fef.property[].value "if (isNan(attribute(createdAt)) == 1, rankin rankprofile[].fef.property[].name "rankingExpression(laAtToUse).rankingScript" rankprofile[].fef.property[].value "if (isNan(attribute(laAt)) == 1, attribute(createdAt), attribute(laAt))" rankprofile[].fef.property[].name "rankingExpression(markedAsAAtToUse).rankingScript" -rankprofile[].fef.property[].value "if (isNan(attribute(markedAsAAt)) == 1, 9223372036854775807, attribute(markedAsAAt))" +rankprofile[].fef.property[].value "if (isNan(attribute(markedAsAAt)) == 1, 9.223372036854776E18, attribute(markedAsAAt))" rankprofile[].fef.property[].name "rankingExpression(tdToUse).rankingScript" rankprofile[].fef.property[].value "pow(2,0 - ((rankingExpression(rankedAt) - rankingExpression(createdAtToUse)) / query(decay)))" rankprofile[].fef.property[].name "rankingExpression(commentOverallScore).rankingScript" @@ -81,18 +81,18 @@ rankprofile[].fef.property[].name "rankingExpression(freshnessRank).rankingScrip rankprofile[].fef.property[].value "nativeRank + freshness(createdAt)" rankprofile[].fef.property[].name "vespa.rank.firstphase" rankprofile[].fef.property[].value "nativeRank" -rankprofile[].fef.property[].name "vespa.type.query.b_out" -rankprofile[].fef.property[].value "tensor(out[1])" -rankprofile[].fef.property[].name "vespa.type.query.W_out" -rankprofile[].fef.property[].value "tensor(out[9])" +rankprofile[].fef.property[].name "vespa.type.query.W_0" +rankprofile[].fef.property[].value "tensor(hidden[9],x[9])" rankprofile[].fef.property[].name "vespa.type.query.b_0" rankprofile[].fef.property[].value "tensor(hidden[9])" -rankprofile[].fef.property[].name "vespa.type.query.b_1" -rankprofile[].fef.property[].value "tensor(out[9])" rankprofile[].fef.property[].name "vespa.type.query.W_1" rankprofile[].fef.property[].value "tensor(hidden[9],out[9])" -rankprofile[].fef.property[].name "vespa.type.query.W_0" -rankprofile[].fef.property[].value "tensor(hidden[9],x[9])" +rankprofile[].fef.property[].name "vespa.type.query.b_1" +rankprofile[].fef.property[].value "tensor(out[9])" +rankprofile[].fef.property[].name "vespa.type.query.W_out" +rankprofile[].fef.property[].value "tensor(out[9])" +rankprofile[].fef.property[].name "vespa.type.query.b_out" +rankprofile[].fef.property[].value "tensor(out[1])" rankprofile[].name "neuralNetworkProfile" rankprofile[].fef.property[].name "rankingExpression(freshnessRank).rankingScript" rankprofile[].fef.property[].value "nativeRank + freshness(createdAt)" @@ -171,7 +171,7 @@ rankprofile[].fef.property[].value "if (freshness(createdAt).logscale < 0.01, 0. rankprofile[].fef.property[].name "rankingExpression(laAtToUse).rankingScript" rankprofile[].fef.property[].value "if (isNan(attribute(laAt)) == 1, attribute(createdAt), attribute(laAt))" rankprofile[].fef.property[].name "rankingExpression(markedAsAAtToUse).rankingScript" -rankprofile[].fef.property[].value "if (isNan(attribute(markedAsAAt)) == 1, 9223372036854775807, attribute(markedAsAAt))" +rankprofile[].fef.property[].value "if (isNan(attribute(markedAsAAt)) == 1, 9.223372036854776E18, attribute(markedAsAAt))" rankprofile[].fef.property[].name "rankingExpression(commentOverallScore).rankingScript" rankprofile[].fef.property[].value "query(textweight) * rankingExpression(textScoreToUse) + query(communityweight) * rankingExpression(nCScoreToUse)" rankprofile[].fef.property[].name "rankingExpression(pinScore).rankingScript" diff --git a/config-model/src/test/derived/neuralnet_noqueryprofile/neuralnet.sd b/config-model/src/test/derived/neuralnet_noqueryprofile/neuralnet.sd index aed80f77e6f..a6564d59e16 100644 --- a/config-model/src/test/derived/neuralnet_noqueryprofile/neuralnet.sd +++ b/config-model/src/test/derived/neuralnet_noqueryprofile/neuralnet.sd @@ -85,7 +85,7 @@ search neuralnet { rank-profile defaultRankProfile inherits default { constants { - maxSignedSixtyFourBitInteger: 9223372036854775807 + maxSignedSixtyFourBitInteger double: 9223372036854775807 } function log10_1p(x) { diff --git a/config-model/src/test/derived/neuralnet_noqueryprofile/rank-profiles.cfg b/config-model/src/test/derived/neuralnet_noqueryprofile/rank-profiles.cfg index 1e05fe77324..cd3abcb6028 100644 --- a/config-model/src/test/derived/neuralnet_noqueryprofile/rank-profiles.cfg +++ b/config-model/src/test/derived/neuralnet_noqueryprofile/rank-profiles.cfg @@ -60,7 +60,7 @@ rankprofile[].fef.property[].value "if (isNan(attribute(createdAt)) == 1, rankin rankprofile[].fef.property[].name "rankingExpression(laAtToUse).rankingScript" rankprofile[].fef.property[].value "if (isNan(attribute(laAt)) == 1, attribute(createdAt), attribute(laAt))" rankprofile[].fef.property[].name "rankingExpression(markedAsAAtToUse).rankingScript" -rankprofile[].fef.property[].value "if (isNan(attribute(markedAsAAt)) == 1, 9223372036854775807, attribute(markedAsAAt))" +rankprofile[].fef.property[].value "if (isNan(attribute(markedAsAAt)) == 1, 9.223372036854776E18, attribute(markedAsAAt))" rankprofile[].fef.property[].name "rankingExpression(tdToUse).rankingScript" rankprofile[].fef.property[].value "pow(2,0 - ((rankingExpression(rankedAt) - rankingExpression(createdAtToUse)) / query(decay)))" rankprofile[].fef.property[].name "rankingExpression(commentOverallScore).rankingScript" @@ -79,12 +79,12 @@ rankprofile[].fef.property[].name "vespa.type.query.W_1" rankprofile[].fef.property[].value "tensor(hidden[9],out[9])" rankprofile[].fef.property[].name "vespa.type.query.b_1" rankprofile[].fef.property[].value "tensor(out[9])" +rankprofile[].fef.property[].name "vespa.type.query.W_out" +rankprofile[].fef.property[].value "tensor(out[9])" rankprofile[].fef.property[].name "vespa.type.query.b_out" rankprofile[].fef.property[].value "tensor(out[1])" rankprofile[].fef.property[].name "query(b_out)" rankprofile[].fef.property[].value "{{out:0}:1.0}" -rankprofile[].fef.property[].name "vespa.type.query.W_out" -rankprofile[].fef.property[].value "tensor(out[9])" rankprofile[].name "neuralNetworkProfile" rankprofile[].fef.property[].name "rankingExpression(freshnessRank).rankingScript" rankprofile[].fef.property[].value "nativeRank + freshness(createdAt)" @@ -163,7 +163,7 @@ rankprofile[].fef.property[].value "if (freshness(createdAt).logscale < 0.01, 0. rankprofile[].fef.property[].name "rankingExpression(laAtToUse).rankingScript" rankprofile[].fef.property[].value "if (isNan(attribute(laAt)) == 1, attribute(createdAt), attribute(laAt))" rankprofile[].fef.property[].name "rankingExpression(markedAsAAtToUse).rankingScript" -rankprofile[].fef.property[].value "if (isNan(attribute(markedAsAAt)) == 1, 9223372036854775807, attribute(markedAsAAt))" +rankprofile[].fef.property[].value "if (isNan(attribute(markedAsAAt)) == 1, 9.223372036854776E18, attribute(markedAsAAt))" rankprofile[].fef.property[].name "rankingExpression(commentOverallScore).rankingScript" rankprofile[].fef.property[].value "query(textweight) * rankingExpression(textScoreToUse) + query(communityweight) * rankingExpression(nCScoreToUse)" rankprofile[].fef.property[].name "rankingExpression(pinScore).rankingScript" diff --git a/config-model/src/test/derived/nuwa/newsindex.sd b/config-model/src/test/derived/nuwa/newsindex.sd index 68592391f52..4d81df85000 100644 --- a/config-model/src/test/derived/nuwa/newsindex.sd +++ b/config-model/src/test/derived/nuwa/newsindex.sd @@ -512,7 +512,7 @@ search newsindex { } constants { - sourcerank: 1 + sourcerank double: 1 } } @@ -601,8 +601,8 @@ search newsindex { } constants { - time_rewards: 900 - maxAge: 604800 + time_rewards double: 900 + maxAge double: 604800 scale: 86400 } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java index 4646ff2f394..cd98ca96c42 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java @@ -27,7 +27,7 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { QueryProfileRegistry queryProfileRegistry = new QueryProfileRegistry(); ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); builder.addSchema( - "search test {\n" + + "schema test {\n" + " document test { \n" + " field a type string { \n" + " indexing: index \n" + @@ -36,8 +36,8 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { " \n" + " rank-profile parent {\n" + " constants {\n" + - " p1: 7 \n" + - " p2: 0 \n" + + " p1 double: 7 \n" + + " p2 double: 0 \n" + " }\n" + " first-phase {\n" + " expression: p2 * (1.3 + p1 )\n" + @@ -93,7 +93,7 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); builder.addSchema( - "search test {\n" + + "schema test {\n" + " document test { \n" + " field a type string { \n" + " indexing: index \n" + @@ -152,7 +152,7 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); ApplicationBuilder builder = new ApplicationBuilder(rankProfileRegistry); builder.addSchema( - "search test {\n" + + "schema test {\n" + " document test { \n" + " field a type string { \n" + " indexing: index \n" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java index e297beef026..76cb956ecdc 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java @@ -69,10 +69,10 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { Schema s = builder.getSchema(); RankProfile parent = rankProfileRegistry.get(s, "parent").compile(new QueryProfileRegistry(), new ImportedMlModels()); - assertEquals("7 * (3 + attribute(a) + attribute(b) * (attribute(a) * 3 + if (7 < attribute(a), 1, 2) == 0))", + assertEquals("7.0 * (3 + attribute(a) + attribute(b) * (attribute(a) * 3 + if (7.0 < attribute(a), 1, 2) == 0))", parent.getFirstPhaseRanking().getRoot().toString()); RankProfile child = rankProfileRegistry.get(s, "child").compile(new QueryProfileRegistry(), new ImportedMlModels()); - assertEquals("7 * (9 + attribute(a))", + assertEquals("7.0 * (9 + attribute(a))", child.getFirstPhaseRanking().getRoot().toString()); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolverTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolverTestCase.java index 2606b9a25aa..9b32d97ef75 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolverTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolverTestCase.java @@ -63,7 +63,7 @@ public class RankingExpressionTypeResolverTestCase { try { ApplicationBuilder builder = new ApplicationBuilder(); builder.addSchema(joinLines( - "search test {", + "schema test {", " document test { ", " field a type tensor(d0[3]) {", " indexing: attribute", @@ -80,18 +80,12 @@ public class RankingExpressionTypeResolverTestCase { " expression: reduce(attribute(a),sum,d0)+y_tensor+my_func+other_func", " }", " constants {", - " x_tensor {", + " x_tensor {", // legacy form " type: tensor(x{})", " value: { {x:bar}:17 }", " }", - " y_tensor {", - " type: tensor(y{})", - " value: { {y:foo}:42 }", - " }", - " z_tensor {", - " type: tensor(z{})", - " value: { {z:qux}:666 }", - " }", + " y_tensor tensor(y{}):{{y:foo}:42 }", + " z_tensor tensor(z{}):{qux:666}", " }", " }", "}" diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorTestCase.java index 3ac560d394e..114486a5ddc 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTensorTestCase.java @@ -20,10 +20,7 @@ public class RankingExpressionWithTensorTestCase { " expression: sum(my_tensor)\n" + " }\n" + " constants {\n" + - " my_tensor {\n" + - " value: { {x:1,y:2}:1, {x:2,y:1}:2 }\n" + - " type: tensor(x{},y{})\n" + - " }\n" + + " my_tensor tensor(x{},y{}):{ {x:1,y:2}:1, {x:2,y:1}:2 }\n" + " }\n" + " }"); f.compileRankProfile("my_profile"); @@ -40,10 +37,7 @@ public class RankingExpressionWithTensorTestCase { " expression: sum(constant(my_tensor))\n" + " }\n" + " constants {\n" + - " my_tensor {\n" + - " value: { {x:1,y:2}:1, {x:2,y:1}:2 }\n" + - " type: tensor(x{},y{})\n" + - " }\n" + + " my_tensor tensor(x{},y{}):{{x:1,y:2}:1, {x:2,y:1}:2}\n" + " }\n" + " }"); f.compileRankProfile("my_profile"); @@ -60,13 +54,9 @@ public class RankingExpressionWithTensorTestCase { " expression: sum(my_tensor)\n" + " }\n" + " constants {\n" + - " my_tensor {\n" + - " value {\n" + + " my_tensor tensor(x{},y{}):\n" + " { {x:1,y:2}:1,\n" + " {x:2,y:1}:2 }\n" + - " }\n" + - " type: tensor(x{},y{})\n" + - " }\n" + " }\n" + " }"); f.compileRankProfile("my_profile"); @@ -83,9 +73,7 @@ public class RankingExpressionWithTensorTestCase { " expression: sum(my_tensor)\n" + " }\n" + " constants {\n" + - " my_tensor {\n" + - " value: { {x:1}:1 }\n" + - " }\n" + + " my_tensor tensor(x{}):{ {x:1}:1 }\n" + " }\n" + " }"); f.compileRankProfile("my_profile"); @@ -126,9 +114,7 @@ public class RankingExpressionWithTensorTestCase { " expression: 5.0 + my_macro\n" + " }\n" + " constants {\n" + - " my_tensor {\n" + - " value: { {x:1}:1 }\n" + - " }\n" + + " my_tensor tensor(x{}):{ {x:1}:1 }\n" + " }\n" + " }"); f.compileRankProfile("my_profile"); @@ -146,11 +132,9 @@ public class RankingExpressionWithTensorTestCase { " expression: my_number_1 + sum(my_tensor) + my_number_2\n" + " }\n" + " constants {\n" + - " my_number_1: 3.0\n" + - " my_tensor {\n" + - " value: { {x:1}:1 }\n" + - " }\n" + - " my_number_2: 5.0\n" + + " my_number_1 double: 3.0\n" + + " my_tensor tensor(x{}):{ {x:1}:1 }\n" + + " my_number_2 double: 5.0\n" + " }\n" + " }"); f.compileRankProfile("my_profile"); @@ -165,17 +149,14 @@ public class RankingExpressionWithTensorTestCase { RankProfileSearchFixture f = new RankProfileSearchFixture( " rank-profile my_profile {\n" + " constants {\n" + - " my_tensor {\n" + - " value: { {x:1}:1 }\n" + - " type: tensor(x)\n" + - " }\n" + + " my_tensor tensor(x):{ {x:1}:1 }\n" + " }\n" + " }"); f.compileRankProfile("my_profile"); fail("Expected exception"); } catch (IllegalArgumentException e) { - assertStartsWith("For constant tensor 'my_tensor' in rank profile 'my_profile': Illegal tensor type spec", + assertStartsWith("Type of constant(my_tensor): Illegal tensor type spec: A tensor type spec must be on the form", e.getMessage()); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java index e3ac5da8955..26b108e2b45 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java @@ -166,9 +166,7 @@ public class TensorTransformTestCase extends AbstractSchemaTestCase { " }\n" + " rank-profile base {\n" + " constants {\n" + - " base_constant_tensor {\n" + - " value: { {x:0}:0 }\n" + - " }\n" + + " base_constant_tensor tensor(x[1]):[0]\n"+ " }\n" + " function base_tensor() {\n" + " expression: constant(base_constant_tensor)\n" + @@ -176,9 +174,7 @@ public class TensorTransformTestCase extends AbstractSchemaTestCase { " }\n" + " rank-profile test inherits base {\n" + " constants {\n" + - " test_constant_tensor {\n" + - " value: { {x:0}:1 }\n" + - " }\n" + + " test_constant_tensor tensor(x[1]):[1]" + " }\n" + " function returns_tensor_with_arg(arg1) {\n" + " expression: 2.0 * arg1\n" + diff --git a/container-search/src/main/java/com/yahoo/search/query/properties/QueryPropertyAliases.java b/container-search/src/main/java/com/yahoo/search/query/properties/QueryPropertyAliases.java index d089283a4b9..4207080b3e5 100644 --- a/container-search/src/main/java/com/yahoo/search/query/properties/QueryPropertyAliases.java +++ b/container-search/src/main/java/com/yahoo/search/query/properties/QueryPropertyAliases.java @@ -25,10 +25,20 @@ public class QueryPropertyAliases extends PropertyAliases { protected CompoundName unalias(CompoundName nameOrAlias) { if (nameOrAlias.first().equalsIgnoreCase("rankfeature") || nameOrAlias.first().equalsIgnoreCase("input") - || nameOrAlias.first().equalsIgnoreCase("featureoverride")) // deprecated: TODO Remove on Vespa 8 - return nameOrAlias.rest().prepend("ranking", "features"); - else if (nameOrAlias.first().equalsIgnoreCase("rankproperty")) - return nameOrAlias.rest().prepend("ranking", "properties"); + || nameOrAlias.first().equalsIgnoreCase("featureoverride")) { // deprecated: TODO Remove on Vespa 8 + if (nameOrAlias.size() > 1) // only alias the prefix + return nameOrAlias.rest().prepend("ranking", "features"); + else + return nameOrAlias; + } + else if (nameOrAlias.first().equalsIgnoreCase("rankproperty")) { + if (nameOrAlias.size() > 1) // only alias the prefix + return nameOrAlias.rest().prepend("ranking", "properties"); + else + return nameOrAlias; + } + + // No special handling return super.unalias(nameOrAlias); } diff --git a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java index 56acdb039a9..b3aeda65f4b 100644 --- a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java @@ -450,7 +450,8 @@ public class QueryTestCase { testProfile.set("d","e", null); testProfile.set("u","11", null); testProfile.set("foo.bar", "wiz", null); - Query q = new Query(QueryTestCase.httpEncode("?query=a:>5&a=b&traceLevel=5&sources=a,b&u=12&foo.bar2=wiz2&c.d=foo&queryProfile=test"),testProfile.compile(null)); + Query q = new Query(QueryTestCase.httpEncode("?query=a:>5&a=b&traceLevel=5&sources=a,b&u=12&foo.bar2=wiz2&c.d=foo&queryProfile=test"), + testProfile.compile(null)); String trace = q.getContext(false).getTrace().toString(); String[] traceLines = trace.split("\n"); } @@ -471,13 +472,21 @@ public class QueryTestCase { } @Test - public void testSimpleQueryParsing () { + public void testSimpleQueryParsing() { Query q = new Query("/search?query=foobar&offset=10&hits=20"); - assertEquals("foobar",q.getModel().getQueryTree().toString()); + assertEquals("foobar", q.getModel().getQueryTree().toString()); assertEquals(10,q.getOffset()); assertEquals(20,q.getHits()); } + /** "input.*" is an alias for "ranking.feature.*", but just "input" is not */ + @Test + public void testPrefixAlias() { + Query q = new Query("/search?query=foobar&input=foo", + new QueryProfile("test").compile(null)); + assertEquals("foo", q.properties().get("input")); + } + /** Test that GET parameter names are case in-sensitive */ @Test public void testGETParametersCase() { diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notifier.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notifier.java index 5a5188da37f..36a254f5c4b 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notifier.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notifier.java @@ -72,10 +72,11 @@ public class Notifier { } private boolean skipSource(NotificationSource source) { - // Limit sources to production systems only. Dev and test systems cause too much noise at the moment. - if (source.zoneId().map(z -> z.environment() != Environment.prod).orElse(false)) { - return true; - } else if (source.jobType().map(t -> !t.isProduction()).orElse(false)) { + // Do not dispatch notification for dev and perf environments + if (source.zoneId() + .map(z -> z.environment()) + .map(e -> e == Environment.dev || e == Environment.perf) + .orElse(false)) { return true; } return false; |