elasticsearch - Elasticsearch:转换量翻倍至geo_point。无效的geohash字符错误

标签 elasticsearch geopoints

当我运行此脚本以将经度和纬度倍数级联到geo_point中时,出现错误。

ElasticsearchIllegalArgumentException[the character \'.\' is not a valid geohash character]

这是我的脚本供引用:
mappings: {
    'index': {
           'transform': {
                   'lang': 'groovy',
                            'script': "ctx._source['coords'] = [ctx._source['lon'],ctx._source['lat']]"
            }
            'properties': {
                    'lon': {
                            'type': 'double',
                    },
                    'lat': {
                            'type': 'string',
                    },
                    'coords': {
                            'type': 'geo_point',
                    }
            }
    }
}

我将不胜感激,谢谢!

最佳答案

由于要从源中提取数据,因此需要在常规脚本中将字符串转换为 double :

new Double(ctx._source['lon']);

关于elasticsearch - Elasticsearch:转换量翻倍至geo_point。无效的geohash字符错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31148329/

相关文章:

java - 关于 Elasticsearch 模式和查询的问题

elasticsearch - 在查询Elasticsearch v6.0.1时使用无痛脚本将新字段添加到_source对象中

elasticsearch - 部分符合 Elasticsearch 查询的要求

java - 使用 Objectify 查询 Geopt

java - 使用elasticsearch获取最近的位置

java - 无法在 ANDROID STUDIO 上导入 com.google.android.maps.GeoPoint

c# - 如何模仿URI查询

filter - 无法使用地理多边形过滤器查询 geo_point

sorting - 使用ElasticSearch对匹配查询进行排序