Get data value inside the EXEC function
ggmacasaet opened this issue · 1 comments
Hi Guys,
I am trying to get the RESULT of the search outside the EXEC function for canonical search. Can you please help?
In the example:
//Search call as a reusable object with a canonical callback
mySearchCall = elasticSearchClient.search('my_index_name', 'my_type_name', qryObj);
//Do it once
mySearchCall.exec(function(err, data){
console.log(JSON.parse(data))
})
but i need
//Search call as a reusable object with a canonical callback
mySearchCall = elasticSearchClient.search('my_index_name', 'my_type_name', qryObj);
//Do it once
data = mySearchCall.exec(function(err, data){
console.log(JSON.parse(data))
return data;
})
Its asynchronous man. You would have to wrap it in a promise or something similar. however my guess is that you should read up a bit on asynchronous coding and node.js a bit first. Most of node is very much based on callbacks.