You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/elasticsearch/rest-apis/retrievers/linear-retriever.md
+13-44Lines changed: 13 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,11 +31,12 @@ Combining `query` and `retrievers` is not supported.
31
31
`normalizer` {applies_to}`stack: ga 9.1`
32
32
: (Optional, String)
33
33
34
-
The normalizer to use when using the [multi-field query format](../retrievers.md#multi-field-query-format).
34
+
The normalizer to use when combining results.
35
35
See [normalizers](#linear-retriever-normalizers) for supported values.
36
36
Required when `query` is specified.
37
-
38
-
When used with `retrievers`, the top-level `normalizer` serves as a default for any sub-retriever that doesn't specify its own normalizer. Per-retriever normalizers always take precedence over the top-level normalizer when both are specified.
37
+
38
+
When used with the [multi-field query format](../retrievers.md#multi-field-query-format) (`query` parameter), normalizes scores per [field grouping](../retrievers.md#multi-field-field-grouping).
39
+
When used with `retrievers`, serves as the default normalizer for any sub-retriever that doesn't specify its own normalizer. Per-retriever normalizers always take precedence over the top-level normalizer.
39
40
40
41
::::{warning}
41
42
Avoid using `none` as that will disable normalization and may bias the result set towards lexical matches.
@@ -76,9 +77,9 @@ Each entry in the `retrievers` array specifies the following parameters:
76
77
`normalizer`
77
78
: (Optional, String)
78
79
79
-
Specifies how the retriever’s score will be normalized before applying the specified `weight`.
80
+
Specifies how the retriever's score will be normalized before applying the specified `weight`.
80
81
See [normalizers](#linear-retriever-normalizers) for supported values.
81
-
Defaults to `none`.
82
+
If not specified, uses the top-level `normalizer` or defaults to `none` if no top-level normalizer is set.
82
83
83
84
See also [this hybrid search example](retrievers-examples.md#retrievers-examples-linear-retriever) using a linear retriever on how to independently configure and apply normalizers to retrievers.
84
85
@@ -96,7 +97,7 @@ The `linear` retriever supports the following normalizers:
96
97
97
98
## Example
98
99
99
-
This example of a hybrid search weights KNN results five times more heavily than BM25 results in the final ranking.
100
+
This example of a hybrid search weights KNN results five times more heavily than BM25 results in the final ranking, with a top-level normalizer applied to all retrievers.
100
101
101
102
```console
102
103
GET my_index/_search
@@ -107,35 +108,14 @@ GET my_index/_search
107
108
{
108
109
"retriever": {
109
110
"knn": {
110
-
...
111
+
"field": "title_vector",
112
+
"query_vector": [0.1, 0.2, 0.3],
113
+
"k": 10,
114
+
"num_candidates": 100
111
115
}
112
116
},
113
117
"weight": 5 # KNN query weighted 5x
114
118
},
115
-
{
116
-
"retriever": {
117
-
"standard": {
118
-
...
119
-
}
120
-
},
121
-
"weight": 1.5 # BM25 query weighted 1.5x
122
-
}
123
-
]
124
-
}
125
-
}
126
-
}
127
-
```
128
-
129
-
### Using top-level normalizer
130
-
131
-
This example shows how to use a top-level normalizer that applies to all sub-retrievers:
132
-
133
-
```console
134
-
GET my_index/_search
135
-
{
136
-
"retriever": {
137
-
"linear": {
138
-
"retrievers": [
139
119
{
140
120
"retriever": {
141
121
"standard": {
@@ -146,18 +126,7 @@ GET my_index/_search
146
126
}
147
127
}
148
128
},
149
-
"weight": 1.0
150
-
},
151
-
{
152
-
"retriever": {
153
-
"knn": {
154
-
"field": "title_vector",
155
-
"query_vector": [0.1, 0.2, 0.3],
156
-
"k": 10,
157
-
"num_candidates": 100
158
-
}
159
-
},
160
-
"weight": 2.0
129
+
"weight": 1.5 # BM25 query weighted 1.5x
161
130
}
162
131
],
163
132
"normalizer": "minmax"
@@ -166,6 +135,6 @@ GET my_index/_search
166
135
}
167
136
```
168
137
169
-
In this example, the `minmax` normalizer is applied to both the standard retriever and the kNN retriever. The top-level normalizer serves as a default that can be overridden by individual sub-retrievers. When using the multi-field query format, the top-level normalizer is applied to all generated inner retrievers.
138
+
In this example, the `minmax` normalizer is applied to both the kNN retriever and the standard retriever. The top-level normalizer serves as a default that can be overridden by individual sub-retrievers. When using the multi-field query format, the top-level normalizer is applied to all generated inner retrievers.
170
139
171
140
See also [this hybrid search example](retrievers-examples.md#retrievers-examples-linear-retriever).
Copy file name to clipboardExpand all lines: x-pack/plugin/rank-rrf/src/test/java/org/elasticsearch/xpack/rank/linear/LinearRetrieverBuilderParsingTests.java
0 commit comments