4444
4545public  class  SemanticTextIndexVersionIT  extends  ESIntegTestCase  {
4646    private  static  final  IndexVersion  SEMANTIC_TEXT_INTRODUCED_VERSION  = IndexVersion .fromId (8512000 );
47- 
47+      private   static   final   double   PERCENTAGE_TO_TEST  =  0.5 ; 
4848    private  Set <IndexVersion > availableVersions ;
49-     private  static  final  int  MIN_NUMBER_OF_TESTS_TO_RUN  = 10 ;
5049
5150    @ Before 
5251    public  void  setup () throws  Exception  {
5352        Utils .storeSparseModel (client ());
5453        availableVersions  = IndexVersionUtils .allReleasedVersions ().stream ()
5554            .filter (indexVersion  -> indexVersion .after (SEMANTIC_TEXT_INTRODUCED_VERSION ))
5655            .collect (Collectors .toSet ());
57- 
58-         logger .info ("Available versions for testing: {}" , availableVersions );
5956    }
6057
6158    @ Override 
@@ -86,7 +83,7 @@ private Settings getIndexSettingsWithVersion(IndexVersion version) {
8683     * @return Map of created indices with their versions 
8784     */ 
8885    protected  Map <String , IndexVersion > createRandomVersionIndices () throws  IOException  {
89-         int  versionsCount  = Math .min ( MIN_NUMBER_OF_TESTS_TO_RUN ,  availableVersions .size ());
86+         int  versionsCount  = ( int )  Math .ceil ( availableVersions .size () *  PERCENTAGE_TO_TEST );
9087        List <IndexVersion > selectedVersions  = randomSubsetOf (versionsCount , availableVersions );
9188        Map <String , IndexVersion > result  = new  HashMap <>();
9289
@@ -100,11 +97,14 @@ protected Map<String, IndexVersion> createRandomVersionIndices() throws IOExcept
10097        return  result ;
10198    }
10299
100+     /** 
101+      * This test creates an index, ingests data, and performs searches (including highlighting when applicable) 
102+      * for a selected subset of index versions. 
103+      */ 
103104    public  void  testSemanticText () throws  Exception  {
104105        Map <String , IndexVersion > indices  = createRandomVersionIndices ();
105106        for  (String  indexName  : indices .keySet ()) {
106107            IndexVersion  version  = indices .get (indexName );
107-             logger .info ("Testing index [{}] with version [{}] [{}]" , indexName , version , version .toReleaseVersion ());
108108
109109            // Test index creation 
110110            assertTrue ("Index "  + indexName  + " should exist" , indexExists (indexName ));
@@ -155,14 +155,14 @@ public void testSemanticText() throws Exception {
155155                assertHitCount (response , 1L );
156156            });
157157
158-             //Semantic Search with highlighter only available from 8.18 and 9.0 
159158            Settings  settings  = client ().admin ()
160159                .indices ()
161160                .prepareGetSettings (TimeValue .THIRTY_SECONDS , indexName )
162161                .get ()
163162                .getIndexToSettings ()
164163                .get (indexName );
165164
165+             //Semantic Search with highlighter only available from 8.18 and 9.0 
166166            if  (InferenceMetadataFieldsMapper .isEnabled (settings )) {
167167                SearchSourceBuilder  sourceHighlighterBuilder  = new  SearchSourceBuilder ()
168168                    .query (new  SemanticQueryBuilder ("semantic_field" , "inference" ))
0 commit comments