0

我在 ES 5.4.1 中使用 reindex API,我需要将一个长字段(代表一个日期)转换为一个日期字段。所以源索引看起来像

"hits": {
      "total": 1,
      "max_score": 1,
      "hits": [
         {
            "_index": "twitter",
            "_type": "tweet",
            "_id": "1",
            "_score": 1,
            "_source": {
               "temp": 1496938873065,
               "message": "hello",
               "user": "joan"
            }
         }
      ]
   }

temp 必须转换为日期对象。

我想用处理器,

PUT _ingest/pipeline/p1
{
  "processors": [
      {
        "date" : {
        "field" : "temp",
        "target_field" : "updatedOn",
        "formats":["epoch_millis"],
        "timezone" : "Europe/Amsterdam"
      }
      }
    ]
}

但是在尝试创建这个处理器时,我得到了一个错误

{
   "error": {
      "root_cause": [
         {
            "type": "exception",
            "reason": "java.lang.IllegalArgumentException: Illegal pattern component: p",
            "header": {
               "processor_type": "date"
            }
         }
      ],
      "type": "exception",
      "reason": "java.lang.IllegalArgumentException: Illegal pattern component: p",
      "caused_by": {
         "type": "illegal_argument_exception",
         "reason": "Illegal pattern component: p"
      },
      "header": {
         "processor_type": "date"
      }
   },
   "status": 500
}

有任何想法吗?

4

1 回答 1

0

参数错误,formats需要使用UNIX_MS代替epoch_millis,像这样:

PUT _ingest/pipeline/p1
{
  "processors": [
      {
        "date" : {
        "field" : "temp",
        "target_field" : "updatedOn",
        "formats":["UNIX_MS"],
        "timezone" : "Europe/Amsterdam"
      }
      }
    ]
}
于 2017-06-12T04:07:36.587 回答