File tree Expand file tree Collapse file tree 3 files changed +38
-2
lines changed
x-pack/plugin/rank-rrf/src
main/java/org/elasticsearch/xpack/rank
yamlRestTest/resources/rest-api-spec/test/linear Expand file tree Collapse file tree 3 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 1313import java .util .Set ;
1414
1515import static org .elasticsearch .search .retriever .CompoundRetrieverBuilder .INNER_RETRIEVERS_FILTER_SUPPORT ;
16+ import static org .elasticsearch .xpack .rank .linear .MinMaxScoreNormalizer .LINEAR_RETRIEVER_MINMAX_SINGLE_DOC_FIX ;
1617
1718public class RankRRFFeatures implements FeatureSpecification {
1819
@@ -25,6 +26,6 @@ public Set<NodeFeature> getFeatures() {
2526
2627 @ Override
2728 public Set <NodeFeature > getTestFeatures () {
28- return Set .of (INNER_RETRIEVERS_FILTER_SUPPORT );
29+ return Set .of (INNER_RETRIEVERS_FILTER_SUPPORT , LINEAR_RETRIEVER_MINMAX_SINGLE_DOC_FIX );
2930 }
3031}
Original file line number Diff line number Diff line change 88package org .elasticsearch .xpack .rank .linear ;
99
1010import org .apache .lucene .search .ScoreDoc ;
11+ import org .elasticsearch .features .NodeFeature ;
1112
1213public class MinMaxScoreNormalizer extends ScoreNormalizer {
13-
1414 public static final MinMaxScoreNormalizer INSTANCE = new MinMaxScoreNormalizer ();
1515
16+ public static final NodeFeature LINEAR_RETRIEVER_MINMAX_SINGLE_DOC_FIX = new NodeFeature ("linear_retriever.minmax_single_doc_fix" );
17+
1618 public static final String NAME = "minmax" ;
1719
1820 private static final float EPSILON = 1e-6f ;
Original file line number Diff line number Diff line change @@ -1102,3 +1102,36 @@ setup:
11021102 ]
11031103 rank_window_size : -10
11041104 - match : { status: 400 }
1105+
1106+ ---
1107+ " minmax normalization properly handles a single doc result set " :
1108+ - requires :
1109+ cluster_features : [ "linear_retriever.minmax_single_doc_fix" ]
1110+ reason : " Fix bug where minmax normalizer would emit unnormalized score when handling a single doc result set"
1111+
1112+ - do :
1113+ search :
1114+ index : test
1115+ body :
1116+ retriever :
1117+ linear :
1118+ retrievers : [
1119+ {
1120+ retriever : {
1121+ standard : {
1122+ query : {
1123+ term : {
1124+ " keyword " : {
1125+ " value " : " one"
1126+ }
1127+ }
1128+ }
1129+ }
1130+ },
1131+ normalizer : " minmax"
1132+ }
1133+ ]
1134+
1135+ - match : { hits.total.value: 1 }
1136+ - match : { hits.hits.0._id: "1" }
1137+ - match : { hits.hits.0._score: 1.0 }
You can’t perform that action at this time.
0 commit comments