Skip to content

Commit c662637

Browse files
authored
Reverts Java 15 features from a backport to 2.x (#1121)
* 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]>
1 parent d060c51 commit c662637

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/test/java/org/opensearch/neuralsearch/processor/rerank/ByFieldRerankProcessorTests.java

+11-13
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ public void testRerank_reranksHits_WhenTargetFieldIsNumericalString() throws IOE
762762
setUpValidSearchResultsWithNestedTargetValueWithNumericalString();
763763
List<Map.Entry<Integer, Float>> sortedScoresDescending = sampleIndexMLScorePairs.stream()
764764
.sorted(Map.Entry.<Integer, Float>comparingByValue().reversed())
765-
.toList();
765+
.collect(Collectors.toList());
766766

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

785785
assertEquals(sampleIndexMLScorePairs.size(), searchResponse.getHits().getHits().length);
786-
assertEquals(sortedScoresDescending.getFirst().getValue(), searchResponse.getHits().getMaxScore(), 0.0001);
786+
assertEquals(sortedScoresDescending.get(0).getValue(), searchResponse.getHits().getMaxScore(), 0.0001);
787787

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

815-
String templateString = """
816-
{
817-
"my_field" : "%s",
818-
"ml": {
819-
"info" : {
820-
"score": "%s"
821-
}
822-
}
823-
}
824-
""".replace("\n", "");
815+
String templateString = "{\n"
816+
+ " \"my_field\" : \"%s\",\n"
817+
+ " \"ml\": {\n"
818+
+ " \"info\" : {\n"
819+
+ " \"score\": \"%s\"\n"
820+
+ " }\n"
821+
+ " }\n"
822+
+ "}\n".replace("\n", "");
825823

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

830-
String sourceMap = templateString.formatted(i, mlScore);
828+
String sourceMap = String.format(Locale.ROOT, templateString, i, mlScore);
831829

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

0 commit comments

Comments
 (0)