go-redis/redis · error

FT.CREATE: SCHEMA FieldType GEOSHAPE is required for GeoShap

Error message

FT.CREATE: SCHEMA FieldType GEOSHAPE is required for GeoShapeFieldType

What it means

Returned by FTCreate when GeoShapeFieldType is set (non-empty) but FieldSchema.FieldType is not SearchFieldTypeGeoShape. A GEOSHAPE field optionally takes a sub-type (FLAT/GEOJSON); setting the sub-type on a non-GEOSHAPE field is contradictory and rejected at search_commands.go:1581.

Source

Thrown at search_commands.go:1583

					vamanaArgs = append(vamanaArgs, "SEARCH_WINDOW_SIZE", schema.VectorArgs.VamanaOptions.SearchWindowSize)
				}
				if schema.VectorArgs.VamanaOptions.Epsilon > 0 {
					vamanaArgs = append(vamanaArgs, "EPSILON", schema.VectorArgs.VamanaOptions.Epsilon)
				}
				if schema.VectorArgs.VamanaOptions.TrainingThreshold > 0 {
					vamanaArgs = append(vamanaArgs, "TRAINING_THRESHOLD", schema.VectorArgs.VamanaOptions.TrainingThreshold)
				}
				if schema.VectorArgs.VamanaOptions.ReduceDim > 0 {
					vamanaArgs = append(vamanaArgs, "REDUCE", schema.VectorArgs.VamanaOptions.ReduceDim)
				}
				args = append(args, len(vamanaArgs))
				args = append(args, vamanaArgs...)
			}
		}
		if schema.GeoShapeFieldType != "" {
			if schema.FieldType != SearchFieldTypeGeoShape {
				cmd := NewStatusCmd(ctx, args...)
				cmd.SetErr(fmt.Errorf("FT.CREATE: SCHEMA FieldType GEOSHAPE is required for GeoShapeFieldType"))
				return cmd
			}
			args = append(args, schema.GeoShapeFieldType)
		}
		if schema.NoStem {
			args = append(args, "NOSTEM")
		}
		if schema.Sortable {
			args = append(args, "SORTABLE")
		}
		if schema.UNF {
			args = append(args, "UNF")
		}
		if schema.NoIndex {
			args = append(args, "NOINDEX")
		}
		if schema.PhoneticMatcher != "" {
			args = append(args, "PHONETIC", schema.PhoneticMatcher)

View on GitHub (pinned to 36d97525cd)

Solutions

  1. Set FieldType: redis.SearchFieldTypeGeoShape whenever GeoShapeFieldType is non-empty.
  2. Constrain GeoShapeFieldType assignment to a geo-field constructor.
  3. Validate that GeoShapeFieldType implies SearchFieldTypeGeoShape before calling FTCreate.

Example fix

// before
&redis.FieldSchema{FieldName: "geom", FieldType: redis.SearchFieldTypeTag, GeoShapeFieldType: "FLAT"}

// after
&redis.FieldSchema{FieldName: "geom", FieldType: redis.SearchFieldTypeGeoShape, GeoShapeFieldType: "FLAT"}
Defensive patterns

Strategy: validation

Validate before calling

if f.GeoShapeFieldType != "" && f.FieldType != redis.SearchFieldTypeGeoShape {
    return fmt.Errorf("field %q: GeoShapeFieldType requires FieldType=GEOSHAPE", f.FieldName)
}

Type guard

func geoShapeConsistent(f *redis.FieldSchema) bool {
    if f.GeoShapeFieldType == "" {
        return true
    }
    return f.FieldType == redis.SearchFieldTypeGeoShape
}

Prevention

When it happens

Trigger: Setting schema.GeoShapeFieldType (e.g. "FLAT") on a FieldSchema whose FieldType is TEXT/NUMERIC/etc., or forgetting to set FieldType: SearchFieldTypeGeoShape when adding the geo sub-type.

Common situations: Reusing a generic FieldSchema builder and conditionally adding GeoShapeFieldType without also switching FieldType, or copy-paste from a geo example into a text field definition.

Related errors


AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06). Data as JSON: /data/errors/e6273d1742449193.json. Report an issue: GitHub.