Back to Redis

GEORADIUSBYMEMBER

content/commands/georadiusbymember.md

latest2.9 KB
Original Source

{{< note >}} This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. {{< /note >}}

This command is exactly like [GEORADIUS]({{< relref "/commands/georadius" >}}) with the sole difference that instead of taking, as the center of the area to query, a longitude and latitude value, it takes the name of a member already existing inside the geospatial index represented by the sorted set.

The position of the specified member is used as the center of the query.

Please check the example below and the [GEORADIUS]({{< relref "/commands/georadius" >}}) documentation for more information about the command and its options.

Note that [GEORADIUSBYMEMBER_RO]({{< relref "/commands/georadiusbymember_ro" >}}) is also available since Redis 3.2.10 and Redis 4.0.0 in order to provide a read-only command that can be used in replicas. See the [GEORADIUS]({{< relref "/commands/georadius" >}}) page for more information.

Examples

{{% redis-cli %}} GEOADD Sicily 13.583333 37.316667 "Agrigento" GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania" GEORADIUSBYMEMBER Sicily Agrigento 100 km {{% /redis-cli %}}

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | Deprecated as of Redis v6.2.0. |

Return information

{{< multitabs id="georadiusbymember-return-info" tab1="RESP2" tab2="RESP3" >}}

One of the following:

  • If no WITH* option is specified, an Array reply of matched member names
  • If WITHCOORD, WITHDIST, or WITHHASH options are specified, the command returns an Array reply of arrays, where each sub-array represents a single item:
    • The distance from the center as a floating point number, in the same unit specified in the radius.
    • The Geohash integer.
    • The coordinates as a two items x,y array (longitude,latitude).

-tab-sep-

One of the following:

  • If no WITH* option is specified, an Array reply of matched member names
  • If WITHCOORD, WITHDIST, or WITHHASH options are specified, the command returns an Array reply of arrays, where each sub-array represents a single item:
    • The distance from the center as a floating point number, in the same unit specified in the radius.
    • The Geohash integer.
    • The coordinates as a two items x,y array (longitude,latitude).

{{< /multitabs >}}