Elasticsearch 1.x add field copy of timestamp

前端 未结 1 703
醉梦人生
醉梦人生 2021-01-27 04:56

I am working in ES 1.5.2. I have an index with documents, with stored timestamp values. I want to add a regular field to it, which will assume the value of the _timestamp field

相关标签:
1条回答
  • 2021-01-27 05:42

    In ES 1.5.2, you can use the update by query plugin in order to reindex your documents and copy the _timestamp field to a regular field.

    After installing the plugin with the following command:

    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
    

    And making sure that dynamic scripting is enabled in your elasticsearch.yml configuration file, you'll be able to run the following command

    POST /twitter/_update_by_query
    {
      "script": {
        "inline": "ctx._source.new_timestamp = ctx._timestamp”
      },
      "query": {
        "match_all": {}
      }
    }
    
    0 讨论(0)
提交回复
热议问题