@@ -350,8 +350,8 @@ public Builder(String name, IndexVersion indexVersionCreated) {
350350 }
351351
352352 private DenseVectorIndexOptions defaultIndexOptions (boolean defaultInt8Hnsw , boolean defaultBBQHnsw ) {
353- if (elementType .getValue () == ElementType .FLOAT && this .indexed .getValue ()) {
354- if (defaultBBQHnsw && this .dims != null && this . dims . isConfigured () && this . dims .getValue () >= BBQ_DIMS_DEFAULT_THRESHOLD ) {
353+ if (this . dims != null && this . dims . isConfigured () && elementType .getValue () == ElementType .FLOAT && this .indexed .getValue ()) {
354+ if (defaultBBQHnsw && this .dims .getValue () >= BBQ_DIMS_DEFAULT_THRESHOLD ) {
355355 return new BBQHnswIndexOptions (
356356 Lucene99HnswVectorsFormat .DEFAULT_MAX_CONN ,
357357 Lucene99HnswVectorsFormat .DEFAULT_BEAM_WIDTH ,
@@ -2713,8 +2713,29 @@ public void parse(DocumentParserContext context) throws IOException {
27132713 }
27142714 if (fieldType ().dims == null ) {
27152715 int dims = fieldType ().elementType .parseDimensionCount (context );
2716- if (fieldType ().indexOptions != null ) {
2717- fieldType ().indexOptions .validateDimension (dims );
2716+ IndexVersion indexVersionCreated = context .indexSettings ().getIndexVersionCreated ();
2717+ final boolean defaultInt8Hnsw = indexVersionCreated .onOrAfter (IndexVersions .DEFAULT_DENSE_VECTOR_TO_INT8_HNSW );
2718+ final boolean defaultBBQ8Hnsw = indexVersionCreated .onOrAfter (IndexVersions .DEFAULT_DENSE_VECTOR_TO_BBQ_HNSW );
2719+ DenseVectorIndexOptions denseVectorIndexOptions = fieldType ().indexOptions ;
2720+ if (denseVectorIndexOptions == null && fieldType ().getElementType () == ElementType .FLOAT && fieldType ().isIndexed ()) {
2721+ if (defaultBBQ8Hnsw && dims >= BBQ_DIMS_DEFAULT_THRESHOLD ) {
2722+ denseVectorIndexOptions = new BBQHnswIndexOptions (
2723+ Lucene99HnswVectorsFormat .DEFAULT_MAX_CONN ,
2724+ Lucene99HnswVectorsFormat .DEFAULT_BEAM_WIDTH ,
2725+ new RescoreVector (DEFAULT_OVERSAMPLE )
2726+ );
2727+ } else if (defaultInt8Hnsw ) {
2728+ denseVectorIndexOptions = new Int8HnswIndexOptions (
2729+ Lucene99HnswVectorsFormat .DEFAULT_MAX_CONN ,
2730+ Lucene99HnswVectorsFormat .DEFAULT_BEAM_WIDTH ,
2731+ null ,
2732+ null
2733+ );
2734+ }
2735+ }
2736+ ;
2737+ if (denseVectorIndexOptions != null ) {
2738+ denseVectorIndexOptions .validateDimension (dims );
27182739 }
27192740 DenseVectorFieldType updatedDenseVectorFieldType = new DenseVectorFieldType (
27202741 fieldType ().name (),
@@ -2723,15 +2744,15 @@ public void parse(DocumentParserContext context) throws IOException {
27232744 dims ,
27242745 fieldType ().indexed ,
27252746 fieldType ().similarity ,
2726- fieldType (). indexOptions ,
2747+ denseVectorIndexOptions ,
27272748 fieldType ().meta (),
27282749 fieldType ().isSyntheticSource
27292750 );
27302751 Mapper update = new DenseVectorFieldMapper (
27312752 leafName (),
27322753 updatedDenseVectorFieldType ,
27332754 builderParams ,
2734- indexOptions ,
2755+ denseVectorIndexOptions ,
27352756 indexCreatedVersion
27362757 );
27372758 context .addDynamicMapper (update );
0 commit comments