我想在我的程序中添加一些自定义地理搜索功能(不是 geoip,将 IP 地址转换为坐标)。如何将自定义纬度和经度数据过滤为 elasticsearch geo_type 格式数据,以便我可以在 kibana 平铺 map 中可视化?
最佳答案
正如您可能已经发现的,有一个(有点笨拙)的解决方案。 基本上,您需要先设置 geo_point 字段的映射,然后才能以这种方式记录数据(我还直接使用 ES python 模块,而不是通过logstash 进行记录..只是为了确定)。
那么如何设置正确的映射呢?
确保您使用新的 elasticsearch 实例(或者至少尚未设置您将使用的索引和类型的映射)
从 sense 运行(或使用适当的curl命令)
PUT <index_name>
{
"mappings": {
"<type_name>": {
"properties": {
"timestamp": {
"type": "date"
},
"message": {
"type": "string"
},
"location": {
"type": "geo_point"
}
<etc.>
}
}
}
}
现在你已经很出色了,只需确保你的 geo_points 采用 ES 除外的格式即可
有关绘制地理点的更多信息:
ElasticSearch how to setup geo_point
这里:
https://discuss.elastic.co/t/geo-point-logging-from-python-to-elasticsearch/37336
关于elasticsearch - 如何从logstash将geo_point类型数据添加到elasticsearch?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30861405/