【问题标题】:Elasticsearch Ingest pipeline -epoch_millis to date formatElasticsearch 摄取管道 -epoch_millis 到日期格式
【发布时间】:2017-06-11 20:01:41
【问题描述】:

我在 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
}

有什么想法吗?

【问题讨论】:

    标签: date elasticsearch data-ingestion


    【解决方案1】:

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

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

    【讨论】:

    • 很好,现在创建管道工作了!非常感谢瓦尔,你太棒了。然而现在又出现了一个新问题。当我尝试使用重新索引 API 应用管道时,使用 - POST _reindex { "source": { "index": "twitter" }, "dest": { "index": "twitter", "pipeline": "p1 “ } } 我现在得到一个异常“类型 [java.lang.Long] 的字段 [temp] 不能转换为 [java.lang.String]”
    • 您不能使用与源和目标相同的索引。您的目的地必须是具有新映射的另一个索引。
    • 我正在使用不同的目标索引
    • 在您之前的评论中,它们都被标记为twitter
    • 对不起,这是一个错字,我确实使用了 2 个不同的索引
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-11
    • 1970-01-01
    • 1970-01-01
    • 2019-05-24
    • 2018-10-07
    相关资源
    最近更新 更多