Skip to content

Commit

Permalink
Reverts Java 15 features from a backport to 2.x (#1121)
Browse files Browse the repository at this point in the history
* Reverts Java 15 features

2.x branch compiles Java 11 code thus any features subsequent of this version will have issues

Signed-off-by: Brian Flores <[email protected]>
  • Loading branch information
brianf-aws authored Jan 21, 2025
1 parent d060c51 commit c662637
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ public void testRerank_reranksHits_WhenTargetFieldIsNumericalString() throws IOE
setUpValidSearchResultsWithNestedTargetValueWithNumericalString();
List<Map.Entry<Integer, Float>> sortedScoresDescending = sampleIndexMLScorePairs.stream()
.sorted(Map.Entry.<Integer, Float>comparingByValue().reversed())
.toList();
.collect(Collectors.toList());

Map<String, Object> config = new HashMap<>(
Map.of(RerankType.BY_FIELD.getLabel(), new HashMap<>(Map.of(ByFieldRerankProcessor.TARGET_FIELD, targetField)))
Expand All @@ -783,7 +783,7 @@ public void testRerank_reranksHits_WhenTargetFieldIsNumericalString() throws IOE
SearchResponse searchResponse = argCaptor.getValue();

assertEquals(sampleIndexMLScorePairs.size(), searchResponse.getHits().getHits().length);
assertEquals(sortedScoresDescending.getFirst().getValue(), searchResponse.getHits().getMaxScore(), 0.0001);
assertEquals(sortedScoresDescending.get(0).getValue(), searchResponse.getHits().getMaxScore(), 0.0001);

for (int i = 0; i < sortedScoresDescending.size(); i++) {
int docId = sortedScoresDescending.get(i).getKey();
Expand Down Expand Up @@ -812,22 +812,20 @@ public void testRerank_reranksHits_WhenTargetFieldIsNumericalString() throws IOE
private void setUpValidSearchResultsWithNestedTargetValueWithNumericalString() {
SearchHit[] hits = new SearchHit[sampleIndexMLScorePairs.size()];

String templateString = """
{
"my_field" : "%s",
"ml": {
"info" : {
"score": "%s"
}
}
}
""".replace("\n", "");
String templateString = "{\n"
+ " \"my_field\" : \"%s\",\n"
+ " \"ml\": {\n"
+ " \"info\" : {\n"
+ " \"score\": \"%s\"\n"
+ " }\n"
+ " }\n"
+ "}\n".replace("\n", "");

for (int i = 0; i < sampleIndexMLScorePairs.size(); i++) {
int docId = sampleIndexMLScorePairs.get(i).getKey();
String mlScore = sampleIndexMLScorePairs.get(i).getValue() + "";

String sourceMap = templateString.formatted(i, mlScore);
String sourceMap = String.format(Locale.ROOT, templateString, i, mlScore);

hits[i] = new SearchHit(docId, docId + "", Collections.emptyMap(), Collections.emptyMap());
hits[i].sourceRef(new BytesArray(sourceMap));
Expand Down

0 comments on commit c662637

Please sign in to comment.