Skip to content

Commit b908c65

Browse files
DOC-2761 basic GEO index example
1 parent d50732b commit b908c65

File tree

1 file changed

+24
-0
lines changed
  • content/develop/interact/search-and-query/indexing

1 file changed

+24
-0
lines changed

content/develop/interact/search-and-query/indexing/geoindex.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,28 @@ The sections below describe these schema types in more detail.
5050

5151
## `GEO`
5252

53+
A `GEO` index lets you represent geospatial data either as
54+
a string containing a longitude-latitude pair (for example,
55+
"-104.991531, 39.742043") or as a JSON array of these
56+
strings. Note that the longitude value comes first in the
57+
string.
5358

59+
The following command creates a `GEO` index for JSON objects
60+
like the one shown in the example above:
61+
62+
FT.CREATE productidx ON JSON PREFIX 1 product: SCHEMA $.location AS location GEO
63+
64+
If you now add JSON objects with the `product:` prefix and a `location` field,
65+
they will be added to the index automatically:
66+
67+
>JSON.SET product:46885 $ '{"description": "Navy Blue Slippers","price": 45.99,"city": "Denver","location": "-104.991531, 39.742043"}'
68+
OK
69+
>JSON.SET product:46886 $ '{"description": "Bright Green Socks","price": 25.50,"city": "Fort Collins","location": "-105.0618814,40.5150098"}'
70+
71+
72+
73+
> FT.SEARCH productidx '@location:[-104.800644 38.846127 100 mi]'
74+
1) "1"
75+
2) "product:46885"
76+
3) 1) "$"
77+
2) "{\"description\":\"Navy Blue Slippers\",\"price\":45.99,\"city\":\"Denver\",\"location\":\"-104.991531, 39.742043\"}"

0 commit comments

Comments
 (0)