weaviate/weaviate · error

expected float64, got %T

Error message

expected float64, got %T

What it means

For DataTypeNumber, analyzeValue requires the value to be float64 — the type encoding/json produces for all JSON numbers. Numbers sent as strings, integers wrapped in other Go types from programmatic map construction, or bools trigger this error. Weaviate does not silently coerce, because indexing a wrong-typed value corrupts filterable range statistics.

Source

Thrown at adapters/repos/db/inverted/objects.go:398

	switch dt {
	case schema.DataTypeText:
		asString, ok := value.(string)
		if !ok {
			return nil, fmt.Errorf("expected string, got %T", value)
		}
		return a.Text(tokenization, asString, propName, textAnalyzer), nil

	case schema.DataTypeInt:
		asInt, err := toInt64(value)
		if err != nil {
			return nil, err
		}
		return a.Int(asInt)

	case schema.DataTypeNumber:
		asFloat, ok := value.(float64)
		if !ok {
			return nil, fmt.Errorf("expected float64, got %T", value)
		}
		return a.Float(asFloat)

	case schema.DataTypeBoolean:
		asBool, ok := value.(bool)
		if !ok {
			return nil, fmt.Errorf("expected bool, got %T", value)
		}
		return a.Bool(asBool)

	case schema.DataTypeDate:
		asInt, err := dateToInt64(value)
		if err != nil {
			return nil, err
		}
		return a.Int(asInt)

	case schema.DataTypeUUID:

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Send an unquoted JSON number: {"price":19.99}.
  2. In Go, store numbers as float64 in the input map (or route through JSON marshal/unmarshal).
  3. If numbers must remain strings, keep dataType as text and use text filtering instead.
  4. Re-import objects after fixing the client serializer.

Example fix

// before
{"price": "19.99"}
// after
{"price": 19.99}
Defensive patterns

Strategy: type-guard

Validate before calling

if is_number_prop(props, name) and not isinstance(val, (int, float)) or isinstance(val, bool):
    raise ValueError(f"{name} is number and must be a JSON number, not a string")

Type guard

func isFloat64(v any) bool {
    _, ok := v.(float64)
    return ok
}

Try / catch

err := creator.WithProperties(props).Do(ctx)
if err != nil && strings.Contains(err.Error(), "expected float64, got") {
    log.Fatalf("number property must be an unquoted JSON number: %v", err)
}

Prevention

When it happens

Trigger: {"price":"19.99"} (string) for a number property; Go callers inserting a value as int/float32/`json.Number` directly into the map instead of letting JSON decoding produce float64; null or object values on a number property.

Common situations: Go code building maps by hand with typed values (int, float32); APIs/ETL tools sending numbers as strings; config/UI forms submitting quoted numbers; schema migrated from text to number with old string data.

Related errors


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/af8677738425fb55. Report an issue: GitHub.