title: How to format date inside source script?
body: <p>I'm using <code>terms</code> aggregations with <code>script</code> property, i know that i can use <code>format</code> property to get date value in specific date format; but i wanna write required format to be gotten inside script source code.</p>
  
  <pre><code>{
    "size": 0,
    "aggs": {
      "NAME": {
        "terms": {
          "script": {
            "source": "doc['Ship Date'].value",
            "lang": "painless"
          },
          "size": 100,
          "order": {
            "_key": "asc"
          }
        }
      }
    }
  }
  </code></pre>