【问题标题】:Elasticsearch 1.x add field copy of timestampElasticsearch 1.x 添加时间戳的字段副本
【发布时间】:2017-11-06 20:15:27
【问题描述】:

我正在使用 ES 1.5.2。我有一个包含文档的索引,其中包含存储的时间戳值。我想向它添加一个常规字段,它将假定该文档的 _timestamp 字段的值。我怎样才能做到这一点?我可以的

PUT twitter/_mapping/new_timestamp
{
  "properties": {
    "name": {
      "type": "float"
    }
  }
}

创建一个常规字段,但如何将所有 _timestamp 值复制到其中?

【问题讨论】:

    标签: elasticsearch indexing timestamp


    【解决方案1】:

    在 ES 1.5.2 中,您可以使用 update by query plugin 来重新索引您的文档并将 _timestamp 字段复制到常规字段。

    使用以下命令安装插件后:

    bin/plugin -url http://oss.sonatype.org/content/repositories/releases/com/yakaz/elasticsearch/plugins/elasticsearch-action-updatebyquery/1.0.0/elasticsearch-action-updatebyquery-1.0.0.zip install elasticsearch-action-updatebyquery
    

    并确保dynamic scripting is enabled 在您的elasticsearch.yml 配置文件中,您将能够运行以下命令

    POST /twitter/_update_by_query
    {
      "script": {
        "inline": "ctx._source.new_timestamp = ctx._timestamp”
      },
      "query": {
        "match_all": {}
      }
    }
    

    【讨论】:

    • 我什至不知道这个插件存在于 1.5
    • 啊,我知道为什么这不起作用。时间戳已启用,但未存储。为此创建了另一个帖子。
    • 我们也要关闭这个帖子吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-16
    • 1970-01-01
    • 2012-12-07
    • 1970-01-01
    • 2016-12-13
    相关资源
    最近更新 更多