Skip to content

geo search: variable center bound to a WKT string from an indexed scan resolves to no center #1318

Open

Description

@bplatz

Summary

GeoSearchOperator::resolve_center (fluree-db-query/src/geo_search.rs, ~line 111) resolves a variable-bound center by matching:

match binding {
    Binding::Lit { val, .. } => match val {
        FlakeValue::GeoPoint(bits) => Some((bits.lat(), bits.lng())),
        FlakeValue::String(s) => fluree_db_core::geo::try_extract_point(s),
        _ => None,
    },
    _ => None,
}

On a fully-indexed ledger with late materialization active, a WKT string literal bound from a scan arrives as Binding::EncodedLit (string-dict backed), which falls into the _ => None arm — the center silently resolves to nothing and the geo search yields no results, instead of decoding the string.

Embedded geo:Point values are NOT affected: late_materialized_object_binding has no encoded representation for DecodeKind::GeoPoint, so those fall back to materialized Lit { GeoPoint } bindings and match the first arm.

Evidence

Code-level only (no runtime repro built yet — needs a dataset where the center variable is bound to a WKT string by a preceding indexed triple pattern). The sibling operator already handles this exact case: s2_search.rs::resolve_query_geom has an explicit Binding::EncodedLit arm that decodes via gv.decode_value_from_kind(..) before parsing the geometry.

Suggested fix

Mirror the s2_search.rs pattern: add an EncodedLit arm to resolve_center that decodes string-dict values through the graph view and feeds the result to try_extract_point. Verify with a repro first (variable WKT center from an indexed scan).

Activity

  1. aaj3f commented on Aug 25, 2026

    @aaj3f
    Contributor

    Sweep verification at 47e96b7b6, with a twist: the code-level diagnosis here is correct — geo_search.rs:120-127 is missing the EncodedLit arm that s2_search has — but GeoSearchCenter::Var is never constructed anywhere at current main. The only GeoSearch builder is the geof:distance rewrite, which requires a constant WKT and emits Const centers only. A variable-center query demonstrably takes the generic path and returns correct rows on an indexed ledger (CLI repro, 2/2 expected rows).

    So there's no live wrong-results path today; the bug arms itself the moment someone wires variable centers into the rewrite. Two cheap ways to handle that, and I'm fine with either: (a) add the EncodedLit arm now, mirroring s2_search, as defense-in-depth — it's S-effort; or (b) rescope this issue to "variable geo-search centers are unimplemented — when implementing, the resolve_center EncodedLit gap must be fixed with them" so the trap is documented where the future implementer will trip it.

  2. added
    P3
    area:query
    on Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3area:query

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions