如何在Elasticseearch

时间:2019-07-08 11:26:50

标签: elasticsearch

我正在尝试更改Elasticsearch(v2.3)中某个字段的日期格式。目前,它的field:value格式如下:

"lastChange" : "2019-07-05 11:35:16"

现在,我想以时间格式添加UTC,使其看起来像

"lastChange" : "2019-07-05 11:35:16 UTC"

我已经尝试查询curl -u user:passwd -XPOST 'http://localhost:9200/proc/task/_update_by_query' -H 'Content-Type: application/json' -d' {"script":{"inline":"ctx._source.lastChange=2018-01-01"},"query":{"exists":{"field":"jSrcIp"}}}',但是由于以下错误而失败

{"took":58,"timed_out":false,"total":3,"updated":0,"batches":1,"version_conflicts":0,"noops":0,"retries":0,"failures":[{"index":"proc_v1","type":"tasks","id":"10","cause":{"type":"mapper_parsing_exception","reason":"failed to parse [lastChange]","caused_by":{"type":"illegal_argument_exception","reason":"Invalid format: \"2016\" is too short"}},"status":400},{"index":"proc_v1","type":"tasks","id":"11","cause":{"type":"mapper_parsing_exception","reason":"failed to parse [lastChange]","caused_by":{"type":"illegal_argument_exception","reason":"Invalid format: \"2016\" is too short"}},"status":400},{"index":"proc_v1","type":"tasks","id":"12","cause":{"type":"mapper_parsing_exception","reason":"failed to parse [lastChange]","caused_by":{"type":"illegal_argument_exception","reason":"Invalid format: \"2016\" is too short"}},"status":400}]}

此外,我不确定为什么会说

  

“ 2016年太短了”

出现错误。

但是,如果我尝试类似地更改另一个字段,它会起作用。我尝试了另一个查询curl -u user:passwd -XPOST 'http://localhost:9200/proc/tasks/_update_by_query' -H 'Content-Type: application/json' -d' {"script":{"inline":"ctx._source.fileSize=2000"},"query":{"exists":{"field":"jSrcIp"}}}',所有记录都有一个值为2000的新fileSize字段。

0 个答案:

没有答案