title: python elasticsearch format data
body: <p>I am using the below code to get data from elastic search and i am unable to format it as per my requirement</p>
  
  <pre><code>from datetime import datetime
  from elasticsearch import Elasticsearch
  import json
  
  es = Elasticsearch(hosts=[{'host': "localhost", 'port': "9200"}])
  
  res = es.search(index="myindice",size=2, body={"query": {"match_all":{}}})
  for hit in res['hits']['hits']:
    v = hit["_source"]
    q = json.dumps({'name': v['name'],'timestamp': v['@timestamp']})
      print(q)
  </code></pre>
  
  <p>And the output is </p>
  
  <pre><code>{"timestamp": "2016-09-22T00:28:44.000Z", "name": "1456772324.47092"}
  {"timestamp": "2016-09-22T00:32:16.000Z", "name": "1456772536.57587"}
  {"timestamp": "2016-09-22T00:39:19.000Z", "name": "1456772836.57587"}
  </code></pre>
  
  <p>But i want the output like this:</p>
  
  <pre><code>{"mydata":[{"timestamp": "2016-09-22T00:28:44.000Z", "name":"1456772324.47092"},
  {"timestamp": "2016-09-22T00:32:16.000Z", "name": "1456772536.57587"},
  {"timestamp": "2016-09-22T00:39:19.000Z", "name": "1456772836.57587"}]}
  </code></pre>
  
  <p>Could you please help me on how i can achieve this.</p>