weaviate/weaviate · error

element %d: expected geo element to be *models.GeoCoordinate

Error message

element %d: expected geo element to be *models.GeoCoordinates, but got %T

What it means

mergeGeoProps averages latitude/longitude of grouped GeoCoordinates during groupBy. Each element must be *models.GeoCoordinates; other types abort with the index and actual type. nil Latitude/Longitude pointers are skipped in averaging.

Source

Thrown at usecases/traverser/grouper/merge_group.go:247

		if asBool {
			countTrue++
		} else {
			countFalse++
		}
	}

	return countTrue >= countFalse, nil
}

func mergeGeoProps(in []interface{}) (*models.GeoCoordinates, error) {
	var sumLat float32
	var sumLon float32

	for i, elem := range in {
		asGeo, ok := elem.(*models.GeoCoordinates)
		if !ok {
			return nil, fmt.Errorf("element %d: expected geo element to be *models.GeoCoordinates, but got %T", i, elem)
		}

		if asGeo.Latitude != nil {
			sumLat += *asGeo.Latitude
		}
		if asGeo.Longitude != nil {
			sumLon += *asGeo.Longitude
		}
	}

	return &models.GeoCoordinates{
		Latitude:  ptFloat32(sumLat / float32(len(in))),
		Longitude: ptFloat32(sumLon / float32(len(in))),
	}, nil
}

func ptFloat32(in float32) *float32 {
	return &in

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Confirm the property dataType is geoCoordinates and objects store {latitude, longitude} objects
  2. Re-import or migrate objects written in a legacy geo format
  3. Do not groupBy on non-geo properties expecting geo merging
  4. Upgrade Weaviate if a deserialization fix for geo coordinates landed in a newer version
Defensive patterns

Strategy: type-guard

Validate before calling

// Validate geo shape before writing
function isGeo(v) {
  return v && typeof v === 'object' &&
    typeof v.latitude === 'number' && typeof v.longitude === 'number'
}

Type guard

function isGeoCoordinates(v) {
  return v !== null && typeof v === 'object' &&
    'latitude' in v && 'longitude' in v &&
    typeof v.latitude === 'number' && typeof v.longitude === 'number'
}

Prevention

When it happens

Trigger: A groupBy query over a geoCoordinates property where a grouped element is not *models.GeoCoordinates — e.g. the value decoded as a map[string]interface{} instead of the model struct.

Common situations: Grouping on a property that is not actually geoCoordinates in the schema, or older data written in a different geo format that does not deserialize into models.GeoCoordinates.

Related errors


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