@@ -762,7 +762,7 @@ public void testRerank_reranksHits_WhenTargetFieldIsNumericalString() throws IOE
762
762
setUpValidSearchResultsWithNestedTargetValueWithNumericalString ();
763
763
List <Map .Entry <Integer , Float >> sortedScoresDescending = sampleIndexMLScorePairs .stream ()
764
764
.sorted (Map .Entry .<Integer , Float >comparingByValue ().reversed ())
765
- .toList ();
765
+ .collect ( Collectors . toList () );
766
766
767
767
Map <String , Object > config = new HashMap <>(
768
768
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
783
783
SearchResponse searchResponse = argCaptor .getValue ();
784
784
785
785
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 );
787
787
788
788
for (int i = 0 ; i < sortedScoresDescending .size (); i ++) {
789
789
int docId = sortedScoresDescending .get (i ).getKey ();
@@ -812,22 +812,20 @@ public void testRerank_reranksHits_WhenTargetFieldIsNumericalString() throws IOE
812
812
private void setUpValidSearchResultsWithNestedTargetValueWithNumericalString () {
813
813
SearchHit [] hits = new SearchHit [sampleIndexMLScorePairs .size ()];
814
814
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 " , "" );
825
823
826
824
for (int i = 0 ; i < sampleIndexMLScorePairs .size (); i ++) {
827
825
int docId = sampleIndexMLScorePairs .get (i ).getKey ();
828
826
String mlScore = sampleIndexMLScorePairs .get (i ).getValue () + "" ;
829
827
830
- String sourceMap = templateString . formatted ( i , mlScore );
828
+ String sourceMap = String . format ( Locale . ROOT , templateString , i , mlScore );
831
829
832
830
hits [i ] = new SearchHit (docId , docId + "" , Collections .emptyMap (), Collections .emptyMap ());
833
831
hits [i ].sourceRef (new BytesArray (sourceMap ));
0 commit comments