这是我们的文档
{
"geometry" : {
"type" : "Point",
"coordinates" : [ -87.662682, 41.843014 ]
}
}我们希望使用geo_shape排序进行_geo_distance搜索,这两者都针对同一个geometry字段。前者需要geo_shape类型,而后者需要geo_point类型。
这两个索引分别成功,但没有一起成功。
"geometry": {
"type": "geo_shape"
}和
"geometry": {
"properties": {
"coordinates": {
"type": "geo_point"
}
}
},到目前为止,我们已经尝试了这些,失败了
"geometry": {
"type": "geo_shape"
},
"geometry.coordinates": {
"type": "geo_point"
},也是
"geometry": {
"copy_to": "geometryShape",
"type": "geo_shape"
},
"geometryShape": {
"properties": {
"coordinates": {
"type": "geo_point"
}
}
}也是
"geometry": {
"copy_to": "geometryShape",
"properties": {
"coordinates": {
"type": "geo_point"
}
}
},
"geometryShape": {
"type": "geo_shape"
}对于如何正确创建这个索引,有什么想法吗?
发布于 2015-05-01 20:02:02
如果启用了脚本,那么您可以通过在映射中指定变换来实现它。
会在这几条线上看什么东西:
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"
}
}
}发布于 2015-04-30 18:58:59
我将使用查询和您最初的映射,只使用geo_shape。Elasticsearch建议,按距离得分通常比按距离排序更好。
另外,您是否使用带有geo_bounding_box的geo_point签出了?我不清楚您使用geo_shape类型是为了什么,但是您可能可以使用边界框来复制它。查看一个示例这里。
https://stackoverflow.com/questions/29855726
复制相似问题