File tree Expand file tree Collapse file tree
integ-test/src/test/java/org/opensearch/sql/security Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616import java .io .IOException ;
1717import java .util .Locale ;
1818import org .apache .commons .text .StringEscapeUtils ;
19+ import org .json .JSONArray ;
1920import org .json .JSONObject ;
2021import org .junit .Assert ;
2122import org .junit .Test ;
@@ -485,10 +486,18 @@ public void testCrossClusterHighlightWildcard() throws IOException {
485486 String .format (
486487 "search source=%s \\ \" Hattie\\ \" | fields firstname" , TEST_INDEX_BANK_REMOTE ),
487488 "[\" *\" ]" );
488- verifySchema (result , schema ("firstname" , "string" ));
489- verifyDataRows (result , rows ("Hattie" ));
490- var highlights = result .getJSONArray ("highlights" );
491- var highlight = highlights .getJSONObject (0 );
489+ JSONArray schemaArray = result .getJSONArray ("schema" );
490+ int hlIndex = -1 ;
491+ for (int i = 0 ; i < schemaArray .length (); i ++) {
492+ if ("_highlight" .equals (schemaArray .getJSONObject (i ).getString ("name" ))) {
493+ hlIndex = i ;
494+ break ;
495+ }
496+ }
497+ Assert .assertTrue ("Schema should contain _highlight column" , hlIndex >= 0 );
498+ JSONArray dataRows = result .getJSONArray ("datarows" );
499+ Assert .assertTrue ("Should have at least one row" , dataRows .length () > 0 );
500+ var highlight = dataRows .getJSONArray (0 ).getJSONObject (hlIndex );
492501 Assert .assertTrue (
493502 "Highlight should contain <em>Hattie</em>" ,
494503 highlight .getJSONArray ("firstname" ).getString (0 ).contains ("<em>Hattie</em>" ));
You can’t perform that action at this time.
0 commit comments