@@ -290,11 +290,6 @@ public Builder elementType(ElementType elementType) {
290290 return this ;
291291 }
292292
293- public Builder indexOptions (IndexOptions indexOptions ) {
294- this .indexOptions .setValue (indexOptions );
295- return this ;
296- }
297-
298293 @ Override
299294 public DenseVectorFieldMapper build (MapperBuilderContext context ) {
300295 // Validate again here because the dimensions or element type could have been set programmatically,
@@ -1226,7 +1221,7 @@ public final String toString() {
12261221 public abstract VectorSimilarityFunction vectorSimilarityFunction (IndexVersion indexVersion , ElementType elementType );
12271222 }
12281223
1229- public abstract static class IndexOptions implements ToXContent {
1224+ abstract static class IndexOptions implements ToXContent {
12301225 final VectorIndexType type ;
12311226
12321227 IndexOptions (VectorIndexType type ) {
@@ -1235,36 +1230,21 @@ public abstract static class IndexOptions implements ToXContent {
12351230
12361231 abstract KnnVectorsFormat getVectorsFormat (ElementType elementType );
12371232
1238- public boolean validate (ElementType elementType , int dim , boolean throwOnError ) {
1239- return validateElementType (elementType , throwOnError ) && validateDimension (dim , throwOnError );
1240- }
1241-
1242- public boolean validateElementType (ElementType elementType ) {
1243- return validateElementType (elementType , true );
1244- }
1245-
1246- final boolean validateElementType (ElementType elementType , boolean throwOnError ) {
1247- boolean validElementType = type .supportsElementType (elementType );
1248- if (throwOnError && validElementType == false ) {
1233+ final void validateElementType (ElementType elementType ) {
1234+ if (type .supportsElementType (elementType ) == false ) {
12491235 throw new IllegalArgumentException (
12501236 "[element_type] cannot be [" + elementType .toString () + "] when using index type [" + type + "]"
12511237 );
12521238 }
1253- return validElementType ;
12541239 }
12551240
12561241 abstract boolean updatableTo (IndexOptions update );
12571242
1258- public boolean validateDimension (int dim ) {
1259- return validateDimension (dim , true );
1260- }
1261-
1262- public boolean validateDimension (int dim , boolean throwOnError ) {
1263- boolean supportsDimension = type .supportsDimension (dim );
1264- if (throwOnError && supportsDimension == false ) {
1265- throw new IllegalArgumentException (type .name + " only supports even dimensions; provided=" + dim );
1243+ public void validateDimension (int dim ) {
1244+ if (type .supportsDimension (dim )) {
1245+ return ;
12661246 }
1267- return supportsDimension ;
1247+ throw new IllegalArgumentException ( type . name + " only supports even dimensions; provided=" + dim ) ;
12681248 }
12691249
12701250 abstract boolean doEquals (IndexOptions other );
@@ -1767,12 +1747,12 @@ boolean updatableTo(IndexOptions update) {
17671747
17681748 }
17691749
1770- public static class Int8HnswIndexOptions extends QuantizedIndexOptions {
1750+ static class Int8HnswIndexOptions extends QuantizedIndexOptions {
17711751 private final int m ;
17721752 private final int efConstruction ;
17731753 private final Float confidenceInterval ;
17741754
1775- public Int8HnswIndexOptions (int m , int efConstruction , Float confidenceInterval , RescoreVector rescoreVector ) {
1755+ Int8HnswIndexOptions (int m , int efConstruction , Float confidenceInterval , RescoreVector rescoreVector ) {
17761756 super (VectorIndexType .INT8_HNSW , rescoreVector );
17771757 this .m = m ;
17781758 this .efConstruction = efConstruction ;
@@ -1910,11 +1890,11 @@ public String toString() {
19101890 }
19111891 }
19121892
1913- public static class BBQHnswIndexOptions extends QuantizedIndexOptions {
1893+ static class BBQHnswIndexOptions extends QuantizedIndexOptions {
19141894 private final int m ;
19151895 private final int efConstruction ;
19161896
1917- public BBQHnswIndexOptions (int m , int efConstruction , RescoreVector rescoreVector ) {
1897+ BBQHnswIndexOptions (int m , int efConstruction , RescoreVector rescoreVector ) {
19181898 super (VectorIndexType .BBQ_HNSW , rescoreVector );
19191899 this .m = m ;
19201900 this .efConstruction = efConstruction ;
@@ -1956,14 +1936,11 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
19561936 }
19571937
19581938 @ Override
1959- public boolean validateDimension (int dim , boolean throwOnError ) {
1960- boolean supportsDimension = type .supportsDimension (dim );
1961- if (throwOnError && supportsDimension == false ) {
1962- throw new IllegalArgumentException (
1963- type .name + " does not support dimensions fewer than " + BBQ_MIN_DIMS + "; provided=" + dim
1964- );
1939+ public void validateDimension (int dim ) {
1940+ if (type .supportsDimension (dim )) {
1941+ return ;
19651942 }
1966- return supportsDimension ;
1943+ throw new IllegalArgumentException ( type . name + " does not support dimensions fewer than " + BBQ_MIN_DIMS + "; provided=" + dim ) ;
19671944 }
19681945 }
19691946
@@ -2007,19 +1984,15 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
20071984 }
20081985
20091986 @ Override
2010- public boolean validateDimension (int dim , boolean throwOnError ) {
2011- boolean supportsDimension = type .supportsDimension (dim );
2012- if (throwOnError && supportsDimension == false ) {
2013- throw new IllegalArgumentException (
2014- type .name + " does not support dimensions fewer than " + BBQ_MIN_DIMS + "; provided=" + dim
2015- );
1987+ public void validateDimension (int dim ) {
1988+ if (type .supportsDimension (dim )) {
1989+ return ;
20161990 }
2017- return supportsDimension ;
1991+ throw new IllegalArgumentException ( type . name + " does not support dimensions fewer than " + BBQ_MIN_DIMS + "; provided=" + dim ) ;
20181992 }
2019-
20201993 }
20211994
2022- public record RescoreVector (float oversample ) implements ToXContentObject {
1995+ record RescoreVector (float oversample ) implements ToXContentObject {
20231996 static final String NAME = "rescore_vector" ;
20241997 static final String OVERSAMPLE = "oversample" ;
20251998
@@ -2338,10 +2311,6 @@ int getVectorDimensions() {
23382311 ElementType getElementType () {
23392312 return elementType ;
23402313 }
2341-
2342- public IndexOptions getIndexOptions () {
2343- return indexOptions ;
2344- }
23452314 }
23462315
23472316 private final IndexOptions indexOptions ;
0 commit comments