Skip to main content

Usage

Parameters

key
string
required
The key containing the geospatial index.
members
string | string[]
required
One or more members to get the Geohash for. Can be passed as individual arguments or as an array.

Response

result
(string | null)[]
An array of Geohash strings in the same order as the requested members.Returns null for members that do not exist.

Examples

Get Geohash for single member

Get Geohash for multiple members

Handle missing members

Using array syntax

What is a Geohash?

A Geohash is a string encoding of a geographic location into a short string of letters and digits. It’s a hierarchical spatial data structure that subdivides space into buckets of grid shape.

Properties

  • Fixed length: The Geohash returned by Redis is always 11 characters
  • Proximity: Locations close to each other tend to have similar Geohash prefixes
  • Precision: Each additional character increases precision:
    • 1 character: ±2,500 km
    • 5 characters: ±2.4 km
    • 11 characters: ±0.6 mm

Use Cases

Important Notes

Encoding Details

  • Geohash uses a Base32 encoding system
  • Characters used: 0-9 and b-z (excluding a, i, l, o)
  • The hash represents the position, not the member name
  • Two members at the exact same coordinates will have the same Geohash

Limitations

  • Geohashes are not perfectly suited for proximity searches near the poles
  • Locations on opposite sides of the equator or prime meridian may have very different hashes despite being close