Spatial operators

This page describes the available operators to assist with performing spatial calculations. For more information on this type of data, see the geohashes documentation and the spatial functions which have been added to help with filtering and generating data.

within#

within(geohash, ...) - evaluates if a comma-separated list of geohashes are equal to are within another geohash.

info
  • The within operator can only be used in LATEST BY queries and all symbol columns within the query must be indexed.

  • Only geohash literals (#ezzn5kxb) are supported as opposed to geohashes passed as strings ('ezzn5kxb').

Arguments:

  • geohash is a geohash type in text or binary form

Return value:

  • evaluates to true if geohash values are a prefix or complete match based on the geohashes passed as arguments

Examples:

Given a table with the following contents:

tsdevice_idg1cg8c
2021-09-02T14:20:07.721444Zdevice_2eezzn5kxb
2021-09-02T14:20:08.241489Zdevice_1uu33w4r2w
2021-09-02T14:20:08.241489Zdevice_3uu33d8b1b

The within operator can be used to filter results by geohash:

SELECT * FROM pos LATEST BY uuid
WHERE g8c within(#ezz, #u33d8);

This yields the following results:

tsdevice_idg1cg8c
2021-09-02T14:20:07.721444Zdevice_2eezzn5kxb
2021-09-02T14:20:08.241489Zdevice_3uu33d8b1b

Additionally, prefix-like matching can be performed to evaluate if geohashes exist within a larger grid:

SELECT * FROM pos LATEST BY uuid
WHERE g8c within(#u33);
tsdevice_idg1cg8c
2021-09-02T14:20:08.241489Zdevice_1uu33w4r2w
2021-09-02T14:20:08.241489Zdevice_3uu33d8b1b