Use GEOSEARCHSTORE to run the same query as GEOSEARCH and store the matching members in another key instead of returning them.
The destination is a sorted set holding the matches. By default their scores are the raw geohash values, so the destination is itself a valid geospatial index that can be queried further; with STOREDIST the score is the distance from the center in the unit of the query, which turns the result into a proximity-ordered list you can page through with ZRANGE.
The destination is overwritten on every call, and it is deleted when the query matches nothing. The reply is the number of members stored. This is the usual way to materialize a "nearby" result once and then reuse it for pagination or further set operations.
Syntax#
Arguments#
| Argument | Required | Repeatable | Description |
|---|---|---|---|
<destination> | Yes | No | Redis key used as destination. |
<source> | Yes | No | Redis key used as source. |
(FROMMEMBER <member> | FROMLONLAT <longitude> <latitude>) | Yes | No | Where to center the search: FROMMEMBER uses the stored position of an existing member, FROMLONLAT uses the given coordinates. |
(BYRADIUS <radius> (m | km | ft | mi) | BYBOX <width> <height> (m | km | ft | mi)) | Yes | No | The area to search: BYRADIUS a circle of the given radius, BYBOX an axis-aligned box of the given width and height centered on the search point. The unit is m (meters), km (kilometers), ft (feet), or mi (miles). |
(ASC | DESC) | No | No | Sort the matches by distance from the center: ASC (nearest first) or DESC (farthest first). Unsorted when omitted. |
COUNT <count> [ANY] | No | No | Return at most <count> matches. ANY returns as soon as enough matches are found, instead of sorting every match first. |
STOREDIST | No | No | Store each match's distance from the center instead of its geohash score. |
Response#
The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.
| Protocol | Reply |
|---|---|
| RESP2 | Integer |
| RESP3 | Integer |
Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.
Examples#
TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.