title: AWS CloudSearch - Getting results of a search in JSON format
body: <p>I am performing a search on my AWS CloudSearch domain from a Lambda function in node.js:</p>
  
  <p><strong>I uploaded a document such as this:</strong></p>
  
  <pre><code>         {
                 “some_field”: “bla bla“,
                 “some_date_field”: 1.466719E9,
                 "number_field”: 4,
                 “some_string”: "some long string blabla"
           }
  </code></pre>
  
  <p><strong>And I perform a search like this</strong></p>
  
  <pre><code>   var params = {
                    query: 'bla bla',
                  };
  
      cloudsearchdomain.search(params, function(err, data) {
  
        if (err) {
          console.log(err, err.stack); // an error occurred
          context.fail(err); 
        } 
        else  {
          context.succeed(data);           // successful response
        }    
  
      });
  </code></pre>
  
  <p>The search works and as documented <a href="http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudSearchDomain.html#search-property" rel="noreferrer">here</a> CloudSearch returns document
  info in fields property of a hit. Here is an example:</p>
  
  <pre><code>  {
     "status": {
     "timems": 2,
     "rid": “blabla”
    },
      "hits": {
         "found": 1,
         "start": 0,
         "hit": [
                 {
                  "id": “452545-49B4-45C3-B94F-43524542352-454352435.6666-8532-4099-xxxx-1",
                  "fields": {
                     “some_field”: [
                       “bla bla“
                      ],
                     “some_date_field”: [
                       "1.466719E9"
                      ],
                     "number_field”: [
                        "4"
                      ],
                     “some_string”: [
                       "some long string blabla"
                     ],
               }
        }
     ]
   }
   }
  </code></pre>
  
  <p>As you can see all the fields are returned as strings in an array.
  <strong>Is there anyway to get the results as a JSON that preserves the
  type of all the fields?</strong></p>