title: AWS API gateway and elastic search get query
body: <p>I need to call elastic search engine directly from api gateway using http connection eg.</p>
  
  <p>https:////_doc/_search?pretty&amp;filter_path=hits.hits._source</p>
  
  <p>i have n number of orders in elastic search engine which i want to get using get query ,but i  want only array of json i posted and dont want any  other information in the response.how can i do that ?</p>
  
  <p>eg.</p>
  
  <p>this is what i am getting  : </p>
  
  <pre><code>   {
        "hits" : {
          "hits" : [
            {
              "_index" : "gpss_orders",
              "_type" : "_doc",
              "_id" : "4867254",
              "_score" : 1.0,
              "_source" : {
                "orderId" : 4867254,
                "loadId" : 18214,
                "orderTypeId" : 1
            }
         ]
       }
     }
  </code></pre>
  
  <p>But i would want response something like this  :</p>
  
  <pre><code>[ {
                    "orderId" : 4867254,
                    "loadId" : 18214,
                    "orderTypeId" : 1
                }]
  </code></pre>
  
  <p>do i need to change in api gateway method response?</p>
  
  <p>i changed the api gateway method response template and got the expected out </p>
  
  <pre><code>#set($esOutput = $input.path('$.hits.hits'))
  #set($orders = [])
  #foreach( $elem in $esOutput )
   #set($order = $elem["_source"])
   #set($response = $orders.add($order) )
  #end
  $orders
  </code></pre>
  
  <p>but now the problem i am facing is that though response from elastic search engine is the proper json,response after method integration template update become like this without any braces  : </p>
  
  <pre><code>[{orderId=4867254, loadId=18214, orderTypeId=1, orderTypeName=Fuel}]
  </code></pre>
  
  <p>response from elastic search :</p>
  
  <pre><code>"took" : 1,
    "hits" : {
      "hits" : [
        {
          "_id" : "4867254",
          "_score" : 1.0,
          "_source" : {
            "orderId" : 4867254,
            "loadId" : 18214,
            "orderTypeId" : 1,
  </code></pre>