我使用gdal和ogr将osm数据导入到elasticsearch的索引中。现在数据集看起来像这样:
{
"_index": "points",
"_id": "ttZCjIwB1FY7TO4ET-AK",
"_score": 6.103035,
"_source": {
"ogc_fid": 24862,
"geometry": {
"type": "Point",
"coordinates": [
8.7037536,
48.8916509
]
},
"osm_id": "3330289083",
"name": "Amt für Umweltschutz",
"other_tags": "\"addr:city\"=>\"Pforzheim\",\"addr:country\"=>\"DE\",\"addr:housenumber\"=>\"9\",\"addr:postcode\"=>\"75175\",\"addr:street\"=>\"Östliche Karl-Friedrich-Straße\",\"government\"=>\"environment\",\"office\"=>\"government\""
}
}
字符串
由于OSM数据结构,地址数据已导入字段other_tags
为了创建更简单的elasticsearch查询,我更喜欢这样的索引结构:
{
"_index": "points",
"_id": "ttZCjIwB1FY7TO4ET-AK",
"_score": 6.103035,
"_source": {
"ogc_fid": 24862,
"geometry": {
"type": "Point",
"coordinates": [
8.7037536,
48.8916509
]
},
"osm_id": "3330289083",
"name": "Amt für Umweltschutz",
"city": "Pforzheim",
"country": "DE",
"housenumber": "9",
"postcode": "75175",
"street": "Östliche Karl-Friedrich-Straße"
}
}
型
我读到过可以用logstash来改变数据,并且有很多例子可以说明一个mutate filter函数是什么样子的。我找了4个小时,但是我找不到如何使用Logstash的mutate filter。
有谁能告诉我实现目标的具体步骤是什么?我需要安装一些东西吗?我需要连接到elasticsearch服务器并使用一些命令吗?或者可以通过请求elasticsearch API来实现吗?
谢谢
2条答案
按热度按时间x4shl7ld1#
如果您使用Logstash导入此数据,则最好使用
kv
filter来解析other_tags
中的地址数据,然后使用mutate/rename
过滤器从字段名称中删除addr:
前缀,如下所示:字符串
n6lpvg4x2#
我发现在重新索引索引时可以改变索引结构,在我的情况下,这也很好。
字符串
如果有人知道更好的方法,我仍然欣赏可能更快,更优雅的解决方案。