@@ -23,7 +23,7 @@ examples.
23
23
Similar to the `geo_shape` type, the `geo_shape` query uses
24
24
http://www.geojson.org[GeoJSON] to represent shapes.
25
25
26
- Given the following index:
26
+ Given the following index with locations as `geo_shape` fields :
27
27
28
28
[source,console]
29
29
--------------------------------------------------
@@ -77,6 +77,90 @@ GET /example/_search
77
77
}
78
78
--------------------------------------------------
79
79
80
+ The above query can, similarly, be queried on `geo_point` fields.
81
+
82
+ [source,console]
83
+ --------------------------------------------------
84
+ PUT /example_points
85
+ {
86
+ "mappings": {
87
+ "properties": {
88
+ "location": {
89
+ "type": "geo_point"
90
+ }
91
+ }
92
+ }
93
+ }
94
+
95
+ PUT /example_points/_doc/1?refresh
96
+ {
97
+ "name": "Wind & Wetter, Berlin, Germany",
98
+ "location": [13.400544, 52.530286]
99
+ }
100
+ --------------------------------------------------
101
+ // TEST[continued]
102
+
103
+ Using the same query, the documents with matching `geo_point` fields are returned
104
+
105
+ [source,console]
106
+ --------------------------------------------------
107
+ GET /example_points/_search
108
+ {
109
+ "query":{
110
+ "bool": {
111
+ "must": {
112
+ "match_all": {}
113
+ },
114
+ "filter": {
115
+ "geo_shape": {
116
+ "location": {
117
+ "shape": {
118
+ "type": "envelope",
119
+ "coordinates" : [[13.0, 53.0], [14.0, 52.0]]
120
+ },
121
+ "relation": "intersects"
122
+ }
123
+ }
124
+ }
125
+ }
126
+ }
127
+ }
128
+ --------------------------------------------------
129
+ // TEST[continued]
130
+
131
+ [source,console-result]
132
+ --------------------------------------------------
133
+ {
134
+ "took" : 17,
135
+ "timed_out" : false,
136
+ "_shards" : {
137
+ "total" : 1,
138
+ "successful" : 1,
139
+ "skipped" : 0,
140
+ "failed" : 0
141
+ },
142
+ "hits" : {
143
+ "total" : {
144
+ "value" : 1,
145
+ "relation" : "eq"
146
+ },
147
+ "max_score" : 1.0,
148
+ "hits" : [
149
+ {
150
+ "_index" : "example_points",
151
+ "_id" : "1",
152
+ "_score" : 1.0,
153
+ "_source" : {
154
+ "name": "Wind & Wetter, Berlin, Germany",
155
+ "location": [13.400544, 52.530286]
156
+ }
157
+ }
158
+ ]
159
+ }
160
+ }
161
+ --------------------------------------------------
162
+ // TESTRESPONSE[s/"took" : 17/"took" : $body.took/]
163
+
80
164
==== Pre-Indexed Shape
81
165
82
166
The Query also supports using a shape which has already been indexed in
0 commit comments