Elasticsearch issue when indexing nanoseconds

Hi Team,

Could not able to index the nanaseconds?

PUT _template/datenanos
{
  "index_patterns": ["datenanos"],
  "mappings": {
    "properties": {
      "timestamp": {
        "type": "date_nanos"
      }
    }
  }
}

POST datenanos/_doc
{
  "timestamp": 1706750418126671600
}

1706817016659228000 is Thursday, February 1, 2024 7:50:16.659 PM in GMT

Error
{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "failed to parse field [timestamp] of type [date_nanos] in document with id 'wR8KZ40BsAu17u8DfBwZ'. Preview of field's value: '1706750418126671600'"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "failed to parse field [timestamp] of type [date_nanos] in document with id 'wR8KZ40BsAu17u8DfBwZ'. Preview of field's value: '1706750418126671600'",
    "caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "date[+54086737-09-12T08:31:11.600Z] is after 2262-04-11T23:47:16.854775807 and cannot be stored in nanosecond resolution"
    }
  },
  "status" : 400
}

The default formatting for date types is strict_date_optional_time_nanos||epoch_millis

I don't believe there is a supported epoch_nanos format so it's passing your timestamp as a millisecond base epoch timestamp.

You'll want to provide dates in strict_date_optional_time_nanos format like yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ

See: date_nanos does't work for 19 symbols nanoseconds · Issue #43917 · elastic/elasticsearch · GitHub

That ticket is closed so if you'd like to see epoch_nanos I'd recommend filling a feature request in that repository or if you are an elastic customer contacting your account team to file an enhancement request.

Thank you @strawgate for the details information.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.