summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-10-25 10:58:00 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2021-10-25 11:01:02 +0200
commite1abecd7a786c78a4d4c233a5440302a30454b98 (patch)
treeece1836ca13e66e4a4c26a2792808ee3c8846ef3
parent85c88300cdab6541fea85cb69a7b4f844bb91250 (diff)
onrerank -> on-first-phase and add on-second-phase
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java8
-rw-r--r--config-model/src/main/javacc/SDParser.jj6
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java38
3 files changed, 31 insertions, 21 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 21aa5661fa4..85b8d7fbe79 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java
@@ -675,7 +675,7 @@ public class RankProfile implements Cloneable {
}
public static class MutateOperation {
- public enum Phase { onmatch, onrerank, onsummary}
+ public enum Phase { onmatch, on_first_phase, on_second_phase, onsummary}
final Phase phase;
final String attribute;
final String operation;
@@ -689,9 +689,9 @@ public class RankProfile implements Cloneable {
public void addMutateOperation(MutateOperation.Phase phase, String attribute, String operation) {
mutateOperations.add(new MutateOperation(phase, attribute, operation));
- //TODO once query control of these are gone we should change these to 'vespa.mutate.'
- addRankProperty("vespa.execute." + phase + ".attribute", attribute);
- addRankProperty("vespa.execute." + phase + ".operation", operation);
+ String prefix = "vespa.mutate." + phase.toString().replace('-', '_');
+ addRankProperty(prefix + ".attribute", attribute);
+ addRankProperty(prefix + ".operation", operation);
}
public List<MutateOperation> getMutateOperations() { return mutateOperations; }
diff --git a/config-model/src/main/javacc/SDParser.jj b/config-model/src/main/javacc/SDParser.jj
index 3f4b6ab8206..e6a5d1f2e4e 100644
--- a/config-model/src/main/javacc/SDParser.jj
+++ b/config-model/src/main/javacc/SDParser.jj
@@ -209,7 +209,8 @@ TOKEN :
| < DOCUMENT: "document" >
| < OPERATION: "operation" >
| < ON_MATCH: "on-match" >
-| < ON_RERANK: "on-rerank" >
+| < ON_FIRST_PHASE: "on-first-phase" >
+| < ON_SECOND_PHASE: "on-second-phase" >
| < ON_SUMMARY: "on-summary" >
| < STRUCT: "struct" >
| < INHERITS: "inherits" >
@@ -2115,7 +2116,8 @@ void mutate_operation(RankProfile profile) :
}
{
( <ON_MATCH> { phase = RankProfile.MutateOperation.Phase.onmatch; }
- | <ON_RERANK> { phase = RankProfile.MutateOperation.Phase.onrerank; }
+ | <ON_FIRST_PHASE> { phase = RankProfile.MutateOperation.Phase.on_first_phase; }
+ | <ON_SECOND_PHASE> { phase = RankProfile.MutateOperation.Phase.on_second_phase; }
| <ON_SUMMARY> { phase = RankProfile.MutateOperation.Phase.onsummary; }
)
lbrace() attribute = identifier() operation = mutate_expr() (<NL>)* <RBRACE>
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java
index ceacd08bddc..637f7571a68 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java
@@ -105,7 +105,10 @@ public class RankPropertiesTestCase extends AbstractSchemaTestCase {
" on-match {",
" synthetic_attribute_a += 7",
" }",
- " on-rerank {",
+ " on-first-phase {",
+ " synthetic_attribute_b +=1",
+ " }",
+ " on-second-phase {",
" synthetic_attribute_b = 1.01",
" }",
" on-summary {",
@@ -129,27 +132,32 @@ public class RankPropertiesTestCase extends AbstractSchemaTestCase {
Schema schema = builder.getSearch();
RankProfile a = rankProfileRegistry.get(schema, "a");
List<RankProfile.MutateOperation> operations = a.getMutateOperations();
- assertEquals(3, operations.size());
+ assertEquals(4, operations.size());
assertEquals(RankProfile.MutateOperation.Phase.onmatch, operations.get(0).phase);
assertEquals("synthetic_attribute_a", operations.get(0).attribute);
assertEquals("+=7", operations.get(0).operation);
- assertEquals(RankProfile.MutateOperation.Phase.onrerank, operations.get(1).phase);
+ assertEquals(RankProfile.MutateOperation.Phase.on_first_phase, operations.get(1).phase);
assertEquals("synthetic_attribute_b", operations.get(1).attribute);
- assertEquals("=1.01", operations.get(1).operation);
- assertEquals(RankProfile.MutateOperation.Phase.onsummary, operations.get(2).phase);
- assertEquals("synthetic_attribute_c", operations.get(2).attribute);
- assertEquals("-=1", operations.get(2).operation);
+ assertEquals("+=1", operations.get(1).operation);
+ assertEquals(RankProfile.MutateOperation.Phase.on_second_phase, operations.get(2).phase);
+ assertEquals("synthetic_attribute_b", operations.get(2).attribute);
+ assertEquals("=1.01", operations.get(2).operation);
+ assertEquals(RankProfile.MutateOperation.Phase.onsummary, operations.get(3).phase);
+ assertEquals("synthetic_attribute_c", operations.get(3).attribute);
+ assertEquals("-=1", operations.get(3).operation);
AttributeFields attributeFields = new AttributeFields(schema);
RawRankProfile raw = new RawRankProfile(a, new LargeRankExpressions(new MockFileRegistry()), new QueryProfileRegistry(), new ImportedMlModels(), attributeFields, new TestProperties());
- assertEquals(7, raw.configProperties().size());
- assertEquals("(vespa.execute.onmatch.attribute, synthetic_attribute_a)", raw.configProperties().get(0).toString());
- assertEquals("(vespa.execute.onmatch.operation, +=7)", raw.configProperties().get(1).toString());
- assertEquals("(vespa.execute.onrerank.attribute, synthetic_attribute_b)", raw.configProperties().get(2).toString());
- assertEquals("(vespa.execute.onrerank.operation, =1.01)", raw.configProperties().get(3).toString());
- assertEquals("(vespa.execute.onsummary.attribute, synthetic_attribute_c)", raw.configProperties().get(4).toString());
- assertEquals("(vespa.execute.onsummary.operation, -=1)", raw.configProperties().get(5).toString());
- assertEquals("(vespa.rank.firstphase, a)", raw.configProperties().get(6).toString());
+ assertEquals(9, raw.configProperties().size());
+ assertEquals("(vespa.mutate.onmatch.attribute, synthetic_attribute_a)", raw.configProperties().get(0).toString());
+ assertEquals("(vespa.mutate.onmatch.operation, +=7)", raw.configProperties().get(1).toString());
+ assertEquals("(vespa.mutate.on_first_phase.attribute, synthetic_attribute_b)", raw.configProperties().get(2).toString());
+ assertEquals("(vespa.mutate.on_first_phase.operation, +=1)", raw.configProperties().get(3).toString());
+ assertEquals("(vespa.mutate.on_second_phase.attribute, synthetic_attribute_b)", raw.configProperties().get(4).toString());
+ assertEquals("(vespa.mutate.on_second_phase.operation, =1.01)", raw.configProperties().get(5).toString());
+ assertEquals("(vespa.mutate.onsummary.attribute, synthetic_attribute_c)", raw.configProperties().get(6).toString());
+ assertEquals("(vespa.mutate.onsummary.operation, -=1)", raw.configProperties().get(7).toString());
+ assertEquals("(vespa.rank.firstphase, a)", raw.configProperties().get(8).toString());
}
}