Skip to content

Commit 978e182

Browse files
committed
Resolved PR comments
1 parent 5c364a0 commit 978e182

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

x-pack/plugin/rank-rrf/src/main/java/org/elasticsearch/xpack/rank/rrf/RRFRetrieverComponent.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,13 @@ public static RRFRetrieverComponent fromXContent(XContentParser parser, Retrieve
9797
parser.nextToken();
9898
weight = parser.floatValue();
9999
} else {
100-
throw new ParsingException(parser.getTokenLocation(), "unknown field [{}] after retriever", fieldName);
100+
throw new ParsingException(
101+
parser.getTokenLocation(),
102+
"unknown field [{}], expected [{}] or [{}]",
103+
fieldName,
104+
RETRIEVER_FIELD.getPreferredName(),
105+
WEIGHT_FIELD.getPreferredName()
106+
);
101107
}
102108
} while (parser.nextToken() == XContentParser.Token.FIELD_NAME);
103109

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public void testRRFRetrieverComponentErrorCases() throws IOException {
273273
}
274274
""";
275275

276-
expectParsingException(multipleRetrieversContent, "unknown field [standard] after retriever");
276+
expectParsingException(multipleRetrieversContent, "unknown field [standard], expected [retriever] or [weight]");
277277

278278
// Test case 2: Weight without retriever
279279
String weightOnlyContent = """

x-pack/plugin/rank-rrf/src/yamlRestTest/resources/rest-api-spec/test/rrf/320_rrf_weighted_retriever.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ setup:
22
- requires:
33
cluster_features: [ "rrf_retriever.weighted_support" ]
44
reason: "RRF retriever Weighted support"
5-
test_runner_features: [ "contains" ]
5+
test_runner_features: [ "contains", "close_to" ]
66
- do:
77
indices.create:
88
index: restaurants
@@ -104,6 +104,12 @@ setup:
104104
- match: { hits.total.value: 2 }
105105
- match: { hits.hits.0._id: "2" }
106106
- match: { hits.hits.1._id: "1" }
107+
# Document 2: matches "burgers" with weight 0.9
108+
# RRF score = 1/(60+1) * 0.9 = 0.01475
109+
- close_to: {hits.hits.0._score: {value: 0.01475, error: 0.0001}}
110+
# Document 1: matches "pizza" with weight 0.1
111+
# RRF score = 1/(60+1) * 0.1 = 0.00164
112+
- close_to: {hits.hits.1._score: {value: 0.00164, error: 0.0001}}
107113

108114
---
109115
"Weighted RRF retriever errors on negative weight":
@@ -130,3 +136,4 @@ setup:
130136
weight: 0.7
131137
- match: { error.type: "x_content_parse_exception" }
132138
- contains: { error.reason: "failed to parse field" }
139+

0 commit comments

Comments
 (0)