1

最近、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
}
4

1 に答える 1

1

_update_by_query取り込みパイプラインの準備が整ったので、次のように、エンドポイントへの呼び出しでパイプラインを参照するだけです。

POST my_index*/_update_by_query?pipeline=my-pipeline
                                    ^
                                    |
                                 add this
于 2021-11-16T15:30:09.157 に答える