-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathnativerank.html
More file actions
1131 lines (1105 loc) · 39.6 KB
/
nativerank.html
File metadata and controls
1131 lines (1105 loc) · 39.6 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: "nativeRank Reference"
redirect_from:
- /en/reference/nativerank.html
---
<p>
The <em>nativeRank</em> feature produces a reasonable text ranking score which is
computed at an acceptable performance,
and is a good candidate for <a href="../../ranking/phased-ranking.html">first phase</a> ranking.
The <em>nativeRank</em> feature is a linear combination of the normalized scores
computed by the features <em>nativeFieldMatch</em>, <em>nativeProximity</em>,
and <em>nativeAttributeMatch</em>.
All these features are described in detail below.
See the <a href="#configuration-properties">configuration properties</a>
section for how to configure the features.
</p>
<h2 id="nativeFieldMatch">nativeFieldMatch</h2>
<p>
The <em>nativeFieldMatch</em> feature captures how well query
terms match searched index fields by looking at the number of times a
term occurs in a field and how early in the field it occurs. The
significance and weight of the terms are also taken into account such
that unusual terms give a higher rank contribution than common ones.
</p><p>
The score for <em>nativeFieldMatch</em> is calculated as follows:
</p>
<figure style="font-size: 1.3rem">
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<semantics>
<mrow>
<mi mathvariant="italic">nativeFieldMatch</mi>
<mo>=</mo>
<mfrac>
<mrow>
<munderover>
<mo>∑</mo>
<mi>i</mi>
<mi>n</mi>
</munderover>
<msub>
<mi mathvariant="italic">termSignificance</mi>
<mi>i</mi>
</msub>
<mo>×</mo>
<msub>
<mi mathvariant="italic">termWeight</mi>
<mi>i</mi>
</msub>
<munderover>
<mo>∑</mo>
<mi>j</mi>
<mi>m</mi>
</munderover>
<msub>
<mi mathvariant="italic">fieldWeight</mi>
<mi>j</mi>
</msub>
<mfenced close=")" open="(">
<mrow>
<msub>
<mi mathvariant="italic">firstOccImp</mi>
<mi>j</mi>
</msub>
<mo>×</mo>
<msub>
<mi mathvariant="italic">firstOccBoost</mi>
<mrow>
<mi>i</mi>
<mi>j</mi>
</mrow>
</msub>
<mo>+</mo>
<mfenced close=")" open="(">
<mrow>
<mn>1</mn>
<mo>-</mo>
<msub>
<mi mathvariant="italic">firstOccImp</mi>
<mi>j</mi>
</msub>
</mrow>
</mfenced>
<mo>×</mo>
<msub>
<mi mathvariant="italic">numOccBoost</mi>
<mrow>
<mi>i</mi>
<mi>j</mi>
</mrow>
</msub>
</mrow>
</mfenced>
</mrow>
<mrow>
<munderover>
<mo>∑</mo>
<mi>i</mi>
<mi>n</mi>
</munderover>
<msub>
<mi mathvariant="italic">termSignificance</mi>
<mi>i</mi>
</msub>
<mo>×</mo>
<msub>
<mi mathvariant="italic">termWeight</mi>
<mi>i</mi>
</msub>
<munderover>
<mo>∑</mo>
<mi>j</mi>
<mi>m</mi>
</munderover>
<msub>
<mi mathvariant="italic">fieldWeight</mi>
<mi>j</mi>
</msub>
<mo>×</mo>
<msub>
<mi mathvariant="italic">fmMaxTable</mi>
<mi>j</mi>
</msub>
</mrow>
</mfrac>
</mrow>
<annotation encoding="SnuggleTeX">\[ nativeFieldMatch = \frac{\sum_i^ntermSignificance_i \times termWeight_i\sum_j^mfieldWeight_j(firstOccImp_j \times firstOccBoost_{ij} + (1 - firstOccImp_j) \times numOccBoost_{ij})}{\sum_i^ntermSignificance_i \times termWeight_i\sum_j^mfieldWeight_j \times fmMaxTable_j} \]</annotation>
</semantics>
</math>
</div>
</figure>
<p>
where <em>n</em> is the number of query terms searched in index fields,
<em>m</em> is the number of fields searched by query term <em>i</em>,
<em>firstOccImp<sub>j</sub></em> is the <em>firstOccurrenceImportance</em>
for field <em>j</em>, and <em>firstOccBoost<sub>ij</sub></em>,
<em>numOccBoost<sub>ij</sub></em> and <em>fmMaxTable<sub>j</sub></em> are given below.
</p>
<figure style="font-size: 1.3rem">
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<semantics>
<mrow>
<msub>
<mi mathvariant="italic">firstOccBoost</mi>
<mrow>
<mi>i</mi>
<mi>j</mi>
</mrow>
</msub>
<mo>=</mo>
<msub>
<mi mathvariant="italic">firstOccurrenceTable</mi>
<mi>j</mi>
</msub>
<mfenced close="]" open="[">
<mfrac>
<mrow>
<msub>
<mi mathvariant="italic">firstOcc</mi>
<mrow>
<mi>i</mi>
<mi>j</mi>
</mrow>
</msub>
<mo>×</mo>
<msub>
<mi mathvariant="italic">tableSize</mi>
<mi>j</mi>
</msub>
</mrow>
<mrow>
<mi>max</mi>
<mfenced close=")" open="(">
<mn>6</mn>
<mrow>
<msub>
<mi mathvariant="italic">fieldLength</mi>
<mi>j</mi>
</msub>
</mrow>
</mfenced>
</mrow>
</mfrac>
</mfenced>
</mrow>
<annotation encoding="SnuggleTeX">\[ firstOccBoost_{ij} = firstOccurrenceTable_j[\frac{firstOcc_{ij} \times tableSize_j}{max(6,fieldLength_j)}] \]</annotation>
</semantics>
</math>
</div>
</figure>
<p>
where <em>firstOccurrenceTable<sub>j</sub></em> is the boost table configured for field <em>j</em>,
typically an expdecay function (see the <a href="#boost-tables">boost tables</a> section below),
<em>firstOcc<sub>ij</sub></em> is the first occurrence of query term <em>i</em> in field <em>j</em>,
and <em>tableSize<sub>j</sub></em> is the size of the boost table.
</p>
<figure style="font-size: 1.3rem">
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<semantics>
<mrow>
<msub>
<mi mathvariant="italic">numOccBoost</mi>
<mrow>
<mi>i</mi>
<mi>j</mi>
</mrow>
</msub>
<mo>=</mo>
<msub>
<mi mathvariant="italic">occurrenceCountTable</mi>
<mi>j</mi>
</msub>
<mfenced close="]" open="[">
<mfrac>
<mrow>
<msub>
<mi mathvariant="italic">numOccs</mi>
<mrow>
<mi>i</mi>
<mi>j</mi>
</mrow>
</msub>
<mo>×</mo>
<msub>
<mi mathvariant="italic">tableSize</mi>
<mi>j</mi>
</msub>
</mrow>
<mrow>
<mi>max</mi>
<mfenced close=")" open="(">
<mn>6</mn>
<mrow>
<msub>
<mi mathvariant="italic">fieldLength</mi>
<mi>j</mi>
</msub>
</mrow>
</mfenced>
</mrow>
</mfrac>
</mfenced>
</mrow>
<annotation encoding="SnuggleTeX">\[ numOccBoost_{ij} = occurrenceCountTable_j[\frac{numOccs_{ij} \times tableSize_j}{max(6,fieldLength_j)}] \]</annotation>
</semantics>
</math>
</div>
</figure>
<p>
where <em>occurrenceCountTable<sub>j</sub></em> is the boost table configured for field <em>j</em>,
typically a loggrowth function (see the <a href="#boost-tables">boost tables</a> section below),
<em>numOccs<sub>ij</sub></em> is the number of occurrences of query term <em>i</em> in field <em>j</em>,
and <em>tableSize<sub>j</sub></em> is the size of the boost table.
</p>
<figure style="font-size: 1.3rem">
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<semantics>
<mrow>
<msub>
<mi mathvariant="italic">fmMaxTable</mi>
<mi>j</mi>
</msub>
<mo>=</mo>
<msub>
<mi mathvariant="italic">firstOccImp</mi>
<mi>j</mi>
</msub>
<mo>×</mo>
<mi>max</mi>
<mfenced close=")" open="(">
<mrow>
<msub>
<mi mathvariant="italic">firstOccurrenceTable</mi>
<mi>j</mi>
</msub>
</mrow>
</mfenced>
<mo>+</mo>
<mfenced close=")" open="(">
<mrow>
<mn>1</mn>
<mo>-</mo>
<msub>
<mi mathvariant="italic">firstOccImp</mi>
<mi>j</mi>
</msub>
</mrow>
</mfenced>
<mo>×</mo>
<mi>max</mi>
<mfenced close=")" open="(">
<mrow>
<msub>
<mi mathvariant="italic">occurrenceCountTable</mi>
<mi>j</mi>
</msub>
</mrow>
</mfenced>
</mrow>
<annotation encoding="SnuggleTeX">\[ fmMaxTable_j = firstOccImp_j \times max(firstOccurrenceTable_j) + (1 - firstOccImp_j) \times max(occurrenceCountTable_j) \]</annotation>
</semantics>
</math>
</div>
</figure>
<p>
where <em>max(boostTable<sub>j</sub>)</em> is the max value in that table.
<em>fmMaxTable<sub>j</sub></em> is 1 if table normalization is turned off
(see the property <em>nativeRank.useTableNormalization</em> in the
<a href="#configuration-properties">configuration properties</a> section).
</p><p>
The default behavior for <em>nativeFieldMatch</em> is to consider all query terms searching in all index fields
when calculating the score.
The calculation can be limited to a specified set of index fields as follows:
</p>
<p style="text-align: center;">
<code>nativeFieldMatch(<em>f1</em>, <em>f2</em>)</code>
</p>
<p>
In this case only query terms searching in index fields <em>f1</em> and <em>f2</em> are considered.
</p>
<h2 id="nativeProximity">nativeProximity</h2>
<p>
The <em>nativeProximity</em> feature captures how near the matched query terms occur
in searched index fields by looking at the word distance between query terms in query term pairs.
Two query terms that are close to each other should give a higher score than two terms that are far from each other.
</p><p>
The score for <em>nativeProximity</em> is calculated as follows:
</p>
<figure style="font-size: 1.3rem">
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<semantics>
<mrow>
<mi mathvariant="italic">nativeProximity</mi>
<mo>=</mo>
<mfrac>
<mrow>
<munderover>
<mo>∑</mo>
<mi>j</mi>
<mi>m</mi>
</munderover>
<msub>
<mi mathvariant="italic">fieldWeight</mi>
<mi>j</mi>
</msub>
<munder>
<mo>∑</mo>
<mrow>
<mi>a</mi>
<mi>b</mi>
</mrow>
</munder>
<msub>
<mi mathvariant="italic">termPairWeight</mi>
<mrow>
<mi>a</mi>
<mi>b</mi>
</mrow>
</msub>
<mfenced close=")" open="(">
<mrow>
<msub>
<mi mathvariant="italic">proxImp</mi>
<mi>j</mi>
</msub>
<mo>×</mo>
<msub>
<mi mathvariant="italic">proxTable</mi>
<mi>j</mi>
</msub>
<mfenced close="]" open="[">
<mrow>
<msub>
<mi mathvariant="italic">dist</mi>
<mrow>
<mi>a</mi>
<mi>b</mi>
</mrow>
</msub>
<mo>-</mo>
<mn>1</mn>
</mrow>
</mfenced>
<mo>+</mo>
<mfenced close=")" open="(">
<mrow>
<mn>1</mn>
<mo>-</mo>
<msub>
<mi mathvariant="italic">proxImp</mi>
<mi>j</mi>
</msub>
</mrow>
</mfenced>
<mo>×</mo>
<msub>
<mi mathvariant="italic">revProxTable</mi>
<mi>j</mi>
</msub>
<mfenced close="]" open="[">
<mrow>
<msub>
<mi mathvariant="italic">dist</mi>
<mrow>
<mi>b</mi>
<mi>a</mi>
</mrow>
</msub>
<mo>-</mo>
<mn>1</mn>
</mrow>
</mfenced>
</mrow>
</mfenced>
</mrow>
<mrow>
<munderover>
<mo>∑</mo>
<mi>j</mi>
<mi>m</mi>
</munderover>
<msub>
<mi mathvariant="italic">fieldWeight</mi>
<mi>j</mi>
</msub>
<munder>
<mo>∑</mo>
<mrow>
<mi>a</mi>
<mi>b</mi>
</mrow>
</munder>
<msub>
<mi mathvariant="italic">termPairWeight</mi>
<mrow>
<mi>a</mi>
<mi>b</mi>
</mrow>
</msub>
<mo>×</mo>
<msub>
<mi mathvariant="italic">pMaxTable</mi>
<mi>j</mi>
</msub>
</mrow>
</mfrac>
</mrow>
<annotation encoding="SnuggleTeX">\[ nativeProximity = \frac{\sum_j^mfieldWeight_j\sum_{ab}termPairWeight_{ab}(proxImp_j \times proxTable_j[dist_{ab} - 1] + (1 - proxImp_j) \times revProxTable_j[dist_{ba} - 1])}{\sum_j^mfieldWeight_j\sum_{ab}termPairWeight_{ab} \times pMaxTable_j} \]</annotation>
</semantics>
</math>
</div>
</figure>
<p>
where <em>m</em> is the number of index fields,
<em>ab</em> is a term pair searched for in field <em>j</em>,
<em>proxImp<sub>j</sub></em> is the <em>proximityImportance</em> for field <em>j</em>,
<em>proxTable<sub>j</sub></em> is the forward proximity boost table for field <em>j</em>,
<em>dist<sub>ab</sub></em> is the minimum distance between occurrences of query terms <em>a</em>
and <em>b</em> in field <em>j</em>,
(<em>a</em> occurs before <em>b</em>),
<em>revProxTable<sub>j</sub></em> is the reverse proximity boost table for field <em>j</em>,
<em>dist<sub>ba</sub></em> is the minimum distance between occurrences of query terms
<em>b</em> and <em>a</em> in field <em>j</em> (<em>b</em> occurs before <em>a</em>),
and <em>termPairWeight<sub>ab</sub></em> and <em>pMaxTable<sub>j</sub></em> are given below.
</p>
<p>
For each field <em>j</em> we consider all query terms searched in this field and generate a set of term pairs.
The <em>slidingWindowSize</em> parameter determines how many pairs that are generated.
With a sliding window of size 3 over the terms <em>a b c d</em>,
we first consider the terms <em>a b c</em>, then the terms <em>b c d</em>,
and finally the terms <em>c d</em>.
The following pairs are generated: <em>ab</em>, <em>ac</em>, <em>bc</em>, <em>bd</em>, and <em>cd</em>.
</p>
<figure style="font-size: 1.3rem">
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<semantics>
<mrow>
<msub>
<mi mathvariant="italic">termPairWeight</mi>
<mrow>
<mi>a</mi>
<mi>b</mi>
</mrow>
</msub>
<mo>=</mo>
<msub>
<mi mathvariant="italic">connectedness</mi>
<mrow>
<mi>a</mi>
<mi>b</mi>
</mrow>
</msub>
<mo>×</mo>
<mfenced close=")" open="(">
<mrow>
<msub>
<mi mathvariant="italic">termSignificance</mi>
<mi>a</mi>
</msub>
<mo>×</mo>
<msub>
<mi mathvariant="italic">termWeight</mi>
<mi>a</mi>
</msub>
<mo>+</mo>
<msub>
<mi mathvariant="italic">termSignificance</mi>
<mi>b</mi>
</msub>
<mo>×</mo>
<msub>
<mi mathvariant="italic">termWeight</mi>
<mi>b</mi>
</msub>
</mrow>
</mfenced>
</mrow>
<annotation encoding="SnuggleTeX">\[ termPairWeight_{ab} = connectedness_{ab} \times (termSignificance_a \times termWeight_a + termSignificance_b \times termWeight_b) \]</annotation>
</semantics>
</math>
</div>
</figure>
<figure style="font-size: 1.3rem">
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<semantics>
<mrow>
<msub>
<mi mathvariant="italic">connectedness</mi>
<mrow>
<mi>a</mi>
<mi>c</mi>
</mrow>
</msub>
<mo>=</mo>
<mfrac>
<mrow>
<mi>min</mi>
<mfenced close=")" open="(">
<mrow>
<msub>
<mi mathvariant="italic">connectedness</mi>
<mrow>
<mi>a</mi>
<mi>b</mi>
</mrow>
</msub>
</mrow>
<mrow>
<msub>
<mi mathvariant="italic">connectedness</mi>
<mrow>
<mi>b</mi>
<mi>c</mi>
</mrow>
</msub>
</mrow>
</mfenced>
</mrow>
<mrow>
<mi>d</mi>
<mi>i</mi>
<mi>s</mi>
<msub>
<mi>t</mi>
<mrow>
<mi>a</mi>
<mi>c</mi>
</mrow>
</msub>
</mrow>
</mfrac>
</mrow>
<annotation encoding="SnuggleTeX">\[ connectedness_{ac} = \frac{min(connectedness_{ab}, connectedness_{bc})}{dist_{ac}} \]</annotation>
</semantics>
</math>
</div>
</figure>
<p>
where <em>dist<sub>ac</sub></em> is the distance between term <em>a</em> and <em>c</em> in the query.
</p>
<figure style="font-size: 1.3rem">
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<semantics>
<mrow>
<msub>
<mi mathvariant="italic">pMaxTable</mi>
<mi>j</mi>
</msub>
<mo>=</mo>
<msub>
<mi mathvariant="italic">proxImp</mi>
<mi>j</mi>
</msub>
<mo>×</mo>
<mi>max</mi>
<mfenced close=")" open="(">
<mrow>
<msub>
<mi mathvariant="italic">proxTable</mi>
<mi>j</mi>
</msub>
</mrow>
</mfenced>
<mo>+</mo>
<mfenced close=")" open="(">
<mrow>
<mn>1</mn>
<mo>-</mo>
<msub>
<mi mathvariant="italic">proxImp</mi>
<mi>j</mi>
</msub>
</mrow>
</mfenced>
<mo>×</mo>
<mi>max</mi>
<mfenced close=")" open="(">
<mrow>
<msub>
<mi mathvariant="italic">revProxTable</mi>
<mi>j</mi>
</msub>
</mrow>
</mfenced>
</mrow>
<annotation encoding="SnuggleTeX">\[ pMaxTable_j = proxImp_j \times max(proxTable_j) + (1 - proxImp_j) \times max(revProxTable_j) \]</annotation>
</semantics>
</math>
</div>
</figure>
<p>
where <em>max(boostTable<sub>j</sub>)</em> is the max value in that table.
<em>pMaxTable<sub>j</sub></em> is 1 if table normalization is turned off
(see the property <em>nativeRank.useTableNormalization</em> in the
<a href="#configuration-properties">configuration properties</a> section).
</p>
<p>
The default behavior for <em>nativeProximity</em> is to consider all index fields and all query terms
pairs searching in these fields when calculating the score.
The calculation can be limited to a specified set of index fields as follows:
</p>
<p style="text-align: center;">
<code>nativeProximity(<em>f1</em>, <em>f2</em>)</code>
</p>
<p>
In this case only query term pairs searching in index fields <em>f1</em> and <em>f2</em> are considered.
</p>
<p>
For multi-value fields, setting <a href="../schemas/schemas.html#rank-element-gap">element-gap</a> for the field in the rank profile enables distance calculation between adjacent elements.
</p>
<h2 id="nativeAttributeMatch">nativeAttributeMatch</h2>
<p>
The <em>nativeAttributeMatch</em> feature captures how well query terms match searched attribute fields,
and is calculated as follows:
</p>
<figure style="font-size: 1.3rem">
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<semantics>
<mrow>
<mi mathvariant="italic">nativeAttributeMatch</mi>
<mo>=</mo>
<mfrac>
<mrow>
<munderover>
<mo>∑</mo>
<mi>i</mi>
<mi>n</mi>
</munderover>
<msub>
<mi mathvariant="italic">termWeight</mi>
<mi>i</mi>
</msub>
<mo>×</mo>
<msub>
<mi mathvariant="italic">attributeWeight</mi>
<mi>j</mi>
</msub>
<mo>×</mo>
<mi>sign</mi>
<mfenced close=")" open="(">
<msub>
<mi>w</mi>
<mrow>
<mi>i</mi>
<mi>j</mi>
</mrow>
</msub>
</mfenced>
<mo>×</mo>
<msub>
<mi mathvariant="italic">weightTable</mi>
<mi>j</mi>
</msub>
<mfenced close="]" open="[">
<mrow>
<mi>abs</mi>
<mfenced close=")" open="(">
<msub>
<mi>w</mi>
<mrow>
<mi>i</mi>
<mi>j</mi>
</mrow>
</msub>
</mfenced>
</mrow>
</mfenced>
</mrow>
<mrow>
<munderover>
<mo>∑</mo>
<mi>i</mi>
<mi>n</mi>
</munderover>
<msub>
<mi mathvariant="italic">termWeight</mi>
<mi>i</mi>
</msub>
<mo>×</mo>
<msub>
<mi mathvariant="italic">attributeWeight</mi>
<mi>j</mi>
</msub>
<mo>×</mo>
<mi>max</mi>
<mfenced close=")" open="(">
<mrow>
<msub>
<mi mathvariant="italic">weightTable</mi>
<mi>j</mi>
</msub>
</mrow>
</mfenced>
</mrow>
</mfrac>
</mrow>
<annotation encoding="SnuggleTeX">\[ nativeAttributeMatch = \frac{\sum_i^ntermWeight_i \times attributeWeight_j \times sign(w_{ij}) \times weightTable_j[abs(w_{ij})]}{\sum_i^ntermWeight_i \times attributeWeight_j \times max(weightTable_j)} \]</annotation>
</semantics>
</math>
</div>
</figure>
<p>
where <em>n</em> is the number of query terms searched in attribute fields,
<em>weightTable<sub>j</sub></em> is the boost table for attribute <em>j</em>,
<em>max(weightTable<sub>j</sub>)</em> is the max value in that table
(1 if table normalization is turned off),
<em>sign(w<sub>ij</sub>)</em> is the sign of <em>w<sub>ij</sub></em>.
<em>w<sub>ij</sub></em> is dependent on the attribute type:
</p>
<ul>
<li><strong>Weighted set</strong>: equals the weight associated with the key
(represented by query term <em>i</em>) in attribute <em>j</em>.</li>
<li><strong>Array</strong>: equals the number of occurrences of query
term <em>i</em> in attribute <em>j</em>.</li>
<li><strong>Single</strong>: equals 1.</li>
</ul>
<p>
The default behavior for <em>nativeAttributeMatch</em> is to consider all query terms
searching in all attribute fields when calculating the score.
The calculation can be limited to a specified set of attribute fields as follows:
</p>
<p style="text-align: center;">
<code>nativeAttributeMatch(<em>a1</em>, <em>a2</em>)</code>
</p>
<p>
In this case only query terms searching in attribute fields <em>a1</em> and <em>a2</em> are considered.
</p>
<h2 id="nativeRank">nativeRank</h2>
<p>
The <em>nativeRank</em> feature is just a linear combination of the three other features,
and is calculated as follows:
</p>
<figure style="font-size: 1.3rem">
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<semantics>
<mrow>
<mi mathvariant="italic">nativeRank</mi>
<mo>=</mo>
<mfrac>
<mrow>
<mi>f</mi>
<mi>m</mi>
<mi>w</mi>
<mo>×</mo>
<mi mathvariant="italic">nativeFieldMatch</mi>
<mo>+</mo>
<mi>p</mi>
<mi>w</mi>
<mo>×</mo>
<mi mathvariant="italic">nativeProximity</mi>
<mo>+</mo>
<mi>a</mi>
<mi>m</mi>
<mi>w</mi>
<mo>×</mo>
<mi mathvariant="italic">nativeAttributeMatch</mi>
</mrow>
<mrow>
<mi>f</mi>
<mi>m</mi>
<mi>w</mi>
<mo>+</mo>
<mi>p</mi>
<mi>w</mi>
<mo>+</mo>
<mi>a</mi>
<mi>m</mi>
<mi>w</mi>
</mrow>
</mfrac>
</mrow>
<annotation encoding="SnuggleTeX">\[ nativeRank = \frac{fmw \times nativeFieldMatch + pw \times nativeProximity + amw \times nativeAttributeMatch}{fmw + pw + amw} \]</annotation>
</semantics>
</math>
</div>
</figure>
<p>
where <em>fmw</em> is the <em>fieldMatchWeight</em>,
<em>pw</em> is the <em>proximityWeight</em>,
and <em>amw</em> is
the <em>attributeMatchWeight</em>.
</p><p>
The default behavior when calculating the native rank score
is to consider all query terms searching in all defined index fields and attribute fields.
In many cases though only a subset of these fields are of interest in the rank score calculation.
You can set up <em>nativeRank</em> for a subset of fields
by specifying the field names in the parameter list as follows:
</p>
<pre>
first-phase {
expression: nativeRank(title,body,tags)
}
</pre>
<p>
In this case we have two index fields (<em>title</em> and <em>body</em>)
and one attribute field (<em>tags</em>),
and the <em>nativeRank</em> feature is calculated based on the
features <em>nativeFieldMatch(title,body)</em>, <em>nativeProximity(title,body)</em>,
and <em>nativeAttributeMatch(tags)</em>.
Note that the CPU cost of calculating the native rank score is also reduced when specifying a subset of the fields.
</p>
<h2 id="variables">Variables</h2>
<p>
This is a list of the common variables used in the formulas above:
</p>
<!--table-to-list-->
<table class="table" id="nativerank-variables-table">
<thead>
<tr><th>Variable</th><th>Description</th></tr>
</thead><tbody>
<tr>
<td><em>attributeWeight<sub>j</sub></em>
</td><td>
The weight of attribute field <em>j</em>. See the
<a href="../schemas/schemas.html#weight">schema reference</a>
for how to set this weight. The default value is 100.
</td>
</tr><tr>
<td><em>connectedness<sub>ab</sub></em>
</td><td>
The connectedness between query terms <em>a</em> and <em>b</em>.
</td>
</tr><tr>
<td><em>fieldLength<sub>j</sub></em>
</td><td>
The length of field <em>j</em> in number of words.
</td>
</tr><tr>
<td><em>fieldWeight<sub>j</sub></em>
</td><td>
The weight of index field <em>j</em>. See
the <a href="../schemas/schemas.html#weight">schema reference</a>
for how to set this weight.
The default value is 100.
</td>
</tr><tr>
<td><em>termSignificance<sub>i</sub></em>
</td><td>
The significance of query term <em>i</em>.
</td>
</tr><tr>
<td><em>termWeight<sub>i</sub></em>
</td><td>
The weight of query term <em>i</em>.
</td>
</tr>
<tbody>
</table>
<h2 id="configuration-properties">Configuration properties</h2>
<p>
This is a comprehensive list of all the configuration properties to all native rank features:
</p>
<!--table-to-list-->
<table class="table" id="native-rank-parameters-table">
<thead>
<tr><th>Feature</th><th>Parameter</th><th>Default</th><th>Description</th></tr>
</thead><tbody>
<tr>
<td><code>nativeFieldMatch</code></td>
<td><code>averageFieldLength</code></td>
<td>The actual length of the field in the given document.</td>
<td>When set this replaces the true field length in the nativeFieldMatch formula for all documents.</td>
</tr><tr>
<tr>
<td><code>nativeFieldMatch</code></td>
<td><code>firstOccurrenceTable</code></td>
<td>expdecay(8000,12.50)</td>
<td>The default table used when calculating boost for the first occurrence in a field.</td>
</tr><tr>
<td><code>nativeFieldMatch</code></td>
<td><code>firstOccurrenceTable.<em>fieldName</em></code></td>
<td>The value of <code>firstOccurrenceTable</code></td>
<td>The table used when calculating boost for the first occurrence in the given field.</td>
</tr><tr>
<td><code>nativeFieldMatch</code></td>
<td><code>occurrenceCountTable</code></td>
<td>loggrowth(1500,4000,19)</td>
<td>The default table used when calculating boost for the number of occurrences in a field.</td>
</tr><tr>
<td><code>nativeFieldMatch</code></td>
<td><code>occurrenceCountTable.<em>fieldName</em></code></td>
<td>The value of <code>occurrenceCountTable</code></td>
<td>The table used when calculating boost for the number of occurrences in the given field.</td>
</tr><tr>
<td><code>nativeFieldMatch</code></td>
<td><code>firstOccurrenceImportance</code></td>
<td>0.5</td>
<td>The default importance value used for weighting the boosts for first occurrence and number of occurrences in a field. This value should be in the interval [0, 1].</td>
</tr><tr>
<td><code>nativeFieldMatch</code></td>
<td><code>firstOccurrenceImportance.<em>fieldName</em></code></td>
<td>The value of <code>firstOccurrenceImportance</code></td>
<td>The importance value used for the given field.</td>
</tr><tr>
<td><code>nativeProximity</code></td>
<td><code>proximityTable</code></td>
<td>expdecay(500,3)</td>
<td>The default table used when calculating forward proximity boost in a field.</td>
</tr><tr>
<td><code>nativeProximity</code></td>
<td><code>proximityTable.<em>fieldName</em></code></td>
<td>The value of <code>proximityTable</code></td>
<td>The table used when calculating forward proximity boost in the given field.</td>
</tr><tr>
<td><code>nativeProximity</code></td>
<td><code>reverseProximityTable</code></td>
<td>expdecay(400,3)</td>
<td>The default table used when calculating reverse proximity boost in a field.</td>
</tr><tr>
<td><code>nativeProximity</code></td>
<td><code>reverseProximityTable.<em>fieldName</em></code></td>
<td>The value of <code>reverseProximityTable</code></td>
<td>The table used when calculating reverse proximity boost in the given field.</td>
</tr><tr>
<td><code>nativeProximity</code></td>
<td><code>proximityImportance</code></td>
<td>0.5</td>
<td>The default importance value used for weighting the boosts for forward and reverse proximity in a field.
This value should be in the interval [0, 1].</td>
</tr><tr>
<td><code>nativeProximity</code></td>
<td><code>proximityImportance.<em>fieldName</em></code></td>
<td>The value of <code>proximityImportance</code></td>
<td>The importance value used for the given field.</td>
</tr><tr>
<td><code>nativeProximity</code></td>
<td><code>slidingWindowSize</code></td>
<td>4</td>
<td>The size of the sliding window used when generating term pairs.
</td>
</tr><tr><td colspan="4">{% include deprecated.html content="The elementGap rank property is deprecated and will be removed in Vespa 9."%}</td>