GEOSEARCH

Since 1.1.0Geospatial

Syntax

GEOSEARCH key <FROMMEMBER member | FROMLONLAT longitude latitude> <BYRADIUS radius <M | KM | FT | MI> | BYBOX width height <M | KM | FT | MI>> [ASC | DESC] [COUNT count [ANY]] [WITHCOORD] [WITHDIST] [WITHHASH]
  • Flags: readonly
  • ACL categories: @geo, @read, @slow
  • Arity: -7

Returns the members of the geospatial index at key within a circle or a box.

Options

OptionEffect
FROMMEMBER member, FROMLONLAT longitude latitudeThe centre: a member, or a position.
BYRADIUS radius unitWithin this distance of the centre.
BYBOX width height unitWithin a box of this size around the centre.
ASC, DESCNearest first, or furthest first.
COUNT count [ANY]Return up to count members; with ANY, the first found rather than the nearest.
WITHDISTGive each member's distance from the centre, in the unit asked.
WITHCOORDGive each member's longitude and latitude.
WITHHASHGive each member's geohash, as the integer score it is stored with.

Units are M, KM, FT and MI.

Reply

  • An array of members; with a WITH option, an array per member of the name and what was asked.

Examples

> GEOADD g 13.361389 38.115556 Palermo 15.087269 37.502669 Catania
(integer) 2
> GEOSEARCH g FROMLONLAT 15 37 BYRADIUS 200 KM ASC WITHDIST
1) 1) "Catania"
   2) "56.4413"
2) 1) "Palermo"
   2) "190.4424"