Skip to content

Commit 252a0e5

Browse files
committed
Use new formats
1 parent fde54fd commit 252a0e5

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.elasticsearch.index.codec.vectors.ES815HnswBitVectorsFormat;
5656
import org.elasticsearch.index.codec.vectors.diskbbq.ES920DiskBBQVectorsFormat;
5757
import org.elasticsearch.index.codec.vectors.es818.ES818BinaryQuantizedVectorsFormat;
58+
import org.elasticsearch.index.codec.vectors.es93.ES93BinaryQuantizedVectorsFormat;
5859
import org.elasticsearch.index.codec.vectors.es93.ES93HnswBinaryQuantizedVectorsFormat;
5960
import org.elasticsearch.index.fielddata.FieldDataContext;
6061
import org.elasticsearch.index.fielddata.IndexFieldData;
@@ -2075,6 +2076,7 @@ public BBQHnswIndexOptions(int m, int efConstruction, boolean onDiskRescore, Res
20752076
KnnVectorsFormat getVectorsFormat(ElementType elementType) {
20762077
return switch (elementType) {
20772078
case FLOAT -> new ES93HnswBinaryQuantizedVectorsFormat(m, efConstruction, onDiskRescore, false);
2079+
case BFLOAT16 -> new ES93HnswBinaryQuantizedVectorsFormat(m, efConstruction, onDiskRescore, true);
20782080
default -> throw new AssertionError();
20792081
};
20802082
}
@@ -2142,7 +2144,8 @@ static class BBQFlatIndexOptions extends QuantizedIndexOptions {
21422144
@Override
21432145
KnnVectorsFormat getVectorsFormat(ElementType elementType) {
21442146
return switch (elementType) {
2145-
case FLOAT -> new ES818BinaryQuantizedVectorsFormat();
2147+
case FLOAT -> new ES93BinaryQuantizedVectorsFormat(false, false);
2148+
case BFLOAT16 -> new ES93BinaryQuantizedVectorsFormat(false, true);
21462149
default -> throw new AssertionError();
21472150
};
21482151
}
@@ -2207,13 +2210,21 @@ static class BBQIVFIndexOptions extends QuantizedIndexOptions {
22072210

22082211
@Override
22092212
KnnVectorsFormat getVectorsFormat(ElementType elementType) {
2210-
assert elementType == ElementType.FLOAT;
2211-
return new ES920DiskBBQVectorsFormat(
2212-
clusterSize,
2213-
ES920DiskBBQVectorsFormat.DEFAULT_CENTROIDS_PER_PARENT_CLUSTER,
2214-
onDiskRescore,
2215-
false
2216-
);
2213+
return switch (elementType) {
2214+
case FLOAT -> new ES920DiskBBQVectorsFormat(
2215+
clusterSize,
2216+
ES920DiskBBQVectorsFormat.DEFAULT_CENTROIDS_PER_PARENT_CLUSTER,
2217+
onDiskRescore,
2218+
false
2219+
);
2220+
case BFLOAT16 -> new ES920DiskBBQVectorsFormat(
2221+
clusterSize,
2222+
ES920DiskBBQVectorsFormat.DEFAULT_CENTROIDS_PER_PARENT_CLUSTER,
2223+
onDiskRescore,
2224+
true
2225+
);
2226+
default -> throw new AssertionError();
2227+
};
22172228
}
22182229

22192230
@Override

0 commit comments

Comments
 (0)