Based on the discussion here it looks like searching by distance on a geo shape field is supported as of v7.7.0. I'm using 7.9 and getting an error.
I have two indices, one points and one polygons. I have no problem doing a geo_distance search on the point index and returning records in sorted order, with the distance calculated.
However, when I try it against my polygon table, I get an error.
Here's the search:
GET /polygons/_search
{
"size": 10,
"query": {
"geo_distance": {
"geometry": [
-80.08191,
26.29242
],
"distance": 30.48,
"distance_type": "arc"
}
},
"sort": [
{
"_geo_distance": {
"geometry": [
{
"lat": 26.29242,
"lon": -80.08191
}
],
"unit": "m",
"distance_type": "arc",
"order": "asc"
}
}
]
}
But I get the following error:
{
"error" : {
"root_cause" : [
{
"type" : "query_shard_exception",
"reason" : "field [geometry] is not a **geo_point** field",
"index_uuid" : "CoVqpfoARqmI-75mrw0Mew",
"index" : "polygons"
}
],
"type" : "search_phase_execution_exception",
"reason" : "all shards failed",
"phase" : "query",
"grouped" : true,
"failed_shards" : [
{
"shard" : 0,
"index" : "polygons",
"node" : "y4igoHidTPC3kB6w6JIagw",
"reason" : {
"type" : "query_shard_exception",
"reason" : "field [geometry] is not a **geo_point** field",
"index_uuid" : "CoVqpfoARqmI-75mrw0Mew",
"index" : "polygons"
}
}
]
},
"status" : 400
}
I get the same error if I remove the sort portion of the search.