Skip to content

Commit 70db95c

Browse files
adding default value to oversample for bbq
1 parent 54e2ba2 commit 70db95c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

server/src/main/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldMapper.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public static boolean isNotUnitVector(float magnitude) {
131131
// vector
132132
public static final int MAGNITUDE_BYTES = 4;
133133
public static final int OVERSAMPLE_LIMIT = 10_000; // Max oversample allowed
134+
private static final float DEFAULT_OVERSAMPLE = 3.0F; // Default oversample value
134135

135136
private static DenseVectorFieldMapper toType(FieldMapper in) {
136137
return (DenseVectorFieldMapper) in;
@@ -1463,7 +1464,7 @@ public IndexOptions parseIndexOptions(String fieldName, Map<String, ?> indexOpti
14631464
if (indexVersion.onOrAfter(ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS)) {
14641465
rescoreVector = RescoreVector.fromIndexOptions(indexOptionsMap, indexVersion);
14651466
if (rescoreVector == null) {
1466-
rescoreVector = new RescoreVector(3.0f);
1467+
rescoreVector = new RescoreVector(DEFAULT_OVERSAMPLE);
14671468
}
14681469
}
14691470
MappingParser.checkNoRemainingFields(fieldName, indexOptionsMap);
@@ -1486,6 +1487,9 @@ public IndexOptions parseIndexOptions(String fieldName, Map<String, ?> indexOpti
14861487
RescoreVector rescoreVector = null;
14871488
if (indexVersion.onOrAfter(ADD_RESCORE_PARAMS_TO_QUANTIZED_VECTORS)) {
14881489
rescoreVector = RescoreVector.fromIndexOptions(indexOptionsMap, indexVersion);
1490+
if (rescoreVector == null) {
1491+
rescoreVector = new RescoreVector(DEFAULT_OVERSAMPLE);
1492+
}
14891493
}
14901494
MappingParser.checkNoRemainingFields(fieldName, indexOptionsMap);
14911495
return new BBQFlatIndexOptions(rescoreVector);
@@ -2314,6 +2318,10 @@ int getVectorDimensions() {
23142318
ElementType getElementType() {
23152319
return elementType;
23162320
}
2321+
2322+
IndexOptions getIndexOptions() {
2323+
return indexOptions;
2324+
}
23172325
}
23182326

23192327
private final IndexOptions indexOptions;

0 commit comments

Comments
 (0)