Trying to parital update a doc but getting error regarding date field with epoch_second format

346 views Asked by At

I'm trying to partially update an existing document which is already in the index and is indexed well, meaning I can view it in Kibana which uses timestamp field to display the documents. I'm trying to update only the doc's name of id test_id my request is:

POST shirkan_test/_update/test_id
{
  "doc": {
    "name": "shirkan"
  },
  "doc_as_upsert": true
}

Getting the following error:

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "failed to parse field [timestamp] of type [date] in document with id 'test_id'. Preview of field's value: '1.602505857664299E9'"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "failed to parse field [timestamp] of type [date] in document with id 'test_id'. Preview of field's value: '1.602505857664299E9'",
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "failed to parse date field [1.602505857664299E9] with format [epoch_second]",
      "caused_by": {
        "type": "date_time_parse_exception",
        "reason": "Failed to parse with all enclosed parsers"
      }
    }
  },
  "status": 400
}

Much appreciate any help with this. Thanks.

EDIT: adding index mapping

{
  "mapping": {
    "properties": {
      "condition": {
        "type": "text",
        "index": false
      },
      "name": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "rank": {
        "type": "double"
      },
      "timestamp": {
        "type": "date",
        "format": "epoch_second"
      }
    }
  }
}

EDIT 2: Changing timestamp format to strict_date_optional_time_nanos doesn't yield such an error and the upsert works well.

1

There are 1 answers

0
Shirkan On BEST ANSWER

Looks like for now, the solution which worked for me to this problem is to change the timestamp field format from epoch_second to strict_date_optional_time_nanos. Other formats may work as well. I had to completely delete the index and recreate it since I came across the same error message when trying to re-index. As mentioned in one of my comments, I filed a bug report here: https://github.com/elastic/elasticsearch/issues/64050