【问题标题】:Elasticsearch: casting doubles to geo_point. Error with invalid geohash characterElasticsearch:将双打转换为 geo_point。无效的 geohash 字符出错
【发布时间】:2015-06-30 20:55:21
【问题描述】:

当我运行此脚本以将经度和纬度双精度数据连接到 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',
                    }
            }
    }
}

感谢您的帮助,谢谢!

【问题讨论】:

    标签: elasticsearch geopoints


    【解决方案1】:

    由于您是从源中提取数据,因此您需要在 groovy 脚本中将字符串转换为双精度:

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

    【讨论】:

    • 谢谢!那行得通——我把它写成一行,所以我最终做了 ctx._source['lon'].toDouble() 每次我查询坐标时,这个脚本会运行吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-13
    • 2015-04-24
    相关资源
    最近更新 更多