geosearch
GEOSEARCH
Apply for Redis Developer Course
|
Redis Regular Inspection / Technical Support
|
Redis Enterprise Server
|
|---|
GEOSEARCH query
Search nearby cities from a given city or coordinates.
This command can replace GEORADIUSBYMEMBER and GEORADIUS.
Example: load test data
| Command> | GEOADD map 126.97796919999996 37.566535 seoul |
| Command> | GEOADD map 126.70520693063735 37.4562551 incheon |
| Command> | GEOADD map 127.38454750000005 36.3504119 daejeon |
| Command> | GEOADD map 129.07564160000004 35.1795543 busan |
Specify a city or coordinates
This is required.
- FROMMEMBER: Use this to search from a city (member).
- FROMLONLAT: Use this to search from coordinates (longitude, latitude).
Specify a radius (circle) or a box
This is required.
- BYRADIUS: Search by circle radius.
- BYBOX: Search by box height and width.
- Distance can be entered as m(meter), km(kilometer), ft(feet), mi(mile).
Example: FROMMEMBER, BYRADIUS
| Command> | GEOSEARCH map FROMMEMBER seoul BYRADIUS 200 km |
| Result> |
1) "incheon" 2) "seoul" 3) "daejeon" |
| Command> | GEOSEARCH map FROMMEMBER seoul BYRADIUS 200 km asc |
| Result> |
1) "seoul" 2) "incheon" 3) "daejeon" |
| Command> | GEOSEARCH map FROMMEMBER seoul BYRADIUS 200 km asc withcoord |
| Result> |
1) 1) "seoul" 2) 1) "126.97797149419784546" 2) "37.56653579238348328" 2) 1) "incheon" 2) 1) "126.70520693063735962" 2) "37.45625514418296831" 3) 1) "daejeon" 2) 1) "127.38454610109329224" 2) "36.3504120662288841" |
| Command> | GEOSEARCH map FROMMEMBER seoul BYRADIUS 200 km asc withdist |
| Result> |
1) 1) "seoul" 2) "0.0000" 2) 1) "incheon" 2) "27.0112" 3) 1) "daejeon" 2) "140.0080" |
| Command> | GEOSEARCH map FROMMEMBER seoul BYRADIUS 200 km asc withhash |
| Result> |
1) 1) "seoul" 2) (integer) 4077564854912194 2) 1) "incheon" 2) (integer) 4077544197320088 3) 1) "daejeon" 2) (integer) 4074568686606292 |
ASC/DESC
- ASC: Show nearest first.
- DESC: Show farthest first.
WITHCOORD/WITHDIST/WITHHASH
- WITHCOORD: Show coordinates (longitude, latitude).
- WITHDIST: Show distance.
- WITHHASH: Show hash value.
COUNT <count>
Use the COUNT option to limit the number of items.
When searching with BYBOX
Example: FROMMEMBER, BYBOX
| Command> | GEOSEARCH map FROMMEMBER seoul BYBOX 200 200 km |
| Result> |
1) "incheon" 2) "seoul" |
| Command> | GEOSEARCH map FROMMEMBER seoul BYBOX 200 200 km asc withdist |
| Result> |
1) 1) "seoul" 2) "0.0000" 2) 1) "incheon" 2) "27.0112" |
When searching with FROMLONLAT
Example: FROMLONLAT
| Command> | GEOSEARCH map FROMLONLAT 127 38 BYRADIUS 200 km |
| Result> |
1) "incheon" 2) "seoul" 3) "daejeon" |
| Command> | GEOSEARCH map FROMLONLAT 127 38 BYRADIUS 200 km asc withdist |
| Result> |
1) 1) "seoul" 2) "48.2515" 2) 1) "incheon" 2) "65.8043" 3) 1) "daejeon" 2) "186.6152" |
| Command> | GEOSEARCH map FROMLONLAT 127 38 BYBOX 200 200 km |
| Result> |
1) "incheon" 2) "seoul" |
| Command> | GEOSEARCH map FROMLONLAT 127 38 BYBOX 200 200 km asc withdist |
| Result> |
1) 1) "seoul" 2) "48.2515" 2) 1) "incheon" 2) "65.8043" |
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]
- Available since version 6.2.0.
- Time complexity is O(N+log(M)).
| << GEOHASH | GEOSEARCH | GEOSEARCHSTORE >> |
|---|
Email
답글이 올라오면 이메일로 알려드리겠습니다.
