这是我们的文件:
{
"geometry" : {
"type" : "Point",
"coordinates" : [ -87.662682, 41.843014 ]
}
}
Run Code Online (Sandbox Code Playgroud)
我们希望做一个geo_shape与搜索_geo_distance排序,都对同一geometry领域.前者需要geo_shape类型,而后者需要geo_point.
这两个索引单独成功,但不能一起成功:
"geometry": {
"type": "geo_shape"
}
Run Code Online (Sandbox Code Playgroud)
和
"geometry": {
"properties": {
"coordinates": {
"type": "geo_point"
}
}
},
Run Code Online (Sandbox Code Playgroud)
到目前为止,我们尝试过这些并且失败了:
"geometry": {
"type": "geo_shape"
},
"geometry.coordinates": {
"type": "geo_point"
},
Run Code Online (Sandbox Code Playgroud)
也
"geometry": {
"copy_to": "geometryShape",
"type": "geo_shape"
},
"geometryShape": {
"properties": {
"coordinates": {
"type": "geo_point"
}
}
}
Run Code Online (Sandbox Code Playgroud)
也
"geometry": {
"copy_to": "geometryShape",
"properties": {
"coordinates": {
"type": "geo_point"
}
}
},
"geometryShape": {
"type": "geo_shape"
}
Run Code Online (Sandbox Code Playgroud)
有关如何正确创建此索引的任何想法?
如果启用了脚本,那么您可以通过在映射中指定转换来实现它
会看起来像这样:
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"
}
}
}
Run Code Online (Sandbox Code Playgroud)