title: How to update date field in elasticsearch
body: <p>I have data in my Elastic index as below :</p>
  
  <p>Indexed data as:</p>
  
  <pre><code>curl -XPUT 'http://localhost:9200/twitter/tweet/1' -d '{
      "user" : "kimchy",
      "post_date" : "2009-11-15T14:12:12",
      "message" : "trying out Elasticsearch"
  }'
  </code></pre>
  
  <p>Mapping obtained using </p>
  
  <blockquote>
    <p>curl -XGET localhost:9200/twitter</p>
    
    <p>{"twitter":{"aliases":{},"mappings":{"tweet":{"properties":{"message":{"type":"string"},"post_date":{"type":"date","format":"strict_date_optional_time||epoch_millis"},"user":{"type":"string"}}}},"settings":{"index":{"creation_date":"1456739938440","number_of_shards":"5","number_of_replicas":"1","uuid":"DwhS57l1TsKQFyzY23LSiQ","version":{"created":"2020099"}}},"warmers":{}}}</p>
  </blockquote>
  
  <p>Now if I am modifying user as below I am able to do the same:</p>
  
  <pre><code>curl -XPOST 'http://localhost:9200/twitter/tweet/1/_update' -d '{
     "script" : "ctx._source.user=new_user",
     "params" : {
        "new_user" : "search"
     }
  }'
  </code></pre>
  
  <p>But when I tried modifying the date fields as below it is giving an exception :</p>
  
  <pre><code>curl -XPOST 'http://localhost:9200/twitter/tweet/1/_update' -d '{
     "script" : "ctx._source.post_date='new-date'",
     "params" : {
        "new-date" : "2016-02-02T16:12:23"
     }
  }'
  </code></pre>
  
  <p>Exception received is :</p>
  
  <blockquote>
    <p>{"error":{"root_cause":[{"type":"remote_transport_exception","reason":"[Anomaly][127.0.0.1:9300][indices:data/write/update[s]]"}],"type":"illegal_argument_exception","reason":"failed
    to execute
    script","caused_by":{"type":"script_exception","reason":"Failed to
    compile inline script [ctx._source.post_date=new-date] using lang
    [groovy]","caused_by":{"type":"script_exception","reason":"failed to
    compile groovy
    script","caused_by":{"type":"multiple_compilation_errors_exception","reason":"startup failed:\ne90a551666b36d90e4fc5b08d04250da5c4d552d: 1: unexpected
    token: - @ line 1, column 26.\n   ctx._source.post_date=new-date\n<br>
    ^\n\n1 error\n"}}}}</p>
  </blockquote>
  
  <p>Now can anyone let me know how I can handle the same.</p>
  
  <p>~Prashant</p>