aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/derived/rankingmacros/rankingmacros.sd
blob: d4ab5ba74c0328727a052c446435d79f272d3210 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Copyright Vespa.ai. 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
  }

}