@@ -779,7 +779,7 @@ public void testSuccessfulParse() throws IOException {
779779 Model model1 = TestModel .createRandomInstance (taskType );
780780 Model model2 = TestModel .createRandomInstance (taskType );
781781 ChunkingSettings chunkingSettings = null ; // Some chunking settings configs can produce different Lucene docs counts
782- SemanticTextIndexOptions indexOptions = randomSemanticTextIndexOptions (taskType , IndexVersion . current () );
782+ SemanticTextIndexOptions indexOptions = randomSemanticTextIndexOptions (taskType );
783783 XContentBuilder mapping = mapping (b -> {
784784 addSemanticTextMapping (
785785 b ,
@@ -1054,7 +1054,7 @@ public void testModelSettingsRequiredWithChunks() throws IOException {
10541054 TaskType taskType = TaskType .SPARSE_EMBEDDING ;
10551055 Model model = TestModel .createRandomInstance (taskType );
10561056 ChunkingSettings chunkingSettings = generateRandomChunkingSettings (false );
1057- SemanticTextIndexOptions indexOptions = randomSemanticTextIndexOptions (taskType , IndexVersion . current () );
1057+ SemanticTextIndexOptions indexOptions = randomSemanticTextIndexOptions (taskType );
10581058 SemanticTextField randomSemanticText = randomSemanticText (
10591059 useLegacyFormat ,
10601060 "field" ,
@@ -1185,12 +1185,8 @@ private static DenseVectorFieldMapper.DenseVectorIndexOptions defaultDenseVector
11851185 return new DenseVectorFieldMapper .Int8HnswIndexOptions (m , efConstruction , null , null );
11861186 }
11871187
1188- private static SemanticTextIndexOptions defaultDenseVectorSemanticIndexOptions (IndexVersion indexVersion ) {
1189- return new SemanticTextIndexOptions (
1190- SemanticTextIndexOptions .SupportedIndexOptions .DENSE_VECTOR ,
1191- defaultDenseVectorIndexOptions (),
1192- indexVersion
1193- );
1188+ private static SemanticTextIndexOptions defaultDenseVectorSemanticIndexOptions () {
1189+ return new SemanticTextIndexOptions (SemanticTextIndexOptions .SupportedIndexOptions .DENSE_VECTOR , defaultDenseVectorIndexOptions ());
11941190 }
11951191
11961192 private static DenseVectorFieldMapper .DenseVectorIndexOptions defaultBbqHnswDenseVectorIndexOptions () {
@@ -1200,22 +1196,16 @@ private static DenseVectorFieldMapper.DenseVectorIndexOptions defaultBbqHnswDens
12001196 return new DenseVectorFieldMapper .BBQHnswIndexOptions (m , efConstruction , rescoreVector );
12011197 }
12021198
1203- private static SemanticTextIndexOptions defaultBbqHnswSemanticTextIndexOptions (IndexVersion indexVersion ) {
1199+ private static SemanticTextIndexOptions defaultBbqHnswSemanticTextIndexOptions () {
12041200 return new SemanticTextIndexOptions (
12051201 SemanticTextIndexOptions .SupportedIndexOptions .DENSE_VECTOR ,
1206- defaultBbqHnswDenseVectorIndexOptions (),
1207- indexVersion
1202+ defaultBbqHnswDenseVectorIndexOptions ()
12081203 );
12091204 }
12101205
12111206 public void testDefaultIndexOptions () throws IOException {
12121207
12131208 // We default to BBQ for eligible dense vectors
1214- var indexVersion = IndexVersionUtils .randomVersionBetween (
1215- random (),
1216- IndexVersions .SEMANTIC_TEXT_DEFAULTS_TO_BBQ ,
1217- IndexVersion .current ()
1218- );
12191209 var mapperService = createMapperService (fieldMapping (b -> {
12201210 b .field ("type" , "semantic_text" );
12211211 b .field ("inference_id" , "another_inference_id" );
@@ -1225,8 +1215,8 @@ public void testDefaultIndexOptions() throws IOException {
12251215 b .field ("similarity" , "cosine" );
12261216 b .field ("element_type" , "float" );
12271217 b .endObject ();
1228- }), useLegacyFormat , indexVersion , indexVersion );
1229- assertSemanticTextField (mapperService , "field" , true , null , defaultBbqHnswSemanticTextIndexOptions (indexVersion ));
1218+ }), useLegacyFormat , IndexVersions . SEMANTIC_TEXT_DEFAULTS_TO_BBQ );
1219+ assertSemanticTextField (mapperService , "field" , true , null , defaultBbqHnswSemanticTextIndexOptions ());
12301220
12311221 // Element types that are incompatible with BBQ will continue to use dense_vector defaults
12321222 mapperService = createMapperService (fieldMapping (b -> {
@@ -1238,7 +1228,7 @@ public void testDefaultIndexOptions() throws IOException {
12381228 b .field ("similarity" , "cosine" );
12391229 b .field ("element_type" , "byte" );
12401230 b .endObject ();
1241- }), useLegacyFormat , indexVersion , indexVersion );
1231+ }), useLegacyFormat , IndexVersions . SEMANTIC_TEXT_DEFAULTS_TO_BBQ );
12421232 assertSemanticTextField (mapperService , "field" , true , null , null );
12431233
12441234 // A dim count of 10 is too small to support BBQ, so we continue to use dense_vector defaults
@@ -1251,17 +1241,13 @@ public void testDefaultIndexOptions() throws IOException {
12511241 b .field ("similarity" , "cosine" );
12521242 b .field ("element_type" , "float" );
12531243 b .endObject ();
1254- }), useLegacyFormat , indexVersion , indexVersion );
1244+ }), useLegacyFormat , IndexVersions . SEMANTIC_TEXT_DEFAULTS_TO_BBQ );
12551245 assertSemanticTextField (
12561246 mapperService ,
12571247 "field" ,
12581248 true ,
12591249 null ,
1260- new SemanticTextIndexOptions (
1261- SemanticTextIndexOptions .SupportedIndexOptions .DENSE_VECTOR ,
1262- defaultDenseVectorIndexOptions (),
1263- indexVersion
1264- )
1250+ new SemanticTextIndexOptions (SemanticTextIndexOptions .SupportedIndexOptions .DENSE_VECTOR , defaultDenseVectorIndexOptions ())
12651251 );
12661252
12671253 // If we explicitly set index options, we respect those over the defaults
@@ -1281,25 +1267,19 @@ public void testDefaultIndexOptions() throws IOException {
12811267 b .field ("ef_construction" , 100 );
12821268 b .endObject ();
12831269 b .endObject ();
1284- }), useLegacyFormat , indexVersion , indexVersion );
1270+ }), useLegacyFormat , IndexVersions . SEMANTIC_TEXT_DEFAULTS_TO_BBQ );
12851271 assertSemanticTextField (
12861272 mapperService ,
12871273 "field" ,
12881274 true ,
12891275 null ,
12901276 new SemanticTextIndexOptions (
12911277 SemanticTextIndexOptions .SupportedIndexOptions .DENSE_VECTOR ,
1292- new DenseVectorFieldMapper .Int4HnswIndexOptions (25 , 100 , null , null ),
1293- indexVersion
1278+ new DenseVectorFieldMapper .Int4HnswIndexOptions (25 , 100 , null , null )
12941279 )
12951280 );
12961281
12971282 // Previous index versions do not set BBQ index options
1298- indexVersion = IndexVersionUtils .randomVersionBetween (
1299- random (),
1300- IndexVersions .INFERENCE_METADATA_FIELDS ,
1301- IndexVersionUtils .getPreviousVersion (IndexVersions .SEMANTIC_TEXT_DEFAULTS_TO_BBQ )
1302- );
13031283 mapperService = createMapperService (fieldMapping (b -> {
13041284 b .field ("type" , "semantic_text" );
13051285 b .field ("inference_id" , "another_inference_id" );
@@ -1309,15 +1289,14 @@ public void testDefaultIndexOptions() throws IOException {
13091289 b .field ("similarity" , "cosine" );
13101290 b .field ("element_type" , "float" );
13111291 b .endObject ();
1312- }), useLegacyFormat , indexVersion , indexVersion );
1313- assertSemanticTextField (mapperService , "field" , true , null , defaultDenseVectorSemanticIndexOptions (indexVersion ));
1292+ }),
1293+ useLegacyFormat ,
1294+ IndexVersions .INFERENCE_METADATA_FIELDS ,
1295+ IndexVersionUtils .getPreviousVersion (IndexVersions .SEMANTIC_TEXT_DEFAULTS_TO_BBQ )
1296+ );
1297+ assertSemanticTextField (mapperService , "field" , true , null , defaultDenseVectorSemanticIndexOptions ());
13141298
13151299 // 8.x index versions that use backported default BBQ set default BBQ index options as expected
1316- indexVersion = IndexVersionUtils .randomVersionBetween (
1317- random (),
1318- IndexVersions .SEMANTIC_TEXT_DEFAULTS_TO_BBQ_BACKPORT_8_X ,
1319- IndexVersions .UPGRADE_TO_LUCENE_10_0_0
1320- );
13211300 mapperService = createMapperService (fieldMapping (b -> {
13221301 b .field ("type" , "semantic_text" );
13231302 b .field ("inference_id" , "another_inference_id" );
@@ -1327,15 +1306,10 @@ public void testDefaultIndexOptions() throws IOException {
13271306 b .field ("similarity" , "cosine" );
13281307 b .field ("element_type" , "float" );
13291308 b .endObject ();
1330- }), useLegacyFormat , indexVersion , indexVersion );
1331- assertSemanticTextField (mapperService , "field" , true , null , defaultBbqHnswSemanticTextIndexOptions (indexVersion ));
1309+ }), useLegacyFormat , IndexVersions . SEMANTIC_TEXT_DEFAULTS_TO_BBQ_BACKPORT_8_X , IndexVersions . UPGRADE_TO_LUCENE_10_0_0 );
1310+ assertSemanticTextField (mapperService , "field" , true , null , defaultBbqHnswSemanticTextIndexOptions ());
13321311
13331312 // Previous 8.x index versions do not set BBQ index options
1334- indexVersion = IndexVersionUtils .randomVersionBetween (
1335- random (),
1336- IndexVersions .INFERENCE_METADATA_FIELDS_BACKPORT ,
1337- IndexVersions .SEMANTIC_TEXT_DEFAULTS_TO_BBQ_BACKPORT_8_X
1338- );
13391313 mapperService = createMapperService (fieldMapping (b -> {
13401314 b .field ("type" , "semantic_text" );
13411315 b .field ("inference_id" , "another_inference_id" );
@@ -1345,18 +1319,17 @@ public void testDefaultIndexOptions() throws IOException {
13451319 b .field ("similarity" , "cosine" );
13461320 b .field ("element_type" , "float" );
13471321 b .endObject ();
1348- }), useLegacyFormat , indexVersion , indexVersion );
1349- assertSemanticTextField (mapperService , "field" , true , null , defaultDenseVectorSemanticIndexOptions (indexVersion ));
1322+ }),
1323+ useLegacyFormat ,
1324+ IndexVersions .INFERENCE_METADATA_FIELDS_BACKPORT ,
1325+ IndexVersionUtils .getPreviousVersion (IndexVersions .SEMANTIC_TEXT_DEFAULTS_TO_BBQ_BACKPORT_8_X )
1326+ );
1327+ assertSemanticTextField (mapperService , "field" , true , null , defaultDenseVectorSemanticIndexOptions ());
13501328 }
13511329
13521330 public void testSpecifiedDenseVectorIndexOptions () throws IOException {
13531331
13541332 // Specifying index options will override default index option settings
1355- var indexVersion = IndexVersionUtils .randomVersionBetween (
1356- random (),
1357- IndexVersions .INFERENCE_METADATA_FIELDS_BACKPORT ,
1358- IndexVersion .current ()
1359- );
13601333 var mapperService = createMapperService (fieldMapping (b -> {
13611334 b .field ("type" , "semantic_text" );
13621335 b .field ("inference_id" , "another_inference_id" );
@@ -1374,16 +1347,15 @@ public void testSpecifiedDenseVectorIndexOptions() throws IOException {
13741347 b .field ("confidence_interval" , 0.4 );
13751348 b .endObject ();
13761349 b .endObject ();
1377- }), useLegacyFormat , indexVersion , indexVersion );
1350+ }), useLegacyFormat , IndexVersions . INFERENCE_METADATA_FIELDS_BACKPORT );
13781351 assertSemanticTextField (
13791352 mapperService ,
13801353 "field" ,
13811354 true ,
13821355 null ,
13831356 new SemanticTextIndexOptions (
13841357 SemanticTextIndexOptions .SupportedIndexOptions .DENSE_VECTOR ,
1385- new DenseVectorFieldMapper .Int4HnswIndexOptions (20 , 90 , 0.4f , null ),
1386- indexVersion
1358+ new DenseVectorFieldMapper .Int4HnswIndexOptions (20 , 90 , 0.4f , null )
13871359 )
13881360 );
13891361
@@ -1402,16 +1374,15 @@ public void testSpecifiedDenseVectorIndexOptions() throws IOException {
14021374 b .field ("type" , "int4_hnsw" );
14031375 b .endObject ();
14041376 b .endObject ();
1405- }), useLegacyFormat , indexVersion , indexVersion );
1377+ }), useLegacyFormat , IndexVersions . INFERENCE_METADATA_FIELDS_BACKPORT );
14061378 assertSemanticTextField (
14071379 mapperService ,
14081380 "field" ,
14091381 true ,
14101382 null ,
14111383 new SemanticTextIndexOptions (
14121384 SemanticTextIndexOptions .SupportedIndexOptions .DENSE_VECTOR ,
1413- new DenseVectorFieldMapper .Int4HnswIndexOptions (16 , 100 , 0f , null ),
1414- indexVersion
1385+ new DenseVectorFieldMapper .Int4HnswIndexOptions (16 , 100 , 0f , null )
14151386 )
14161387 );
14171388
@@ -1469,19 +1440,15 @@ public void testSpecifiedDenseVectorIndexOptions() throws IOException {
14691440
14701441 public static SemanticTextIndexOptions randomSemanticTextIndexOptions () {
14711442 TaskType taskType = randomFrom (TaskType .SPARSE_EMBEDDING , TaskType .TEXT_EMBEDDING );
1472- return randomSemanticTextIndexOptions (taskType , IndexVersion . current () );
1443+ return randomSemanticTextIndexOptions (taskType );
14731444 }
14741445
1475- public static SemanticTextIndexOptions randomSemanticTextIndexOptions (TaskType taskType , IndexVersion indexVersion ) {
1446+ public static SemanticTextIndexOptions randomSemanticTextIndexOptions (TaskType taskType ) {
14761447
14771448 if (taskType == TaskType .TEXT_EMBEDDING ) {
14781449 return randomBoolean ()
14791450 ? null
1480- : new SemanticTextIndexOptions (
1481- SemanticTextIndexOptions .SupportedIndexOptions .DENSE_VECTOR ,
1482- randomIndexOptionsAll (),
1483- indexVersion
1484- );
1451+ : new SemanticTextIndexOptions (SemanticTextIndexOptions .SupportedIndexOptions .DENSE_VECTOR , randomIndexOptionsAll ());
14851452 }
14861453
14871454 return null ;
0 commit comments