{
  "schema_version": 2,
  "id": "commands/geosearch",
  "title": "GEOSEARCH",
  "url": "https://redis.io/docs/latest/commands/geosearch/",
  "summary": "Queries a geospatial index for members inside an area of a box or a circle.",
  "since": "6.2.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:43+01:00",
  "page_type": "content",
  "content_hash": "0188f1ef92c554b3f773a614b3a8984fc0bc54cbf47048aef89ab4281681d879",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Return the members of a sorted set populated with geospatial information using [`GEOADD`](https://redis.io/docs/latest/commands/geoadd), which are within the borders of the area specified by a given shape. This command extends the [`GEORADIUS`](https://redis.io/docs/latest/commands/georadius) command, so in addition to searching within circular areas, it supports searching within rectangular areas.\n\nThis command should be used in place of the deprecated [`GEORADIUS`](https://redis.io/docs/latest/commands/georadius) and [`GEORADIUSBYMEMBER`](https://redis.io/docs/latest/commands/georadiusbymember) commands."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe name of the key that holds the geospatial index (a sorted set).\n\n</details>\n\nQuery center point options:\n\n<details open><summary><code>FROMMEMBER member</code></summary>\n\nUse the position of the existing `member` as the center of the search. Mutually exclusive with `FROMLONLAT`.\n\n</details>\n\n<details open><summary><code>FROMLONLAT longitude latitude</code></summary>\n\nUse the given coordinates as the center of the search. Mutually exclusive with `FROMMEMBER`.\n\n</details>\n\nQuery shape options:\n\n<details open><summary><code>BYRADIUS radius M | KM | FT | MI</code></summary>\n\nSearch within a circle of the given `radius` in the specified unit. Mutually exclusive with `BYBOX`.\n\n</details>\n\n<details open><summary><code>BYBOX width height M | KM | FT | MI</code></summary>\n\nSearch within an axis-aligned box of the given `width` and `height` in the specified unit. Mutually exclusive with `BYRADIUS`.\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>ASC | DESC</code></summary>\n\nSort the results by distance from the center: nearest first (`ASC`) or farthest first (`DESC`).\n\n</details>\n\n<details open><summary><code>COUNT count [ANY]</code></summary>\n\nReturn at most `count` matches. With `ANY`, the command returns as soon as enough matches are found — faster, but the results may be unsorted. Without `COUNT`, all matching items are returned.\nThis means that the results returned may not be the ones closest to the specified point, but the effort invested by the server to generate them is significantly less. When ANY is not provided, the command will perform an effort that is proportional to the number of items matching the specified area and sort them, so to query very large areas with a very small COUNT option may be slow even if just a few results are returned.\n\n</details>\n\n<details open><summary><code>WITHCOORD</code></summary>\n\nAlso return the longitude and latitude of each matching item.\n\n</details>\n\n<details open><summary><code>WITHDIST</code></summary>\n\nAlso return the distance of each matching item from the center, in the same unit as the radius.\n\n</details>\n\n<details open><summary><code>WITHHASH</code></summary>\n\nAlso return the raw 52-bit geohash-encoded score of each matching item.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> GEOADD Sicily 13.361389 38.115556 \"Palermo\" 15.087269 37.502669 \"Catania\"\n(integer) 2\nredis> GEOADD Sicily 12.758489 38.788135 \"edge1\"   17.241510 38.788135 \"edge2\"\n(integer) 2\nredis> GEOSEARCH Sicily FROMLONLAT 15 37 BYRADIUS 200 km ASC\n1) \"Catania\"\n2) \"Palermo\"\nredis> GEOSEARCH Sicily FROMLONLAT 15 37 BYBOX 400 400 km ASC WITHCOORD WITHDIST\n1) 1) \"Catania\"\n   2) \"56.4413\"\n   3) 1) \"15.087267458438873\"\n      2) \"37.50266842333162\"\n2) 1) \"Palermo\"\n   2) \"190.4424\"\n   3) 1) \"13.361389338970184\"\n      2) \"38.1155563954963\"\n3) 1) \"edge2\"\n   2) \"279.7403\"\n   3) 1) \"17.241510450839996\"\n      2) \"38.78813451624225\"\n4) 1) \"edge1\"\n   2) \"279.7405\"\n   3) 1) \"12.75848776102066\"\n      2) \"38.78813451624225\""
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\nOne of the following:\n* If no `WITH*` option is specified, an [Array reply](../../develop/reference/protocol-spec#arrays) of matched member names\n* If `WITHCOORD`, `WITHDIST`, or `WITHHASH` options are specified, the command returns an [Array reply](../../develop/reference/protocol-spec#arrays) of arrays, where each sub-array represents a single item:\n    * The distance from the center as a floating point number, in the same unit specified in the radius.\n    * The Geohash integer.\n    * The coordinates as a two items x,y array (longitude,latitude).\n\n**RESP3:**\n\nOne of the following:\n* If no `WITH*` option is specified, an [Array reply](../../develop/reference/protocol-spec#arrays) of matched member names\n* If `WITHCOORD`, `WITHDIST`, or `WITHHASH` options are specified, the command returns an [Array reply](../../develop/reference/protocol-spec#arrays) of arrays, where each sub-array represents a single item:\n    * The distance from the center as a floating point number, in the same unit specified in the radius.\n    * The Geohash integer.\n    * The coordinates as a two items x,y array (longitude,latitude)."
    }
  ],
  "examples": []
}
