Skip to content

Commit 2bc12ec

Browse files
committed
Nitpicks and some other enhancement comments resolved
1 parent bd0d4ce commit 2bc12ec

File tree

3 files changed

+10
-61
lines changed

3 files changed

+10
-61
lines changed

docs/reference/elasticsearch/rest-apis/retrievers/linear-retriever.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ Combining `query` and `retrievers` is not supported.
3838
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).
3939
Otherwise 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.
4040

41+
:::{note}
42+
**Top-level normalizer support for sub-retrievers**: The ability to use a top-level normalizer as a default for sub-retrievers was introduced in Elasticsearch 9.2+. In earlier versions, only per-retriever normalizers are supported.
43+
:::
44+
4145
::::{warning}
4246
Avoid using `none` as that will disable normalization and may bias the result set towards lexical matches.
4347
See [field grouping](../retrievers.md#multi-field-field-grouping) for more information.
@@ -80,6 +84,7 @@ Each entry in the `retrievers` array specifies the following parameters:
8084
Specifies how the retriever's score will be normalized before applying the specified `weight`.
8185
See [normalizers](#linear-retriever-normalizers) for supported values.
8286
If not specified, uses the top-level `normalizer` or defaults to `none` if no top-level normalizer is set.
87+
{applies_to}`stack: ga 9.2`
8388

8489
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.
8590

x-pack/plugin/rank-rrf/src/test/java/org/elasticsearch/xpack/rank/linear/LinearRetrieverBuilderParsingTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected LinearRetrieverBuilder createTestInstance() {
7575
new CompoundRetrieverBuilder.RetrieverSource(TestRetrieverBuilder.createRandomTestRetrieverBuilder(), null)
7676
);
7777
weights[i] = randomFloat();
78-
normalizers[i] = randomFrom(SCORE_NORMALIZERS);
78+
normalizers[i] = randomScoreNormalizer();
7979
}
8080

8181
return new LinearRetrieverBuilder(innerRetrievers, fields, query, normalizer, rankWindowSize, weights, normalizers);

x-pack/plugin/rank-rrf/src/yamlRestTest/resources/rest-api-spec/test/linear/10_linear_retriever.yml

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,66 +1514,6 @@ setup:
15141514
- match: { hits.total.value: 0 }
15151515
- length: { hits.hits: 0 }
15161516

1517-
---
1518-
"Linear retriever with per-retriever normalizer override":
1519-
- requires:
1520-
cluster_features: [ "linear_retriever.top_level_normalizer" ]
1521-
reason: "Support for top-level normalizer in linear retriever"
1522-
- do:
1523-
search:
1524-
index: test
1525-
body:
1526-
retriever:
1527-
linear:
1528-
normalizer: minmax
1529-
retrievers: [
1530-
{
1531-
retriever: {
1532-
standard: {
1533-
query: {
1534-
constant_score: {
1535-
filter: {
1536-
term: {
1537-
keyword: {
1538-
value: "one"
1539-
}
1540-
}
1541-
},
1542-
boost: 5.0
1543-
}
1544-
}
1545-
}
1546-
},
1547-
weight: 1.0,
1548-
normalizer: l2_norm
1549-
},
1550-
{
1551-
retriever: {
1552-
standard: {
1553-
query: {
1554-
constant_score: {
1555-
filter: {
1556-
term: {
1557-
keyword: {
1558-
value: "four"
1559-
}
1560-
}
1561-
},
1562-
boost: 12.0
1563-
}
1564-
}
1565-
}
1566-
},
1567-
weight: 1.0
1568-
}
1569-
]
1570-
1571-
- match: { hits.total.value: 2 }
1572-
- match: { hits.hits.0._id: "1" }
1573-
- match: { hits.hits.1._id: "4" }
1574-
- close_to: { hits.hits.0._score: { value: 1.0, error: 0.001} }
1575-
- close_to: { hits.hits.1._score: { value: 1.0, error: 0.001} }
1576-
15771517
---
15781518
"Linear retriever with mixed normalizers - inheritance test":
15791519
- requires:
@@ -1657,6 +1597,10 @@ setup:
16571597
# Third retriever: L2 norm on [6.0] = 1.0, final = 1.0 * 2.0 = 2.0
16581598
- match: { hits.hits.0._id: "3" } # Highest score due to weight=2.0
16591599
- close_to: { hits.hits.0._score: { value: 2.0, error: 0.001} }
1600+
- match: { hits.hits.1._id: "1" } # Second score = 1.0
1601+
- close_to: { hits.hits.1._score: { value: 1.0, error: 0.001} }
1602+
- match: { hits.hits.2._id: "2" } # Third score = 1.0
1603+
- close_to: { hits.hits.2._score: { value: 1.0, error: 0.001} }
16601604

16611605
---
16621606
"Linear retriever with identity normalizer (no normalization)":

0 commit comments

Comments
 (0)