【问题标题】:Elasticsearch returns stored fields as stringElasticsearch 将存储的字段作为字符串返回
【发布时间】:2017-09-05 06:44:52
【问题描述】:

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

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

现在,使用以下查询:

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

ES 返回:

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

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

【问题讨论】:

  • 有趣的问题。我查看了试图弄清楚这一点的消息来源。它使用称为 FieldVisitor 的东西,它具有 intValue() 和 stringValue() 等方法,但没有日期字段。如果它也发生在整数字段中,您可以尝试使用吗?也许这是一个错误。来源:github.com/elastic/elasticsearch/blob/…
  • 整数字段不会发生这种情况。我应该将其发布为 github 问题吗?
  • 我想是的。不过我不是贡献者。

标签: elasticsearch elasticsearch-5


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2013-08-06
    • 2019-12-15
    • 2020-03-26
    • 1970-01-01
    • 2015-12-10
    • 1970-01-01
    • 2017-10-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多