elastic/elasticsearch · error · IllegalArgumentException
Field [{}] must have FLOAT32 encoding, got: {}
Error message
Field [{}] must have FLOAT32 encoding, got: {} What it means
Thrown by ES92GpuHnswVectorsWriter.addField() when the field's VectorEncoding is not FLOAT32. The GPU HNSW writer only supports FLOAT32 vectors during the indexing (flush) path. During merging, quantized BYTE data is handled separately via mergeByteVectorField, but the initial indexing path requires floats.
Source
Thrown at libs/gpu-codec/src/main/java/org/elasticsearch/gpu/codec/ES92GpuHnswVectorsWriter.java:150
CodecUtil.writeIndexHeader(
vectorIndex,
LUCENE99_HNSW_VECTOR_INDEX_CODEC_NAME,
LUCENE99_VERSION_CURRENT,
state.segmentInfo.getId(),
state.segmentSuffix
);
success = true;
} finally {
if (success == false) {
org.elasticsearch.core.IOUtils.closeWhileHandlingException(this);
}
}
}
@Override
public KnnFieldVectorsWriter<?> addField(FieldInfo fieldInfo) throws IOException {
if (fieldInfo.getVectorEncoding().equals(VectorEncoding.FLOAT32) == false) {
throw new IllegalArgumentException(
"Field [" + fieldInfo.name + "] must have FLOAT32 encoding, got: " + fieldInfo.getVectorEncoding()
);
}
@SuppressWarnings("unchecked")
FlatFieldVectorsWriter<float[]> flatFieldWriter = (FlatFieldVectorsWriter<float[]>) flatVectorWriter.addField(fieldInfo);
FieldWriter newField = new FieldWriter(flatFieldWriter, fieldInfo);
fields.add(newField);
return newField;
}
/**
* Flushes vector data and associated data to disk.
* <p>
* This method and the private helpers it calls only need to support FLOAT32.
* For FlatFieldVectorWriter we only need to support float[] during flush: during indexing users provide floats[], and pass floats to
* FlatFieldVectorWriter, even when we have a BYTE dataType (i.e. an "int8_hnsw" type).
* During merging, we use quantized data, so we need to support byte[] too (see {@link ES92GpuHnswVectorsWriter#mergeOneField}),
* but not here.View on GitHub (pinned to db6a809a66)
Solutions
- Ensure dense_vector fields using the GPU HNSW format have element_type: float (the default).
- If using scalar quantization (int8_hnsw), ensure the quantization happens at merge time, not during initial indexing — the flush path only accepts FLOAT32.
- Verify the index mapping's dense_vector field does not specify element_type: byte for the indexing phase.
Example fix
// before — mapping with byte encoding on a GPU HNSW index
// PUT /my-index/_mapping
// { "properties": { "my_vector": { "type": "dense_vector", "dims": 128, "element_type": "byte" } } }
// after — use float encoding for GPU HNSW indexing
// PUT /my-index/_mapping
// { "properties": { "my_vector": { "type": "dense_vector", "dims": 128, "element_type": "float" } } } Defensive patterns
Strategy: type-guard
Validate before calling
if (fieldInfo.getVectorEncoding() != VectorEncoding.FLOAT32) {
throw new IllegalStateException("GPU HNSW writer requires FLOAT32 encoding for field " + fieldInfo.name);
}
writer.addField(fieldInfo); Type guard
static boolean isGpuCompatible(FieldInfo fieldInfo) {
return fieldInfo.getVectorEncoding() == VectorEncoding.FLOAT32;
} Prevention
- Ensure dense_vector mappings use element_type: float (the default) for GPU HNSW indices.
- Verify field encoding before calling addField in custom codec integration code.
- Remember that scalar quantization (int8_hnsw) works at merge time with FLOAT32 input — do not set element_type to byte.
When it happens
Trigger: addField(fieldInfo) is called during segment flush for a field whose VectorEncoding is BYTE or BINARY. This means a binary vector field or byte-quantized vector field was indexed into a GPU HNSW format. In normal Elasticsearch operation, the mapping system should prevent this, but direct codec usage or mapping misconfiguration can trigger it.
Common situations: Indexing a dense_vector field with element_type: byte into an index configured for GPU HNSW format; using the GPU codec format on a field that was mapped with binary encoding; codec format mismatch where a non-float field reaches the GPU writer.
Related errors
- segment of size [{}] too small for expected {} float vectors
- negative number of vectors: {}
- negative vector dims: {}
- maxConn must be positive and less than or equal to 512; maxC
- beamWidth must be positive and less than or equal to 3200; b
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/e59a2f6df7d08c13.
Report an issue: GitHub.