I am performing a search on my AWS CloudSearch domain from a Lambda function in node.js:
I uploaded a document such as this:
{
“some_field”: “bla bla“,
“some_date_field”: 1.466719E9,
"number_field”: 4,
“some_string”: "some long string blabla"
}
And I perform a search like this
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
}
});
The search works and as documented here CloudSearch returns document info in fields property of a hit. Here is an example:
{
"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"
],
}
}
]
}
}
As you can see all the fields are returned as strings in an array. Is there anyway to get the results as a JSON that preserves the type of all the fields?