Skip to content

ES returns stored fields of type date as string #26504

@akefirad

Description

@akefirad

Elasticsearch version:

{
  "version": {
    "number": "5.4.2",
    "build_hash": "929b078",
    "build_date": "2017-06-15T02:29:28.122Z",
    "build_snapshot": false,
    "lucene_version": "6.5.1"
  }
}

Description of the problem including expected versus actual behavior:
When query asks for stored_fields, in the result, fields of type date are returned as string, even though they are defined as long (epoch_millis). In ES version 1.X it would be long.

Steps to reproduce:

  1. Create an index with one date field with the following mapping:
{
  "type": "date",
  "store" : true,
  "format" : "epoch_millis"
}
  1. Index a document with some date value.
  2. Make the following search query:
{
  "query":{ "match_all": {} },
  "stored_fields": [ "mydate" ]
}
  1. The result is as follow:
{
  "took": 7,
  "timed_out": false,
  "_shards": {},
  "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "foo",
        "_type": "bar",
        "_id": "1162256",
        "_score": 1,
        "fields": {
          "mydate": [
            "1504540873381"
          ]
        }
      }
    ]
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Search/SearchSearch-related issues that do not fall into other categories>docsGeneral docs changeshelp wantedadoptme

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions