我有来自外部来源的数据,我在 Discover of Kibana 中的字段之一是“ clearancetime ”。此字段为空或具有以下格式的时间戳:
January 22nd 2017, 00:00:00.000
我编写了一个在三元语句中使用清除时间的字段。我认为在 Discover 中出现错误,即表达式中使用的字段 cleartime 在映射中不存在。因此,我尝试使用以下 PUT 请求通过 sense 添加它:
PUT source*/_mappings/clearancetime
{
"properties": {
"data": {
"type": "date"
}
}
}
我得到回复:{ "acknowledge": true }
但是我仍然得到映射错误中不存在相同的字段。
有任何想法吗?
更新:一些额外的错误信息(对不起格式)....
Error: Request to Elasticsearch failed: {"error":
{"root_cause":[{"type":"script_exception",
"reason":"Field [clearancetime] used in expression does not exist in mappings"}],
"type":"search_phase_execution_exception","reason":"all shards failed",
"phase":"query","grouped":true,"failed_shards":
[{"shard:0,"index":"source-raw-2017.01","node":"dewddasOSada_0vJWA",
"reason":{"type":"script_exception","reason":"Error during search with inline script
[doc['clearancetime'].value > 0 ? doc['clearancetime'].value - doc['initialtime'].value : 0] using lang [expression]",
"caused_by":{"type":"script_exception",
"reason":"Field [clearancetime] used in expression does not exist in mappings"}}}]}}
名为“duration”的脚本字段具有以下三元表达式:
doc['clearancetime'].value > 0 ? doc['clearancetime'].value - doc['initialtime'].value : 0