Here is our document:
{
"geometry" : {
"type" : "Point",
"coordinates" : [ -87.662682, 41.843014 ]
}
}
We'd like to do a geo_shape
search with a _geo_distance
sort, both against the same geometry
field. The former requiresgeo_shape
types while the latter requires geo_point
.
These two indexes succeed individually, but not together:
"geometry": {
"type": "geo_shape"
}
and
"geometry": {
"properties": {
"coordinates": {
"type": "geo_point"
}
}
},
So far we've tried these and failed:
"geometry": {
"type": "geo_shape"
},
"geometry.coordinates": {
"type": "geo_point"
},
also
"geometry": {
"copy_to": "geometryShape",
"type": "geo_shape"
},
"geometryShape": {
"properties": {
"coordinates": {
"type": "geo_point"
}
}
}
also
"geometry": {
"copy_to": "geometryShape",
"properties": {
"coordinates": {
"type": "geo_point"
}
}
},
"geometryShape": {
"type": "geo_shape"
}
Any ideas on how to create this index properly?
If scripting is enabled then you could achieve it via specifying transforms in mapping
would look something on these lines :
put test/test_type/_mapping
{
"transform": {
"script": "if (ctx._source['geometry']['coordinates']) ctx._source['test'] = ctx._source['geometry']['coordinates']",
"lang": "groovy"
},
"properties": {
"geometry": {
"type": "geo_shape"
},
"coordinates": {
"type": "geo_point"
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With