aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/derived/twostreamingstructs/streamingstruct.sd
blob: 8e70fdfc8d18ee25bca81efe346754dc11da79d2 (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
schema streamingstruct {

  document streamingstruct {
    field coupleof type string {
      indexing: index | summary
    }

    field normalfields type string {
      indexing: index | summary
      summary anothersummaryfield {
        source: normalfields
      }
    }

    struct s1 {
      field f1 type string { }
      field f1s type string {
        match: substring
      }
      field f2 type int { }
      field f3 type double { }
      # Allow default matchtypes in struct. Can be overridden.
      # No index/attribute related stuff. It is only a datatype definition.
    }

    struct ns1 {
      field nf1 type s1 { }
      field nf1s type s1 {
        match: substring
      }
      field nf2 type string { }
      # May specify nested structs.
    }

    field a type s1 {
      indexing: summary
      # Will generate attribute a.f1, a.f1s, a.f2, a.f3
      # with datatypes preserved.
      # No customisation.
      # a will be a synonym for all (a.*)
    }
    field m type map<long, string> {
      indexing: summary
      # Will generate attribute m.key, m.value
      # with datatypes preserved.
      # m will be a synonym for all (m.*)
    }
    field b type s1 {
      indexing: index | summary
      # Will generate index b.f1, b.f1s, b.f2, b.f3
      # with datatypes preserved if backend allows.
      # No customisation.
      # b will be synonym for all (b.*).
    }
    field c type s1 {
      struct-field f1 {
        # Whatever you normally write in a field declaration
        indexing: attribute | summary  # -> Generates attribute c.f1
      }
      struct-field f1s {
        indexing: index | summary      # -> c.f1s
        match: prefix
      }
      struct-field f3 {
        indexing: index | summary      # -> c.f3
      }
      # attribute c will be synonym for c.f1.
      # Index c will be synonym for c.f1s OR c.f3.
      # Indexed search can handle that however they want.
    }
    field c2 type s1 {
      struct-field f1 {
        # Whatever you normally write in a field declaration
        indexing: attribute | summary  # -> Generates attribute c2.f1
      }
      struct-field f1s {
        indexing: index | summary      # -> c2.f1s
        match: suffix
      }
      struct-field f2 {
        indexing: index | summary      # -> c2.f2
      }
      struct-field f3 {
        indexing: index | summary      # -> c2.f3
      }
    }
    field c3 type s1 {
      # Uses all sub fields, but not summary for all. 
      struct-field f1 {
        indexing: attribute | summary
      }
      struct-field f1s {
        indexing: index
        match: prefix
      }
      struct-field f2 {
        indexing: index | summary
      }
      struct-field f3 {
        indexing: index | summary
      }
    }
    field n type ns1 {
      struct-field nf1 {
        struct-field f1 {
          indexing: index | summary
        }
        struct-field f1s {
          indexing: index | summary
          match: prefix
        }
        struct-field f3 {
          indexing: index
        }
      }
      struct-field nf1s {
        indexing: index | summary
      }
      struct-field nf2 {
        indexing: index | summary
      }
      # Will generate indexes n.nf1.f1, n.nf1.f1s, n.nf1.f3,
      # n.nf1s.f1, n.nf1s.f1s, n.nf1s.f2, n.nf1s.f3
      # and n.nf2.
      # n will be synonym for all 8,
      # n.nf1 will be synonym for the first 3 and
      # n.nf1s will be synonym for the next 4
    }

    field array1 type array<s1> {
      indexing: summary
    }
    field array2 type array<s1> {
      indexing: index | summary
    }
    field array3 type array<s1> {
      struct-field f1 {
        indexing: attribute | summary  # -> Generates attribute array3.f1
      }
      struct-field f1s {
        indexing: index | summary      # -> array3.f1s
        match: prefix
      }
      struct-field f3 {
        indexing: index | summary      # -> array3.f3
      }
    }
    field subject type s1 {
      struct-field f1 {
        indexing: summary
        summary subject {
          source:subject.f1
        }
      }
    }
    field d type s1 {
      indexing: index
      # override matching for all subfields
      match: prefix
    }
    field e type s1 {
      indexing: index
      # override matching for all subfields
      match: substring
    }
    field f type s1 {
      indexing: index
      # override matching for all subfields
      match: suffix
    }
    field g type string {
      indexing: index | summary
      summary: dynamic
    }
  }

  document-summary summ {
    summary snippet {
      dynamic
      source: a.f1, b.f2
    }
    summary snippet2 {
      source: a.f1, b.f1, b.f2
    }
  }

}