Geo search

Put a geopoint field on a model and you can ask which records are nearest a point, ordered by distance. The queries work with points and a radius.

Geopoint fields

A geopoint field holds a latitude and a longitude, and the console edits it with a map picker. A model can carry several, each a separately named point. The point is indexed in the same transaction as the record write, so a record can be found by location as soon as it is saved.

Nearest to a point or to a record

searchByLocation takes a latitude and a longitude and returns the records near that point. findNearbyRecords takes a record and returns the ones nearest to it, leaving that record out. Both can be narrowed to one model. Results come nearest first, and each carries its distance in metres with the record's id, model key, natural key and content.

Radius and paging

The radius is optional. With one, results stop at that distance. Without one, the query returns the nearest records wherever they are. Results are cursor-paginated, forward only, 50 to a page by default. A latitude outside -90 to 90 or a longitude outside -180 to 180 is refused.

Access rules and existing records

A query runs under the caller's row-level access rules. Adding a geopoint field to a model that already has records does not index the existing rows. foir geometry has commands that list the records missing from the index and backfill them.

Points and radius only

Areas, lines and bounding boxes are not supported.

Read the detail

The CLI reference documents the geometry commands: searching near a point, finding the records nearest another, and backfilling records that are not yet indexed.