elasticsearch - 将 geoIP 数据添加到 Elasticsearch 索引中的旧数据
问题描述
我最近在 Elasticsearch 的摄取管道中添加了一个 GeoIP 处理器。这很好用,并为新摄取的文档添加了新字段。我想通过对索引执行 _update_by_query 将 GeoIP 字段添加到旧数据中,但是,它似乎不接受“处理器”作为参数。
我想做的是这样的:
POST my_index*/_update_by_query
{
"refresh": true,
"processors": [
{
"geoip" : {
"field": "doc['client_ip']",
"target_field" : "geo",
"database_file" : "GeoLite2-City.mmdb",
"properties":["continent_name", "country_iso_code", "country_name", "city_name", "timezone", "location"]
}
}
],
"script": {
"day_of_week": {
"type": "long",
"script": "emit(doc['@timestamp'].value.withZoneSameInstant(ZoneId.of(doc['geo.timezone'])).getDayOfWeek().getValue())"
},
"hour_of_day": {
"type": "long",
"script": "emit(doc['@timestamp'].value.withZoneSameInstant(ZoneId.of(doc['geo.timezone'])).getHour())"
},
"office_hours": {
"script": "if (doc['day_of_week'].value< 6 && doc['day_of_week'].value > 0) {if (doc['hour_of_day'].value> 7 && doc['hour_of_day'].value<19) {return 1;} else {return -1;} } else {return -1;}"
}
}
}
我收到以下错误:
{
"error" : {
"root_cause" : [
{
"type" : "parse_exception",
"reason" : "Expected one of [source] or [id] fields, but found none"
}
],
"type" : "parse_exception",
"reason" : "Expected one of [source] or [id] fields, but found none"
},
"status" : 400
}
解决方案
由于您已准备好摄取管道,因此您只需在对_update_by_query
端点的调用中引用它,如下所示:
POST my_index*/_update_by_query?pipeline=my-pipeline
^
|
add this
推荐阅读
- python - Shapely Python:查找线串和多边形接触的位置
- vba - vba 宏将不同工作簿中的数据合并到一个工作簿中
- php - 如何从要在包含文件中使用的函数中返回数据库?
- ruby-on-rails - Rails 资产无法预编译
- postgresql - PostgreSQL:子查询返回多于一行
- c++ - 在 Visual Studio 2017 中创建向后兼容的项目?
- docker - docker-compose 构建环境变量
- java - Java JSP - 删除 .DS_Store 并显示正确的文件夹名称
- python - 如何在 Python 3.6 中使用异步生成器?
- java - MockMvc + Hamcrest:浮点数的不一致集合