|
54 | 54 | import org.elasticsearch.index.codec.vectors.ES815BitFlatVectorFormat; |
55 | 55 | import org.elasticsearch.index.codec.vectors.ES815HnswBitVectorsFormat; |
56 | 56 | import org.elasticsearch.index.codec.vectors.diskbbq.ES920DiskBBQVectorsFormat; |
| 57 | +import org.elasticsearch.index.codec.vectors.es818.ES818BinaryQuantizedVectorsFormat; |
| 58 | +import org.elasticsearch.index.codec.vectors.es818.ES818HnswBinaryQuantizedVectorsFormat; |
57 | 59 | import org.elasticsearch.index.codec.vectors.es93.ES93BinaryQuantizedVectorsFormat; |
| 60 | +import org.elasticsearch.index.codec.vectors.es93.ES93GenericFlatVectorsFormat; |
58 | 61 | import org.elasticsearch.index.codec.vectors.es93.ES93HnswBinaryQuantizedVectorsFormat; |
59 | 62 | import org.elasticsearch.index.codec.vectors.es93.ES93HnswVectorsFormat; |
60 | 63 | import org.elasticsearch.index.fielddata.FieldDataContext; |
@@ -238,7 +241,8 @@ public static class Builder extends FieldMapper.Builder { |
238 | 241 |
|
239 | 242 | private final Parameter<ElementType> elementType = new Parameter<>("element_type", false, () -> ElementType.FLOAT, (n, c, o) -> { |
240 | 243 | ElementType elementType = namesToElementType.get((String) o); |
241 | | - if (elementType == null) { |
| 244 | + if (elementType == null |
| 245 | + || (elementType == ElementType.BFLOAT16 && ES93GenericFlatVectorsFormat.ES93_VECTOR_FORMATS.isEnabled() == false)) { |
242 | 246 | throw new MapperParsingException("invalid element_type [" + o + "]; available types are " + namesToElementType.keySet()); |
243 | 247 | } |
244 | 248 | return elementType; |
@@ -2145,7 +2149,14 @@ public static class HnswIndexOptions extends DenseVectorIndexOptions { |
2145 | 2149 |
|
2146 | 2150 | @Override |
2147 | 2151 | public KnnVectorsFormat getVectorsFormat(ElementType elementType) { |
2148 | | - return new ES93HnswVectorsFormat(m, efConstruction, elementType); |
| 2152 | + if (ES93GenericFlatVectorsFormat.ES93_VECTOR_FORMATS.isEnabled()) { |
| 2153 | + return new ES93HnswVectorsFormat(m, efConstruction, elementType); |
| 2154 | + } else { |
| 2155 | + if (elementType == ElementType.BIT) { |
| 2156 | + return new ES815HnswBitVectorsFormat(m, efConstruction); |
| 2157 | + } |
| 2158 | + return new Lucene99HnswVectorsFormat(m, efConstruction, 1, null); |
| 2159 | + } |
2149 | 2160 | } |
2150 | 2161 |
|
2151 | 2162 | @Override |
@@ -2220,7 +2231,9 @@ public BBQHnswIndexOptions(int m, int efConstruction, boolean onDiskRescore, Res |
2220 | 2231 | @Override |
2221 | 2232 | KnnVectorsFormat getVectorsFormat(ElementType elementType) { |
2222 | 2233 | assert elementType == ElementType.FLOAT || elementType == ElementType.BFLOAT16; |
2223 | | - return new ES93HnswBinaryQuantizedVectorsFormat(m, efConstruction, elementType, onDiskRescore); |
| 2234 | + return ES93GenericFlatVectorsFormat.ES93_VECTOR_FORMATS.isEnabled() |
| 2235 | + ? new ES93HnswBinaryQuantizedVectorsFormat(m, efConstruction, elementType, onDiskRescore) |
| 2236 | + : new ES818HnswBinaryQuantizedVectorsFormat(m, efConstruction); |
2224 | 2237 | } |
2225 | 2238 |
|
2226 | 2239 | @Override |
@@ -2286,7 +2299,9 @@ static class BBQFlatIndexOptions extends QuantizedIndexOptions { |
2286 | 2299 | @Override |
2287 | 2300 | KnnVectorsFormat getVectorsFormat(ElementType elementType) { |
2288 | 2301 | assert elementType == ElementType.FLOAT || elementType == ElementType.BFLOAT16; |
2289 | | - return new ES93BinaryQuantizedVectorsFormat(elementType, false); |
| 2302 | + return ES93GenericFlatVectorsFormat.ES93_VECTOR_FORMATS.isEnabled() |
| 2303 | + ? new ES93BinaryQuantizedVectorsFormat(elementType, false) |
| 2304 | + : new ES818BinaryQuantizedVectorsFormat(); |
2290 | 2305 | } |
2291 | 2306 |
|
2292 | 2307 | @Override |
|
0 commit comments