@@ -14,7 +14,7 @@ Fields of type `geo_point` accept latitude-longitude pairs, which can be used:
1414* to integrate distance into a document's <<query-dsl-function-score-query,relevance score>>.
1515* to <<geo-sorting,sort>> documents by distance.
1616
17- There are five ways that a geopoint may be specified, as demonstrated below:
17+ There are six ways that a geopoint may be specified, as demonstrated below:
1818
1919[source,console]
2020--------------------------------------------------
@@ -31,7 +31,7 @@ PUT my-index-000001
3131
3232PUT my-index-000001/_doc/1
3333{
34- "text": "Geopoint as an object",
34+ "text": "Geopoint as an object with 'lat' and 'lon' keys ",
3535 "location": { <1>
3636 "lat": 41.12,
3737 "lon": -71.34
@@ -40,32 +40,41 @@ PUT my-index-000001/_doc/1
4040
4141PUT my-index-000001/_doc/2
4242{
43- "text": "Geopoint as a string",
44- "location": "41.12,-71.34" <2>
43+ "text": "Geopoint as an object using GeoJSON format",
44+ "location": { <2>
45+ "type": "Point",
46+ "coordinates": [-71.34, 41.12]
47+ }
4548}
4649
4750PUT my-index-000001/_doc/3
4851{
49- "text": "Geopoint as a geohash ",
50- "location": "drm3btev3e86 " <3>
52+ "text": "Geopoint as a string ",
53+ "location": "41.12,-71.34 " <3>
5154}
5255
5356PUT my-index-000001/_doc/4
5457{
55- "text": "Geopoint as an array ",
56- "location": [ -71.34, 41.12 ] <4>
58+ "text": "Geopoint as a geohash ",
59+ "location": "drm3btev3e86" <4>
5760}
5861
5962PUT my-index-000001/_doc/5
63+ {
64+ "text": "Geopoint as an array",
65+ "location": [ -71.34, 41.12 ] <5>
66+ }
67+
68+ PUT my-index-000001/_doc/6
6069{
6170 "text": "Geopoint as a WKT POINT primitive",
62- "location" : "POINT (-71.34 41.12)" <5 >
71+ "location" : "POINT (-71.34 41.12)" <6 >
6372}
6473
6574GET my-index-000001/_search
6675{
6776 "query": {
68- "geo_bounding_box": { <6 >
77+ "geo_bounding_box": { <7 >
6978 "location": {
7079 "top_left": {
7180 "lat": 42,
@@ -82,22 +91,26 @@ GET my-index-000001/_search
8291--------------------------------------------------
8392
8493<1> Geopoint expressed as an object, with `lat` and `lon` keys.
85- <2> Geopoint expressed as a string with the format: `"lat,lon"`.
86- <3> Geopoint expressed as a geohash.
87- <4> Geopoint expressed as an array with the format: [ `lon`, `lat`]
88- <5> Geopoint expressed as a https://docs.opengeospatial.org/is/12-063r5/12-063r5.html[Well-Known Text]
94+ <2> Geopoint expressed as an object, in https://geojson.org/[GeoJSON] format, with `type` and `coordinates` keys.
95+ <3> Geopoint expressed as a string with the format: `"lat,lon"`.
96+ <4> Geopoint expressed as a geohash.
97+ <5> Geopoint expressed as an array with the format: [ `lon`, `lat`]
98+ <6> Geopoint expressed as a https://docs.opengeospatial.org/is/12-063r5/12-063r5.html[Well-Known Text]
8999POINT with the format: `"POINT(lon lat)"`
90- <6 > A geo-bounding box query which finds all geopoints that fall inside the box.
100+ <7 > A geo-bounding box query which finds all geopoints that fall inside the box.
91101
92102[IMPORTANT]
93103.Geopoints expressed as an array or string
94104==================================================
95105
96106Please note that string geopoints are ordered as `lat,lon`, while array
97- geopoints are ordered as the reverse: `lon,lat`.
107+ geopoints, GeoJSON and WKT are ordered as the reverse: `lon,lat`.
98108
99- Originally, `lat,lon` was used for both array and string, but the array
100- format was changed early on to conform to the format used by GeoJSON.
109+ The reasons for this are historical. Geographers traditionally write `latitude`
110+ before `longitude`, while recent formats specified for geographic data like
111+ https://geojson.org/[GeoJSON] and https://docs.opengeospatial.org/is/12-063r5/12-063r5.html[Well-Known Text]
112+ order `longitude` before `latitude` (easting before northing) in order to match
113+ the mathematical convention of ordering `x` before `y`.
101114
102115==================================================
103116
0 commit comments