Elasticsearch returns 将字段存储为字符串

Elasticsearch returns stored fields as string

我有一个名为 mydate 的字段,在 ES 5.4 中具有以下映射:

{
  "type": "date",
  "store" : true,
  "format" : "epoch_millis"
}

现在,使用以下查询:

POST foo/bar/_search
{
  "query":{ "match_all": {} },
  "stored_fields": [ "mydate" ]
}

ES returns:

{
  "took": 7,
  "timed_out": false,
  "_shards": {...},
  "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "foo",
        "_type": "bar",
        "_id": "1162256",
        "_score": 1,
        "fields": {
          "mydate": [
            "1504540873381"
          ]
        }
      }
    ]
  }
}

我的问题是为什么返回的字段值是string,不是long。当我使用 _source 进行查询时,它确实是一个长值。

不是真正的答案,但至少它解释了为什么会发生:https://github.com/elastic/elasticsearch/issues/26504