spring-projects/spring-ai · error · IllegalArgumentException
Field {0} has unsupported type {1}
Error message
Field {0} has unsupported type {1} What it means
RedisVectorStore.schemaField() maps each MetadataField to a RediSearch schema field, supporting only NUMERIC, TAG and TEXT field types. A MetadataField with any other fieldType hits the default branch and throws this IllegalArgumentException. It prevents building an FT.CREATE schema with an unmappable field type.
Source
Thrown at vector-stores/spring-ai-redis-store/src/main/java/org/springframework/ai/vectorstore/redis/RedisVectorStore.java:711
.attributes(vectorAttrs)
.as(this.embeddingFieldName)
.build());
if (!CollectionUtils.isEmpty(this.metadataFields)) {
for (MetadataField field : this.metadataFields) {
fields.add(schemaField(field));
}
}
return fields;
}
private SchemaField schemaField(MetadataField field) {
String fieldName = jsonPath(field.name);
return switch (field.fieldType) {
case NUMERIC -> NumericField.of(fieldName).as(field.name);
case TAG -> TagField.of(fieldName).as(field.name);
case TEXT -> TextField.of(fieldName).as(field.name);
default -> throw new IllegalArgumentException(
MessageFormat.format("Field {0} has unsupported type {1}", field.name, field.fieldType));
};
}
private VectorAlgorithm vectorAlgorithm() {
if (this.vectorAlgorithm == Algorithm.HNSW) {
return VectorAlgorithm.HNSW;
}
return VectorAlgorithm.FLAT;
}
private String jsonPath(String field) {
return JSON_PATH_PREFIX + field;
}
@Override
public VectorStoreObservationContext.Builder createObservationContextBuilder(String operationName) {
VectorStoreSimilarityMetric similarityMetric = switch (this.distanceMetric) {View on GitHub (pinned to 98a7beda4f)
Solutions
- Use only FieldType.NUMERIC, FieldType.TAG or FieldType.TEXT when defining metadata fields for the Redis store
- Coerce unsupported types: map BOOLEAN to TAG, dates to NUMERIC (epoch) before building the store
- Check for null/default FieldType values coming from shared configuration or other store adapters
Example fix
// before
new MetadataField("active", FieldType.BOOLEAN)
// after
new MetadataField("active", FieldType.TAG) Defensive patterns
Strategy: validation
Validate before calling
java.util.Set<FieldType> allowed = Set.of(FieldType.NUMERIC, FieldType.TAG, FieldType.TEXT);
fields.forEach(f -> { if (!allowed.contains(f.fieldType)) throw new IllegalArgumentException("Unsupported field type for Redis store: " + f.fieldType); }); Type guard
static boolean isSupportedFieldType(MetadataField f) { return f.fieldType == FieldType.NUMERIC || f.fieldType == FieldType.TAG || f.fieldType == FieldType.TEXT; } Try / catch
try { RedisVectorStore.builder().metadataFields(fields).build(); } catch (IllegalArgumentException e) { if (e.getMessage().contains("unsupported type")) { /* remap field type */ } } Prevention
- Define Redis store metadata fields only with NUMERIC/TAG/TEXT
- Map BOOLEAN/DATE types to TAG/NUMERIC before configuration
- Review field definitions when migrating from other vector stores
When it happens
Trigger: Constructing the RedisVectorStore with MetadataField instances (via builder metadataFields or an observed metadata mode) whose fieldType is not one of NUMERIC/TAG/TEXT, e.g. a null or custom FieldType value.
Common situations: Copy-pasting MetadataField definitions from another vector store that supports more types (e.g. BOOLEAN or CHUNK); refactor renamed/extended FieldType enum; building fields programmatically with a wrong enum constant.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Failed to create index:
- Not allowed filter identifier name:
- Field type {0} not supported
- Expression type {0} not supported for numeric fields
- Numeric value must be a Number
AI-assisted analysis of spring-projects/spring-ai@98a7beda4f (2026-09-11).
Data as JSON: /api/errors/ce22fa5b2936c432.
Report an issue: GitHub.