title: ElasticSearch - Copy one field value to other field for all documents
body: <p>We have a field "name" in the index. We recently added a new field "alias".
  I want to copy name field value to the new field alias for all documents.</p>
  
  <p>Is there any Update query that will do this? 
  If that is not possible , Help me to achieve this.
  Thanks in advance</p>
  
  <p>I am trying this query 
  <a href="http://URL/index/profile/_update_by_query" rel="noreferrer">http://URL/index/profile/_update_by_query</a></p>
  
  <pre><code>{
    "query": {
  
          "constant_score" : {
              "filter" : {
                  "exists" : { "field" : "name" }
              }
          }
  
    },
    "script" : "ctx._source.alias = name;"
  }
  </code></pre>
  
  <p>In the script , I am not sure how to give name field.
  I getting error</p>
  
  <pre><code>{
    "error": {
      "root_cause": [
        {
          "type": "class_cast_exception",
          "reason": "java.lang.String cannot be cast to java.util.Map"
        }
      ],
      "type": "class_cast_exception",
      "reason": "java.lang.String cannot be cast to java.util.Map"
    },
    "status": 500
  }
  </code></pre>