refactor(search): drop the unreachable group key fallback for geo predicates

This commit is contained in:
Dominik Schmidt committed 2026-12-04 11:01:26 +01:00
1 parent 787e06147a
commit ca8bc37589
1 file changed
+4 -12
+4 -12
View File
@@ -335,7 +335,7 @@ func ParseQuery(query string) (*ast.Ast, error) {
return nil, err
}
if err := validateGeoKeys(a.Nodes, ""); err != nil {
if err := validateGeoKeys(a.Nodes); err != nil {
return nil, errtypes.BadRequest(err.Error())
}
@@ -344,18 +344,13 @@ func ParseQuery(query string) (*ast.Ast, error) {
// validateGeoKeys rejects a geo predicate on a field that is not a geopoint.
// The parser cannot tell, it does not know the index fields; checking here
// keeps it a bad request before any engine compiles the query. A bare
// predicate inside a group inherits the group key.
func validateGeoKeys(nodes []ast.Node, groupKey string) error {
// keeps it a bad request before any engine compiles the query.
func validateGeoKeys(nodes []ast.Node) error {
for _, n := range nodes {
var key string
switch node := n.(type) {
case *ast.GroupNode:
k := groupKey
if node.Key != "" {
k = node.Key
}
if err := validateGeoKeys(node.Nodes, k); err != nil {
if err := validateGeoKeys(node.Nodes); err != nil {
return err
}
continue
@@ -368,9 +363,6 @@ func validateGeoKeys(nodes []ast.Node, groupKey string) error {
default:
continue
}
if key == "" {
key = groupKey
}
if !FieldIsGeopoint(ResolveField(key)) {
return &kql.GeoFieldError{Key: key}
}