Hey there,
my objective is narrowing down nearby addresses within 100 meters and sorting them by the nearest address
My mapping:
mappings: {
dynamic: "true",
properties: {
geometry: { type: "geo_shape" }
}
}
The geo_shape is always a point
type: "point",
coordinates: [lat, long]
The query:
GET addresses/_search
{
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
"geo_distance": {
"distance": "100",
"geometry": {
"lat": 51.3606,
"lon": 7.4785
}
}
}
}
},
"sort": [
{
"_geo_distance": {
"geometry": {
"lat": 51.3606,
"lon": 7.4785
},
"order": "asc",
"unit": "m",
"mode": "min",
"distance_type": "arc",
"ignore_unmapped": true
}
}
]
}
The query works without the sorting
The query produces the following error:
{
"error" : {
"root_cause" : [
{
"type" : "class_cast_exception",
"reason" : "class org.elasticsearch.xpack.spatial.index.fielddata.plain.AbstractLatLonShapeIndexFieldData$LatLonShapeIndexFieldData cannot be cast to class org.elasticsearch.index.fielddata.IndexGeoPointFieldData (org.elasticsearch.xpack.spatial.index.fielddata.plain.AbstractLatLonShapeIndexFieldData$LatLonShapeIndexFieldData is in unnamed module of loader java.net.FactoryURLClassLoader @28e94c2; org.elasticsearch.index.fielddata.IndexGeoPointFieldData is in unnamed module of loader 'app')"
}
],
"type" : "search_phase_execution_exception",
"reason" : "all shards failed",
"phase" : "query",
"grouped" : true,
"failed_shards" : [
{
"shard" : 0,
"index" : "addresses",
"node" : "6ncZ_x83Qw2fnlzYvbcRzQ",
"reason" : {
"type" : "class_cast_exception",
"reason" : "class org.elasticsearch.xpack.spatial.index.fielddata.plain.AbstractLatLonShapeIndexFieldData$LatLonShapeIndexFieldData cannot be cast to class org.elasticsearch.index.fielddata.IndexGeoPointFieldData (org.elasticsearch.xpack.spatial.index.fielddata.plain.AbstractLatLonShapeIndexFieldData$LatLonShapeIndexFieldData is in unnamed module of loader java.net.FactoryURLClassLoader @28e94c2; org.elasticsearch.index.fielddata.IndexGeoPointFieldData is in unnamed module of loader 'app')"
}
}
],
"caused_by" : {
"type" : "class_cast_exception",
"reason" : "class org.elasticsearch.xpack.spatial.index.fielddata.plain.AbstractLatLonShapeIndexFieldData$LatLonShapeIndexFieldData cannot be cast to class org.elasticsearch.index.fielddata.IndexGeoPointFieldData (org.elasticsearch.xpack.spatial.index.fielddata.plain.AbstractLatLonShapeIndexFieldData$LatLonShapeIndexFieldData is in unnamed module of loader java.net.FactoryURLClassLoader @28e94c2; org.elasticsearch.index.fielddata.IndexGeoPointFieldData is in unnamed module of loader 'app')",
"caused_by" : {
"type" : "class_cast_exception",
"reason" : "class org.elasticsearch.xpack.spatial.index.fielddata.plain.AbstractLatLonShapeIndexFieldData$LatLonShapeIndexFieldData cannot be cast to class org.elasticsearch.index.fielddata.IndexGeoPointFieldData (org.elasticsearch.xpack.spatial.index.fielddata.plain.AbstractLatLonShapeIndexFieldData$LatLonShapeIndexFieldData is in unnamed module of loader java.net.FactoryURLClassLoader @28e94c2; org.elasticsearch.index.fielddata.IndexGeoPointFieldData is in unnamed module of loader 'app')"
}
}
},
"status" : 500
}
What am I doing wrong?