GEOHASH(3valkey)
β¨ GEOHASH π
okay so bestie, this is a page from the Valkey Command Manual and it's about a command called geohash. It's giving "where my little map pins at" energy. Let's go π
πΈ NAME
geohash β returns members from a geospatial index as geohash strings. That's it, that's the whole job π«Ά
π SYNOPSIS
GEOHASH key member [member...]
π DESCRIPTION
So you've got a sorted set that's secretly a geospatial index (you put stuff in there with GEOADD, which lives over in valkey-geoadd(7)), and this command hands you back valid Geohash strings that represent where one or more of those elements are actually sitting. β¨
Now, normally Valkey stores positions using its own little variation on the Geohash technique, where positions get encoded as 52 bit integers. That encoding is also different from the standard one, because the initial min and max coordinates used during encoding and decoding are different. No cap. π
But this command? This command returns a standard Geohash, as a string, exactly as described in the Wikipedia article and compatible with the geohash.org web site. Main character behaviour only. π
π¦ Geohash string properties
The command returns 11 characters Geohash strings, so literally no precision is lost compared to the Valkey internal 52 bit representation. The returned Geohashes have these properties:
- They can be shortened by removing characters from the right. You'll lose precision, but it will still point to the same area. Lowkey still valid π
- It is possible to use them in geohash.org URLs such as
http://geohash.org/<geohash-string>. That right there is an example of such a URL. - Strings with a similar prefix are nearby β but the contrary is not true, so it's possible that strings with different prefixes are nearby too. It's giving "same neighbourhood, different vibes" ποΈ
π REPLY
valkey-protocol(7) Array reply: an array where each element is the Geohash corresponding to each member name passed as an argument to the command. One geohash per member, in order, periodt β¨
π₯ COMPLEXITY
O(1) for each member requested. Snappy. Iconic. π
π ACL CATEGORIES
@geo@read@slow
π§ HISTORY
- Available since:
3.2.0β a legend from the jump π
β EXAMPLES
127.0.0.1:6379> GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"
(integer) 2
127.0.0.1:6379> GEOHASH Sicily Palermo Catania
1) "sqc8b49rny0"
2) "sqdtr74hyu0"
look at those little strings go π so cute, so precise
π SEE ALSO
geoadd(3valkey)geodist(3valkey)geopos(3valkey)georadius(3valkey)georadiusbymember(3valkey)georadiusbymember_ro(3valkey)georadius_ro(3valkey)geosearch(3valkey)geosearchstore(3valkey)
and that's the whole page bestie, no notes π go forth and geohash responsibly π¦
okay bye ily β this was Valkey 9.0.0, dated 2025-10-21, and yes GEOHASH(3valkey) ate, no crumbs left ππ
β¨
π¦ where this page comes from
- fedora 44: valkey-doc 9.0.3-2.fc44 Β· CC-BY-SA-4.0
- fedora 44: valkey-doc 9.0.6-1.fc44 Β· CC-BY-SA-4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms