-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathschemas.html
More file actions
4964 lines (4649 loc) · 183 KB
/
schemas.html
File metadata and controls
4964 lines (4649 loc) · 183 KB
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
# Copyright Vespa.ai. All rights reserved.
title: "Schema reference"
redirect_from:
- en/reference/schema-reference.html
---
<p>
This reference documents the syntax and content of schemas, document types, and fields.
This is a reference, see <a href="../../basics/schemas.html">schemas</a> for an overview and examples.
</p>
<h2 id="syntax">Syntax</h2>
<p>
Throughout this document, a string in square brackets represents some argument.
The whole string, including the brackets, is replaced by a concrete string in a schema.
</p><p>
Constructs in schemas have a regular syntax.
Each element starts with the element <em>identifier</em>,
possibly followed by the <em>name</em> of this particular occurrence of the element,
possibly followed by a space-separated list of interleaved <em>attribute names</em>
and <em>attribute values</em>, possibly followed by the <em>element body</em>.
Thus, one will find elements of these varieties:
</p>
<p>
<code>[element-identifier] : [element-body]</code><br/>
<code>[element-identifier] [element-name] : [element-body]</code><br/>
<code>[element-identifier] [element-name] [attribute-name] [attribute-value]</code><br/>
<code>[element-identifier] [element-name] [attribute-name] [attribute-value] {
[element-body]
}</code><br/>
</p>
<p>
One-line element values start with a colon and end with a newline.
</p>
<p>
Multiline values (for fields supporting them) are any block of text enclosed in curly brackets.
</p>
<p>
Comments may be inserted anywhere and start with a hash (#).
</p>
<p>
Names are <em>identifiers</em>, they must match <code>["a"-"z","A"-"Z", "_"]["a"-"z","A"-"Z","0"-"9","_"]*</code>.
</p>
<p>A schema file is not sensitive to indentation.</p>
<h2 id="elements">Elements</h2>
<p>
Elements and structure of a schema file:
</p>
<pre class="pre-config">
<a href="#schema">schema</a>
<a href="#document">document</a>
<a href="#struct">struct</a>
<a href="#field">field</a>
<a href="#match">match</a>
<a href="#field">field</a><span style="display:none"> <!-- Keep field types here for the doc search direct display, hide for clarity -->
<a href="#array">array<type></a>
<a href="#bool">bool</a>
<a href="#byte">byte</a>
<a href="#double">double</a>
<a href="#float">float</a>
<a href="#int">int</a>
<a href="#long">long</a>
<a href="#map">map<key-type,value-type></a>
<a href="#position">position</a>
<a href="#predicate">predicate</a>
<a href="#raw">raw</a>
<a href="#reference">reference<document-type></a>
<a href="#string">string</a>
<a href="#struct-name">struct-name</a>
<a href="#tensor">tensor(dimension-1,...,dimension-N)</a>
<a href="#uri">uri</a>
<a href="#weightedset">weightedset<element-type></a>
<a href="#weightedset-properties">weightedset</a></span>
<a href="#alias">alias</a>
<a href="#attribute">attribute</a>
<a href="#distance-metric">distance-metric</a>
<a href="#bolding">bolding</a>
<a href="#dictionary">dictionary</a>
<a href="#id">id</a>
<a href="#index">index</a>
<a href="#index-hnsw">hnsw</a>
<a href="#indexing">indexing</a>
<a href="#linguistics">linguistics</a>
<a href="#match">match</a>
<a href="#normalizing">normalizing</a>
<a href="#query-command">query-command</a>
<a href="#rank">rank</a>
<a href="#rank-type">rank-type</a>
<a href="#sorting">sorting</a>
<a href="#stemming">stemming</a>
<a href="#struct-field">struct-field</a>
<a href="#indexing">indexing</a>
<a href="#match">match</a>
<a href="#query-command">query-command</a>
<a href="#struct-field">struct-field</a>
…
<a href="#summary">summary</a>
<a href="#summary-to">summary-to <b>DEPRECATED</b></a>
<a href="#summary">summary</a>
<a href="#summary-to">summary-to <b>DEPRECATED</b></a>
<a href="#weight">weight</a>
<a href="#compression">compression</a>
<a href="#index">index</a>
<a href="#field">field</a>
<a href="#fieldset">fieldset</a>
<a href="#rank-profile">rank-profile</a>
<a href="#diversity">diversity</a>
<a href="#diversity-attribute">attribute</a>
<a href="#diversity-min-groups">min-groups</a>
<a href="#match-phase">match-phase</a>
<a href="#match-phase-attribute">attribute</a>
<a href="#match-phase-order">order</a>
<a href="#match-phase-total-max-hits">total-max-hits</a>
<a href="#match-phase-max-hits">max-hits</a>
<a href="#firstphase-rank">first-phase</a>
<a href="#total-keep-rank-count">total-keep-rank-count</a>
<a href="#keep-rank-count">keep-rank-count</a>
<a href="#rank-score-drop-limit">rank-score-drop-limit</a>
<a href="#expression">expression</a>
<a href="#secondphase-rank">second-phase</a>
<a href="#expression">expression</a>
<a href="#secondphase-rank-score-drop-limit">rank-score-drop-limit</a>
<a href="#secondphase-total-rerank-count">total-rerank-count</a>
<a href="#secondphase-rerank-count">rerank-count</a>
<a href="#globalphase-rank">global-phase</a>
<a href="#expression">expression</a>
<a href="#globalphase-rerank-count">rerank-count</a>
<a href="#globalphase-rank-score-drop-limit">rank-score-drop-limit</a>
<a href="#function-rank">function [name] </a>
<a href="#inputs">inputs</a>
<a href="#constants">constants</a>
<a href="#onnx-model">onnx-model</a>
<a href="#significance">significance</a>
<a href="#rank-properties">rank-properties</a>
<a href="#match-features">match-features</a>
<a href="#mutate">mutate</a>
<a href="#on-match">on-match</a>
<a href="#on-first-phase">on-first-phase</a>
<a href="#on-second-phase">on-second-phase</a>
<a href="#on-summary">on-summary</a>
<a href="#summary-features">summary-features</a>
<a href="#rank-features">rank-features</a>
<a href="#ignore-default-rank-features">ignore-default-rank-features</a>
<a href="#num-threads-per-search">num-threads-per-search</a>
<a href="#num-search-partitions">num-search-partitions</a>
<a href="#min-hits-per-thread">min-hits-per-thread</a>
<a href="#termwise-limit">termwise-limit</a>
<a href="#post-filter-threshold">post-filter-threshold</a>
<a href="#approximate-threshold">approximate-threshold</a>
<a href="#filter-first-threshold">filter-first-threshold</a>
<a href="#filter-first-exploration">filter-first-exploration</a>
<a href="#exploration-slack">exploration-slack</a>
<a href="#target-hits-max-adjustment-factor">target-hits-max-adjustment-factor</a>
<a href="#filter-threshold">filter-threshold</a>
<a href="#rank">rank</a>
<a href="#rank-filter-threshold">filter-threshold</a>
<a href="#rank-element-gap">element-gap</a>
<a href="#rank-type">rank-type</a>
<a href="#weakand">weakand</a>
<a href="#weakand-stopword-limit">stopword-limit</a>
<a href="#weakand-adjust-target">adjust-target</a>
<a href="#weakand-allow-drop-all">allow-drop-all</a>
<a href="#rank-profile">rank-profile (inner)</a>
<a href="#constant">constant</a>
<a href="#onnx-model">onnx-model</a>
<a href="#stemming">stemming</a>
<a href="#document-summary">document-summary</a>
<a href="#summary">summary</a>
<a href="#import-field">import field</a>
<a href="#raw-as-base64-in-summary">raw-as-base64-in-summary</a>
</pre>
<h2 id="schema">schema</h2>
<p>The root element of schemas.
A schema describes a type of data and what we should compute over it.
A schema must be defined in a file named <code>[schema-name].sd</code>.</p>
<pre>
schema [name] inherits [name] {
[body]
}
</pre>
<p>The <code>inherits</code> attribute is optional.
If a schema is inherited, this schema will include all the constructs of it as if they
were defined in this schema (except the parent document type).
The document type in this must declare that it inherits the document type of the parent schema.
</p>
<p>The body is mandatory and may contain:</p>
<table class="table">
<thead>
<tr><th>Name</th><th>Occurrence</th><th>Description</th></tr>
</thead><tbody>
<tr><td><a href="#document">document</a></td>
<td>One</td>
<td>A document type defined in this schema</td>
</tr>
<tr><td><a href="#field">field</a></td>
<td style="white-space:nowrap;">Zero to many</td>
<td>A field not contained in the document.
Use <em>synthetic fields</em> (outside <a href="#document">document</a>) to derive new field values
to be placed in the indexing structure from document fields.
Find examples in <a href="../../operations/reindexing.html#use-cases">reindexing</a>.</td>
</tr>
<tr><td><a href="#fieldset">fieldset</a></td>
<td>Zero to many</td>
<td>Group document fields together for searching</td>
</tr>
<tr><td><a href="#rank-profile">rank-profile</a></td>
<td>Zero to many</td>
<td>A bundle of ranking functions and settings, selectable in a query.</td>
</tr>
<tr><td><a href="#constant">constant</a></td>
<td>Zero to many</td>
<td>A constant tensor located in a file used for ranking</td>
</tr>
<tr><td><a href="#onnx-model">onnx-model</a></td>
<td>Zero to many</td>
<td>An ONNX model located in the application package used for ranking</td>
</tr>
<tr><td><a href="#stemming">stemming</a></td>
<td>Zero or one</td>
<td>The default stemming setting.</td>
</tr>
<tr><td><a href="#raw-as-base64-in-summary">raw-as-base64-in-summary</a></td>
<td>Zero or one</td>
<td>Base64 encode raw fields in summary rather than using an escaped string. The default is true.</td>
</tr>
<tr><td style="white-space: nowrap"><a href="#document-summary">document-summary</a></td>
<td>Zero to many</td>
<td>An explicitly defined document summary</td>
</tr>
<tr><td><a href="#import-field">import field</a></td>
<td>Zero to many</td>
<td>Import a field value from a global document</td>
</tr>
</tbody>
</table>
<h2 id="document">document</h2>
<p>
Contained in <a href="#schema">schema</a> and describes a document type.
This can also be the root of the schema, if the document is not to be queried directly.
</p>
<pre>
document [name] inherits [name-list] {
[body]
}
</pre>
<p>
The document name is optional; it defaults to the containing <code>schema</code>
element's name. If there is no containing <code>schema</code> element, the document name is required. If the document with a name is defined inside a schema, the document name must match the <code>schema</code> element's name. The reference to <em>document type</em> in the documentation refers to the document name defined here.
</p>
<p>
The <code>inherits</code> attribute is optional
and has as value a comma-separated list of names of other document types.
A document type may inherit the fields of one or more other document types,
see <a href="/en/schemas/inheritance-in-schemas.html">document inheritance</a> for examples.
If no document types are explicitly inherited,
the document inherits the generic <code>document</code> type.
</p>
<p>The body of a document type is optional and may contain:</p>
<table class="table">
<thead>
<tr><th>Name</th><th>Occurrence</th><th>Description</th></tr>
</thead><tbody>
<tr><td><a href="#struct">struct</a></td>
<td>Zero to many</td>
<td>A struct type definition for this document.</td>
</tr>
<tr><td><a href="#field">field</a></td>
<td>Zero to many</td>
<td>A field of this document.</td>
</tr>
<tr><td><a href="#compression">compression</a></td>
<td>Zero to one</td>
<td>Specifies compression options for documents of this document type in storage.</td>
<!-- ToDo Check does this apply to proton? -->
</tr>
</tbody>
</table>
<h2 id="struct">struct</h2>
<p>
Contained in <a href="#document">document</a>.
Defines a composite type.
A struct consists of zero or more fields that the user can access together as one.
The struct has to be defined before it is used as a type in a field specification.
</p>
<pre>
struct [name] {
[body]
}
</pre>
<p>The body of a struct is optional and may contain:</p>
<table class="table">
<thead>
<tr><th>Name</th><th>Occurrence</th><th>Description</th></tr>
</thead><tbody>
<tr><td><a href="#field">field</a></td>
<td>Zero to many</td>
<td>A field of this struct.</td>
</tr>
</tbody>
</table>
<h2 id="field">field</h2>
<p>
Contained in
<a href="#schema">schema</a>,
<a href="#document">document</a>,
or
<a href="#struct">struct</a>.
Defines a named value with a type and (optionally) how this field
should be stored, indexed, searched, presented, and how it should influence ranking.
</p>
<pre>
field [name] type [type-name] {
[body]
}
</pre>
Do not use names that are used for other purposes in the indexing language
or other places in the schema file. Reserved names are:
<ul>
<li>attribute</li>
<li>body</li>
<li>case</li>
<li>context</li>
<li>documentid</li>
<li>else</li>
<li>header</li>
<li>hit</li>
<li>host</li>
<li>if</li>
<li>index</li>
<li>position</li>
<li>reference</li>
<li>relevancy</li>
<li>sddocname</li>
<li>summary</li>
<li>switch</li>
<li>tokenize</li>
</ul>
<p>
Other names not to use include any words that start with a number or include special characters.
</p><p>
The <em>type</em> attribute is mandatory - supported types:
</p>
<table class="table">
<thead>
<tr>
<th>Field type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr><th>array<type></th>
<td>
<p id="array">
For single-value (primitive) types, use array<type> to create an array field of the element type:
</p>
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>Each element is indexed separately</td>
</tr><tr>
<th>Attribute</th>
<td>Added as an array attribute</td>
</tr><tr>
<th>Summary</th>
<td>Added as an array summary field</td>
</tr>
</tbody>
</table>
<p>
Also used to create an array field of the given <a href="#struct">struct type</a>.
The struct type must be defined separately. Example:
</p>
<pre>
struct person {
field first_name type string {}
field last_name type string {}
}
field people type array<person> {
indexing: summary
summary: matched-elements-only
struct-field first_name {
indexing: attribute
attribute: fast-search
}
}
</pre>
<p>
The entire <em>people</em> field is part of the document summary.
The <a href="#struct-field">struct field</a> <em>first_name</em> is defined as an <em>attribute</em> for searching,
with <a href="../../content/attributes.html#fast-search">fast-search</a>.
A subset, or all, of the struct fields can be defined as attributes.
</p>
<p>
Use the <a href="../querying/yql.html#sameelement">sameElement</a>
operator to ensure matches in the same struct field instance.
</p>
<p>
Use <a href="#matched-elements-only">matched-elements-only</a>
to reduce the amount of data that is returned in the document summary.
</p>
{% include important.html content="
<code>key</code> and <code>value</code> are reserved words in an array<struct>,
as these are used to implement <a href='#map'>map</a>.
Do not use these as struct-field names."%}
<p>Restrictions:</p>
<ul>
<li>Array of struct types does not support <a href="../../basics/ranking.html">ranking features</a>
and can only be used for matching and filtering.</li>
<li>All struct arrays can be fed, retrieved, and used in document summaries.</li>
<li>Some parts of struct arrays can be searched in <a href="../applications/services/content.html#document">indexed search mode</a>,
while all parts of struct arrays can be searched in <a href="../../performance/streaming-search.html">streaming search</a>.
See below for supported cases.</li>
</ul>
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>
Only supported in <a href="../../performance/streaming-search.html#differences-in-streaming-search">streaming search</a>.
Set this on the top-level struct array field to make all parts searchable.
</td>
</tr><tr>
<th>Attribute</th>
<td>
Only supported for <a href="#struct-field">struct fields</a>
that have primitive types (bool, string, int, long, byte, float, double).
Any struct field must be defined as an attribute to be used for searching.
The struct type can still contain fields of non-primitive types,
as long as these are not defined as attributes.
</td>
</tr><tr>
<th>Summary</th>
<td>Added as an array summary field</td>
</tr>
</tbody>
</table>
</td></tr>
<tr><th>bool</th>
<td><p id="bool">Use for boolean values.</p>
<pre>
field alive type bool {
indexing: summary | attribute
}
</pre>
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>Not supported</td>
</tr><tr>
<th>Attribute</th>
<td>Added as a boolean</td>
</tr><tr>
<th>Summary</th>
<td>Added as a boolean value (<code>true</code> or <code>false</code>)</td>
</tr>
</tbody>
</table>
{% include important.html content="
Defaults to <code>false</code> if not specified.
"%}
</td></tr>
<tr><th>byte</th>
<td><p id="byte">Use for single 8-bit numbers.</p>
<pre>
field smallnumber type byte {
indexing: summary | attribute
}
</pre>
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>Not supported. An attribute will automatically be used instead</td>
</tr><tr>
<th>Attribute</th>
<td>Added as a byte which supports range searches</td>
</tr><tr>
<th>Summary</th>
<td>Added as a byte</td>
</tr>
</tbody>
</table>
</td></tr>
<tr><th>double</th>
<td><p id="double">Use for high precision floating point numbers (64-bit IEEE 754 double).</p>
<pre>
field mydouble type double {
indexing: summary | attribute
}
</pre>
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>Not supported. An attribute will automatically be used instead</td>
</tr><tr>
<th>Attribute</th>
<td>Added as a 64-bit IEEE 754 double which supports range searches</td>
</tr><tr>
<th>Summary</th>
<td>Added as a 64-bit IEEE 754 double</td>
</tr>
</tbody>
</table>
</td></tr>
<tr><th>float</th>
<td><p id="float">Use for floating point numbers (32-bit IEEE 754 float).</p>
<pre>
field myfloat type float {
indexing: summary | attribute
}
</pre>
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>Not supported. An attribute will automatically be used instead</td>
</tr><tr>
<th>Attribute</th>
<td>Added as a 32-bit IEEE 754 float which supports range searches</td>
</tr><tr>
<th>Summary</th>
<td>Added as a 32-bit IEEE 754 float</td>
</tr>
</tbody>
</table>
</td></tr>
<tr><th>int</th>
<td><p id="int">Use for single 32-bit integers.</p>
<pre>
field release_year type int {
indexing: summary | attribute
}
</pre>
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>Not supported. An attribute will automatically be used instead</td>
</tr><tr>
<th>Attribute</th>
<td>Becomes integer attributes, which supports range grouping and range searches</td>
</tr><tr>
<th>Summary</th>
<td>Added as a 32-bit integer</td>
</tr>
</tbody>
</table>
</td></tr>
<tr><th>long</th>
<td><p id="long">Use for single 64-bit integers.</p>
<pre>
field bignumber type long {
indexing: summary | attribute
}
</pre>
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>Not supported. An attribute will automatically be used instead</td>
</tr><tr>
<th>Attribute</th>
<td>Becomes a 64-bit integer attribute, which supports range grouping and range searches</td>
</tr><tr>
<th>Summary</th>
<td>Added as a 64-bit integer</td>
</tr>
</tbody>
</table>
</td></tr>
<tr><th>map<key-type,value-type></th>
<td>
<p id="map">
Use to create a map where each unique key is mapped to a single value.
Any primitive type can be used as <em>key-type</em> and any primitive type or Vespa struct type as <em>value-type</em>.
Example of a map of primitive types,
where the <em>key</em> and <em>value</em> fields are specified as <em>attributes</em>:
</p>
<pre>
field my_map type map<string, int> {
indexing: summary
struct-field key { indexing: attribute }
struct-field value { indexing: attribute }
}
</pre>
<p>
Note that a Vespa map entry is handled as a <em>struct</em>
with a <em>key</em> and <em>value</em> field
with <em>key-type</em> and <em>value-type</em> as types.
This explains the <em>struct-field</em> syntax above.
The full <em>my_map</em> field is configured into the document summary.
</p>
<p>A more complex example is a map of struct:</p>
<pre>
struct person {
field first_name type string {}
field last_name type string {}
field age type int {}
}
field identities type map<string, person> {
indexing: summary
summary: matched-elements-only
struct-field key {
indexing: attribute
attribute: fast-search
}
struct-field value.first_name {
indexing: attribute
attribute: fast-search
}
struct-field value.last_name {
indexing: attribute
attribute: fast-search
}
}
</pre>
<p>
This example illustrates that the struct elements are configured individually -
there is no field configuration for <em>age</em> -
one can define a subset of the struct fields as attributes.
</p>
<p>
Here, <em>key</em>, <em>value.first_name</em> and <em>value.last_name</em> are defined as attributes.
This makes them available for searching and <a href="/en/querying/grouping.html#grouping-over-a-map-field">grouping</a>.
A common use case is requiring matches in the same map entry
(e.g., match both first and last name for the same person),
see the <a href="/en/reference/querying/yql.html#sameelement">sameElement</a> operator
for how to implement this.
Use <a href="#matched-elements-only">matched-elements-only</a>
to reduce the amount of data in the document summary.
</p>
<p>
<a href="/en/performance/feature-tuning.html#when-to-use-fast-search-for-attribute-fields">fast-search</a>
is used to make query access faster by creating an index structure for lookups.
</p>
<p>
As an alternative to a map,
an <a href="#array">array<struct></a> can contain the same element multiple times and maintains order.
</p>
<p>Restrictions:</p>
<ul>
<li>Map of struct or primitive types do not support <a href="../../basics/ranking.html">ranking features</a>
and can only be used for matching and filtering.</li>
<li>All map types can be fed, retrieved, and used in document summaries.</li>
<li>Some map types can be searched in <a href="../applications/services/content.html#document">indexed search mode</a>,
while all map types can be searched in <a href="../../performance/streaming-search.html">streaming search</a>.
See below for supported cases:</li>
</ul>
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>
Only supported in <a href="../../performance/streaming-search.html#differences-in-streaming-search">streaming search</a>.
Set this on the top-level map field to make all struct fields in the map field searchable.
</td>
</tr><tr>
<th>Attribute</th>
<td>
Only supported for <a href="#struct-field">struct fields</a> where <em>value-type</em> is either a
primitive type (bool, string, int, long, byte, float, double) or a
<a href="#struct">struct type</a> with fields of primitive types.
Any struct field must be defined as an attribute to be used for searching.
The <em>value-type</em> struct can still contain fields of non-primitive types,
as long as these are not defined as attributes.
</td>
</tr><tr>
<th>Summary</th>
<td>Added as a map.</td>
</tr>
</tbody>
</table>
</td></tr>
<tr><th>position</th>
<td>
<p id="position">
Used to filter and/or rank documents by distance to a position in the query,
see <a href="../../querying/geo-search.html">Geo search</a>.
</p>
<pre>
field location type position {
indexing: attribute
}
</pre>
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>Not supported</td>
</tr><tr>
<th>Attribute</th>
<td>Added as an interleaved 64-bit integer
(see <a href="https://en.wikipedia.org/wiki/Z-order_curve">Z-order curve</a>) -
queries are implemented by doing a set of range searches in the attribute.
This attribute has <a href="../../content/attributes.html#fast-search">fast-search</a> set implicitly</td>
</tr><tr>
<th>Summary</th>
<td>Refer to the <a href="document-json-format.html#position">reference</a></td>
</tr>
</tbody>
</table>
</td></tr>
<tr><th>predicate</th>
<td>
<p id="predicate">
Use to match queries to a set of boolean constraints.
See <a href="../../schemas/predicate-fields.html#queries">querying predicate fields.</a>
Predicate fields are not supported in
<a href="../../performance/streaming-search.html#differences-in-streaming-search">streaming search</a>.
</p>
<pre>
field predicate_field type predicate {
indexing: attribute
index {
arity: 2 # mandatory
lower-bound: 3
upper-bound: 200
dense-posting-list-threshold: 0.25
}
}
</pre>
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>Not supported</td>
</tr><tr>
<th>Attribute</th>
<td>Indexed in-memory in a variable-size binary format that is optimized for application during query evaluation</td>
</tr><tr>
<th>Summary</th>
<td>Added as-is</td>
</tr>
</tbody>
</table>
</td></tr>
<tr><th>raw</th>
<td><p id="raw">Use for binary data</p>
<pre>
field rawfield type raw {
indexing: summary | attribute
}
</pre>
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>Not supported</td>
</tr><tr>
<th>Attribute</th>
<td>Added as raw data. Not searchable.</td>
</tr><tr>
<th>Summary</th>
<td>Added as raw data. Outputted as a base64-encoded string.
See <a href="document-json-format.html#raw">JSON feed format</a> for details.
</td>
</tr>
</tbody>
</table>
</td></tr>
<tr><th>reference<document-type></th>
<td>
<p id="reference">
A <em>reference<document-type></em> field is a reference to an instance of a document-type -
i.e., a foreign key.
Reference fields are not supported in
<a href="../../performance/streaming-search.html#differences-in-streaming-search">streaming search</a>.
</p>
<pre>
field artist_ref type reference<artist> {
indexing: attribute
}
</pre>
The reference is the <a href="../../schemas/documents.html">document id</a> of the document-type instance.
References are used to join documents in a <a href="../../schemas/parent-child.html">parent-child relationship</a>.
A reference can only be made to <a href="../applications/services/content.html#document">global</a> documents.
The following types of references are not supported:
<ul>
<li>Self-reference</li>
<li>Cyclic reference: If document type <em>foo</em> has a reference to <em>bar</em>,
then <em>bar</em> cannot have a reference to <em>foo</em></li>
</ul>
A reference attribute field can be searched using the document id of the parent document-type instance as query term.
Note that this will be a linear scan as <a href="#attribute">fast-search</a> is not supported.
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>Invalid - deployment will fail</td>
</tr><tr>
<th>Attribute</th>
<td>
As <a href="#string">string</a> - a reference must be an attribute.
Can be an empty string or point to a non-existent document.
Memory usage is about 33 bytes per parent document.
This is composed of 24 bytes used in a reference store, with a btree structure
on top of that which requires 5 bytes on average (depends on lid compaction).
In addition 4 bytes on average for a reference from child document to the parent document
(depends on lid compaction). In total about 33 bytes.
</td>
</tr><tr>
<th>Summary</th>
<td>As <a href="#string">string</a></td>
</tr>
</tbody>
</table>
</td></tr>
<tr><th>string</th>
<td>
<p id="string">
Use for a text field of any length.
String fields may only contain <em>text characters</em>, as defined by <code>isTextCharacter</code> in
<a href="https://github.com/vespa-engine/vespa/blob/master/vespajlib/src/main/java/com/yahoo/text/Text.java">
com.yahoo.text.Text</a>
</p>
<pre>
field surname type string {
indexing: summary | index
}
</pre>
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>
Refer to <a href="../../linguistics/linguistics.html">linguistics</a>
for details on normalization, tokenization and stemming.
</td>
</tr><tr>
<th>Attribute</th>
<td>
Added as-is. <a href="#match">match</a> exact or prefix is
supported types of searches in string attributes. Searches are however
case-insensitive. A query for <code>BritneY.spears</code> will match a
document containing <code>BrItNeY.SpEars</code>
</td>
</tr><tr>
<th>Summary</th>
<td>Added as-is</td>
</tr>
</tbody>
</table>
</td></tr>
<tr><th>struct</th>
<td>
<p id="struct-name">
Use to define a field with a struct datatype.
Create a <a href="#struct">struct type</a> inside the document definition and
declare the struct field in a document or struct using the struct type name as the field type:
</p>
<pre>
struct person {
field first_name type string {}
field last_name type string {}
}
field my_person type person {
indexing: summary
}
</pre>
Restrictions:
<ul>
<li>Struct fields can <strong>not</strong> be searched in indexed search mode
(but <a href="#array">array of struct</a> and
<a href="#map">map type</a> are searchable, with some restrictions).</li>
<li>Struct fields can be fed, retrieved, and used in document summaries.</li>
</ul>
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>
Only supported in <a href="../../performance/streaming-search.html#differences-in-streaming-search">streaming search</a>.
Set this on the top-level field to make all parts searchable.
</td>
</tr><tr>
<th>Attribute</th>
<td>Not supported.</td>
</tr><tr>
<th>Summary</th>
<td>Added as a struct.</td>
</tr>
</tbody>
</table>
</td></tr>
<tr><th>tensor(dimension-1,...,dimension-N)</th>
<td>
<p id="tensor">
Use to create a tensor field with the given
<a href="../ranking/tensor.html#tensor-type-spec">tensor type spec</a>
that can be used for <a href="../../basics/ranking.html">ranking</a> and
<a href="../../querying/nearest-neighbor-search">nearest neighbor search</a>.
A tensor field is otherwise <span style="text-decoration: underline;">not</span> searchable.
</p><p>
See <a href="../ranking/tensor.html">tensor evaluation reference</a> for definition,
the <a href="../../ranking/tensor-user-guide.html">tensor user guide</a> and
the <a href="document-json-format.html#tensor">JSON feed format</a>.
</p>
<pre>
field tensorfield type tensor<float>(x{},y{}) {
indexing: attribute | summary
}
field tensorfield type tensor<float>(x[2],y[2]) {
indexing: attribute | summary
}
</pre>
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>Supported for tensor types with:
<ul>
<li>One indexed dimension - single vector per document</li>
<li>One or more mapped dimensions and one indexed dimension - multiple vectors per document</li>
</ul>
See <a href="../../querying/approximate-nn-hnsw">approximate nearest neighbor search</a>.</td>
</tr><tr>
<th>Attribute</th>
<td>Added as-is in an attribute to be used for ranking and nearest neighbor search.</td>
</tr><tr>
<th>Summary</th>
<td>Added as-is.</td>
</tr>
</tbody>
</table>
</td></tr>
<tr><th>uri</th>
<td><p id="uri">Use for URL type matching.
URI fields are not supported in
<a href="../../performance/streaming-search.html#differences-in-streaming-search">streaming search</a>.
</p>
<table class="table">
<thead></thead><tbody>
<tr>
<th style="width:100px">Index</th>
<td>
<p>
The URL is split into its different components, which are indexed
separately. Note that only URLs can be indexed this way, not other URIs.
The different components are as defined by the HTTP standard:
Scheme, hostname, port, path, query, and fragment. Example:
<pre>
http://mysite.mydomain.com:8080/path/shop?d=hab&id=1804905709&cat=100#frag1
</pre>
<table class="table">