我在Elastic搜索中编写了以下update_by_query,以在现有索引中发布日期值。
查询如下:
POST my_index/_update_by_query?pretty
{
"query" : {
"match": {
"file.filename": "file56.pdf"
}
},
"script" : {
"inline" : "ctx._source.dbattrs = params.value",
"params" : {
"value" : {
"creation_datetime" : {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis",
"value": "2019-12-30 12:33:45"
}
}
}
}
}
我收到以下错误:
"cause": {
"type": "mapper_parsing_exception",
"reason": "failed to parse field [dbattrs.creation_datetime] of type [text] in document with id '658f556393af33cfe213144d0745674'",
"caused_by": {
"type": "illegal_state_exception",
"reason": "Can't get text on a START_OBJECT at 1:216"
}
},
这意味着日期值未标识为日期,而是文本,这就是为什么会出现错误:“无法解析文本类型的字段”的原因。
如何定义该值是日期类型而不是文本?我认为,将类型定义为日期就足够了,但是它不起作用。