107107import static org .elasticsearch .xpack .inference .mapper .SemanticTextField .getChunksFieldName ;
108108import static org .elasticsearch .xpack .inference .mapper .SemanticTextField .getEmbeddingsFieldName ;
109109import static org .elasticsearch .xpack .inference .mapper .SemanticTextFieldMapper .DEFAULT_ELSER_2_INFERENCE_ID ;
110+ import static org .elasticsearch .xpack .inference .mapper .SemanticTextFieldMapper .DEFAULT_RESCORE_OVERSAMPLE ;
110111import static org .elasticsearch .xpack .inference .mapper .SemanticTextFieldTests .generateRandomChunkingSettings ;
111112import static org .elasticsearch .xpack .inference .mapper .SemanticTextFieldTests .generateRandomChunkingSettingsOtherThan ;
112113import static org .elasticsearch .xpack .inference .mapper .SemanticTextFieldTests .randomSemanticText ;
@@ -1203,6 +1204,24 @@ private static DenseVectorFieldMapper.DenseVectorIndexOptions defaultDenseVector
12031204 return new DenseVectorFieldMapper .Int8HnswIndexOptions (m , efConstruction , null , null );
12041205 }
12051206
1207+ private static SemanticTextIndexOptions defaultDenseVectorSemanticIndexOptions () {
1208+ return new SemanticTextIndexOptions (SemanticTextIndexOptions .SupportedIndexOptions .DENSE_VECTOR , defaultDenseVectorIndexOptions ());
1209+ }
1210+
1211+ private static DenseVectorFieldMapper .DenseVectorIndexOptions defaultBbqHnswDenseVectorIndexOptions () {
1212+ int m = Lucene99HnswVectorsFormat .DEFAULT_MAX_CONN ;
1213+ int efConstruction = Lucene99HnswVectorsFormat .DEFAULT_BEAM_WIDTH ;
1214+ DenseVectorFieldMapper .RescoreVector rescoreVector = new DenseVectorFieldMapper .RescoreVector (DEFAULT_RESCORE_OVERSAMPLE );
1215+ return new DenseVectorFieldMapper .BBQHnswIndexOptions (m , efConstruction , rescoreVector );
1216+ }
1217+
1218+ private static SemanticTextIndexOptions defaultBbqHnswSemanticTextIndexOptions () {
1219+ return new SemanticTextIndexOptions (
1220+ SemanticTextIndexOptions .SupportedIndexOptions .DENSE_VECTOR ,
1221+ defaultBbqHnswDenseVectorIndexOptions ()
1222+ );
1223+ }
1224+
12061225 public void testDefaultIndexOptions () throws IOException {
12071226
12081227 // We default to BBQ for eligible dense vectors
@@ -1216,7 +1235,7 @@ public void testDefaultIndexOptions() throws IOException {
12161235 b .field ("element_type" , "float" );
12171236 b .endObject ();
12181237 }), useLegacyFormat , IndexVersions .SEMANTIC_TEXT_DEFAULTS_TO_BBQ );
1219- assertSemanticTextField (mapperService , "field" , true , null , SemanticTextFieldMapper . defaultSemanticDenseIndexOptions ());
1238+ assertSemanticTextField (mapperService , "field" , true , null , defaultBbqHnswSemanticTextIndexOptions ());
12201239
12211240 // Element types that are incompatible with BBQ will continue to use dense_vector defaults
12221241 mapperService = createMapperService (fieldMapping (b -> {
@@ -1294,13 +1313,7 @@ public void testDefaultIndexOptions() throws IOException {
12941313 IndexVersions .INFERENCE_METADATA_FIELDS ,
12951314 IndexVersionUtils .getPreviousVersion (IndexVersions .SEMANTIC_TEXT_DEFAULTS_TO_BBQ )
12961315 );
1297- assertSemanticTextField (
1298- mapperService ,
1299- "field" ,
1300- true ,
1301- null ,
1302- new SemanticTextIndexOptions (SemanticTextIndexOptions .SupportedIndexOptions .DENSE_VECTOR , defaultDenseVectorIndexOptions ())
1303- );
1316+ assertSemanticTextField (mapperService , "field" , true , null , defaultDenseVectorSemanticIndexOptions ());
13041317
13051318 // 8.x index versions that use backported default BBQ set default BBQ index options as expected
13061319 mapperService = createMapperService (fieldMapping (b -> {
@@ -1313,7 +1326,7 @@ public void testDefaultIndexOptions() throws IOException {
13131326 b .field ("element_type" , "float" );
13141327 b .endObject ();
13151328 }), useLegacyFormat , IndexVersions .SEMANTIC_TEXT_DEFAULTS_TO_BBQ_BACKPORT_8_X , IndexVersions .UPGRADE_TO_LUCENE_10_0_0 );
1316- assertSemanticTextField (mapperService , "field" , true , null , SemanticTextFieldMapper . defaultSemanticDenseIndexOptions ());
1329+ assertSemanticTextField (mapperService , "field" , true , null , defaultBbqHnswSemanticTextIndexOptions ());
13171330
13181331 // Previous 8.x index versions do not set BBQ index options
13191332 mapperService = createMapperService (fieldMapping (b -> {
@@ -1330,7 +1343,7 @@ public void testDefaultIndexOptions() throws IOException {
13301343 IndexVersions .INFERENCE_METADATA_FIELDS_BACKPORT ,
13311344 IndexVersionUtils .getPreviousVersion (IndexVersions .SEMANTIC_TEXT_DEFAULTS_TO_BBQ_BACKPORT_8_X )
13321345 );
1333- assertSemanticTextField (mapperService , "field" , true , null , defaultDenseVectorIndexOptions ());
1346+ assertSemanticTextField (mapperService , "field" , true , null , defaultDenseVectorSemanticIndexOptions ());
13341347 }
13351348
13361349 @ Override
0 commit comments