索引date_nanos字段值时Elasticsearch非法_参数_异常

o0lyfsai  于 4个月前  发布在  ElasticSearch
关注(0)|答案(1)|浏览(49)

我试图索引使用纳秒epoch作为跨度计时的OpenTelemarket数据。我的索引Map中包含以下内容(通过GET /index/_mappings验证:

"startTimeUnixNano": {
    "type": "date_nanos"
},

字符串
但是,当使用此值索引文档时:

"startTimeUnixNano":1700860667233615872,


Elasticsearch抛出一个illegal_argument_exception

{
    "error":{
        "root_cause":[
            {
                "type":"document_parsing_exception",
                "reason":"[1:1723] failed to parse field [resourceSpans.scopeSpans.spans.startTimeUnixNano] of type [date_nanos] in document with id 'OMxXDowB4M_uH230iKzE'. Preview of field's value: '1700860667233615872'"
            }
        ],
        "type":"document_parsing_exception",
        "reason":"[1:1723] failed to parse field [resourceSpans.scopeSpans.spans.startTimeUnixNano] of type [date_nanos] in document with id 'OMxXDowB4M_uH230iKzE'. Preview of field's value: '1700860667233615872'",
        "caused_by":{
            "type":"illegal_argument_exception",
            "reason":"date[+53900098-12-02T05:46:55.872Z] is after 2262-04-11T23:47:16.854775807 and cannot be stored in nanosecond resolution"
        }
    },
    "status":400
}


它显然接受了这个巨大的时间戳值,其格式的精度低于纳秒,因为Elasticsearch评估的日期是很久以后的,但我已经将索引Map设置为date_nano,所以我不知道为什么我不能给予它一个纳秒的历元。
我已经通过(JavaScript)确认了提供的纳秒时间戳在范围内:

new Date(1700860667233615872 / 1000000)


2023年11月24日

cu6pst1q

cu6pst1q1#

您还需要像在JS代码中那样将发送到ES的值除以1000000,即发送此值将有效并具有正确的分辨率

"startTimeUnixNano": 1700860667233.615872,

字符串
这将解决

Friday, November 24, 2023 9:17:47.233615

相关问题