aboutsummaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorArne Juul <arnej@yahooinc.com>2023-03-02 11:12:02 +0000
committerArne Juul <arnej@yahooinc.com>2023-03-02 11:12:02 +0000
commit27f83008c0026108f9fc3a7cffa576897cb7a55d (patch)
treea54a3da0dff4982b718d5be608e12b2918c5cfca /config-model
parentde2d6283c0758a1afaf4cea3b143d04a66b78f5f (diff)
unit test with problematic .sd from system test
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/test/derived/rankingmacros/rank-profiles.cfg83
-rw-r--r--config-model/src/test/derived/rankingmacros/rankingmacros.sd105
-rw-r--r--config-model/src/test/java/com/yahoo/schema/derived/RankProfilesTestCase.java5
3 files changed, 193 insertions, 0 deletions
diff --git a/config-model/src/test/derived/rankingmacros/rank-profiles.cfg b/config-model/src/test/derived/rankingmacros/rank-profiles.cfg
new file mode 100644
index 00000000000..71b7bc7166c
--- /dev/null
+++ b/config-model/src/test/derived/rankingmacros/rank-profiles.cfg
@@ -0,0 +1,83 @@
+rankprofile[].name "default"
+rankprofile[].name "unranked"
+rankprofile[].fef.property[].name "vespa.rank.firstphase"
+rankprofile[].fef.property[].value "value(0)"
+rankprofile[].fef.property[].name "vespa.hitcollector.heapsize"
+rankprofile[].fef.property[].value "0"
+rankprofile[].fef.property[].name "vespa.hitcollector.arraysize"
+rankprofile[].fef.property[].value "0"
+rankprofile[].fef.property[].name "vespa.dump.ignoredefaultfeatures"
+rankprofile[].fef.property[].value "true"
+rankprofile[].name "standalone"
+rankprofile[].fef.property[].name "rankingExpression(myfeature).rankingScript"
+rankprofile[].fef.property[].value "7 * attribute(num)"
+rankprofile[].fef.property[].name "rankingExpression(fourtimessum@2b1138e8965e7ff5.67f1e87166cfef86).rankingScript"
+rankprofile[].fef.property[].value "4 * (match + match)"
+rankprofile[].fef.property[].name "rankingExpression(macro_with_dollar$).rankingScript"
+rankprofile[].fef.property[].value "69"
+rankprofile[].fef.property[].name "rankingExpression(anotherfeature).rankingScript"
+rankprofile[].fef.property[].value "10 * rankingExpression(myfeature)"
+rankprofile[].fef.property[].name "rankingExpression(yetanotherfeature).rankingScript"
+rankprofile[].fef.property[].value "100 * rankingExpression(myfeature)"
+rankprofile[].fef.property[].name "rankingExpression(fourtimessum).rankingScript"
+rankprofile[].fef.property[].value "4 * (var1 + var2)"
+rankprofile[].fef.property[].name "vespa.rank.firstphase"
+rankprofile[].fef.property[].value "rankingExpression(firstphase)"
+rankprofile[].fef.property[].name "rankingExpression(firstphase).rankingScript"
+rankprofile[].fef.property[].value "match + fieldMatch(title) + rankingExpression(myfeature)"
+rankprofile[].fef.property[].name "vespa.rank.secondphase"
+rankprofile[].fef.property[].value "rankingExpression(secondphase)"
+rankprofile[].fef.property[].name "rankingExpression(secondphase).rankingScript"
+rankprofile[].fef.property[].value "rankingExpression(fourtimessum@2b1138e8965e7ff5.67f1e87166cfef86) + 0 * rankingExpression(macro_with_dollar$)"
+rankprofile[].fef.property[].name "vespa.summary.feature"
+rankprofile[].fef.property[].value "firstPhase"
+rankprofile[].fef.property[].name "vespa.summary.feature"
+rankprofile[].fef.property[].value "rankingExpression(myfeature)"
+rankprofile[].fef.property[].name "vespa.summary.feature"
+rankprofile[].fef.property[].value "rankingExpression(anotherfeature)"
+rankprofile[].fef.property[].name "vespa.summary.feature"
+rankprofile[].fef.property[].value "rankingExpression(yetanotherfeature)"
+rankprofile[].fef.property[].name "vespa.summary.feature"
+rankprofile[].fef.property[].value "rankingExpression(macro_with_dollar$)"
+rankprofile[].fef.property[].name "vespa.feature.rename"
+rankprofile[].fef.property[].value "rankingExpression(anotherfeature)"
+rankprofile[].fef.property[].name "vespa.feature.rename"
+rankprofile[].fef.property[].value "anotherfeature"
+rankprofile[].fef.property[].name "vespa.feature.rename"
+rankprofile[].fef.property[].value "rankingExpression(yetanotherfeature)"
+rankprofile[].fef.property[].name "vespa.feature.rename"
+rankprofile[].fef.property[].value "yetanotherfeature"
+rankprofile[].fef.property[].name "vespa.feature.rename"
+rankprofile[].fef.property[].value "rankingExpression(macro_with_dollar$)"
+rankprofile[].fef.property[].name "vespa.feature.rename"
+rankprofile[].fef.property[].value "macro_with_dollar$"
+rankprofile[].name "constantsAndMacro"
+rankprofile[].fef.property[].name "rankingExpression(c).rankingScript"
+rankprofile[].fef.property[].value "attribute(num)"
+rankprofile[].fef.property[].name "vespa.rank.firstphase"
+rankprofile[].fef.property[].value "rankingExpression(firstphase)"
+rankprofile[].fef.property[].name "rankingExpression(firstphase).rankingScript"
+rankprofile[].fef.property[].value "attribute(num) * 2.0 + 3.0"
+rankprofile[].fef.property[].name "vespa.summary.feature"
+rankprofile[].fef.property[].value "firstPhase"
+rankprofile[].name "doc"
+rankprofile[].fef.property[].name "rankingExpression(myfeature).rankingScript"
+rankprofile[].fef.property[].value "fieldMatch(title) + freshness(timestamp)"
+rankprofile[].fef.property[].name "rankingExpression(otherfeature@6b0a229a66fcaa04).rankingScript"
+rankprofile[].fef.property[].value "nativeRank(title,body)"
+rankprofile[].fef.property[].name "rankingExpression(otherfeature).rankingScript"
+rankprofile[].fef.property[].value "nativeRank(foo,body)"
+rankprofile[].fef.property[].name "vespa.rank.firstphase"
+rankprofile[].fef.property[].value "rankingExpression(firstphase)"
+rankprofile[].fef.property[].name "rankingExpression(firstphase).rankingScript"
+rankprofile[].fef.property[].value "rankingExpression(myfeature) * 10"
+rankprofile[].fef.property[].name "vespa.rank.secondphase"
+rankprofile[].fef.property[].value "rankingExpression(secondphase)"
+rankprofile[].fef.property[].name "rankingExpression(secondphase).rankingScript"
+rankprofile[].fef.property[].value "rankingExpression(otherfeature@6b0a229a66fcaa04) * rankingExpression(myfeature)"
+rankprofile[].fef.property[].name "vespa.summary.feature"
+rankprofile[].fef.property[].value "rankingExpression(myfeature)"
+rankprofile[].fef.property[].name "vespa.feature.rename"
+rankprofile[].fef.property[].value "rankingExpression(myfeature)"
+rankprofile[].fef.property[].name "vespa.feature.rename"
+rankprofile[].fef.property[].value "myfeature"
diff --git a/config-model/src/test/derived/rankingmacros/rankingmacros.sd b/config-model/src/test/derived/rankingmacros/rankingmacros.sd
new file mode 100644
index 00000000000..84598cb483a
--- /dev/null
+++ b/config-model/src/test/derived/rankingmacros/rankingmacros.sd
@@ -0,0 +1,105 @@
+# Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+schema rankingmacros {
+
+ document rankingmacros {
+ field title type string {
+ indexing: index
+ }
+ field timestamp type long {
+ indexing: attribute
+ }
+ field description type string {
+ indexing: index
+ }
+ field num type int {
+ indexing: attribute
+ }
+ field abstract type string {
+ indexing: index
+ }
+ field body type string {
+ indexing: index
+ }
+ field usstaticrank type string {
+ indexing: attribute
+ }
+ field boostmax type string {
+ indexing: index
+ }
+ field entitytitle type string {
+ indexing: index
+ }
+ }
+
+ rank-profile standalone {
+ macro fourtimessum(var1, var2) {
+ expression: 4*(var1+var2)
+ }
+ macro myfeature() {
+ expression {
+ 7 * attribute(num)
+ }
+ }
+ macro anotherfeature() {
+ expression: 10*myfeature
+ }
+ macro yetanotherfeature() {
+ expression: 100*rankingExpression(myfeature) # legacy form
+ }
+ macro macro_with_dollar$() { # Not allowed
+ expression: 69
+ }
+ first-phase {
+ expression: match + fieldMatch(title) + myfeature
+ }
+ second-phase {
+ expression: fourtimessum(match,match) + 0 * macro_with_dollar$
+ }
+ summary-features {
+ firstPhase
+ rankingExpression(myfeature)
+ anotherfeature
+ yetanotherfeature
+ macro_with_dollar$
+ }
+ }
+
+ # Profile with macro and constants
+ rank-profile constantsAndMacro {
+ macro c() {
+ expression: attribute(num)
+ }
+
+ constants {
+ a: 2
+ b: 3
+ }
+
+ first-phase {
+ expression: attribute(num) * a + b
+ }
+
+ summary-features {
+ firstPhase
+ }
+ }
+
+ # The example in the docs
+ rank-profile doc inherits default {
+ macro myfeature() {
+ expression: fieldMatch(title) + freshness(timestamp)
+ }
+ macro otherfeature(foo) {
+ expression{ nativeRank(foo, body) }
+ }
+
+ first-phase {
+ expression: myfeature * 10
+ }
+ second-phase {
+ expression: otherfeature(title) * myfeature
+ }
+ summary-features: myfeature
+ }
+
+}
diff --git a/config-model/src/test/java/com/yahoo/schema/derived/RankProfilesTestCase.java b/config-model/src/test/java/com/yahoo/schema/derived/RankProfilesTestCase.java
index 5c24b32e275..a4c03291ce2 100644
--- a/config-model/src/test/java/com/yahoo/schema/derived/RankProfilesTestCase.java
+++ b/config-model/src/test/java/com/yahoo/schema/derived/RankProfilesTestCase.java
@@ -17,4 +17,9 @@ public class RankProfilesTestCase extends AbstractExportingTestCase {
void testRankProfiles() throws IOException, ParseException {
assertCorrectDeriving("rankprofiles", null, new TestProperties(), new TestableDeployLogger());
}
+
+ @Test
+ void testMacrosInRankProfiles() throws IOException, ParseException {
+ assertCorrectDeriving("rankingmacros", null, new TestProperties(), new TestableDeployLogger());
+ }
}