I'm trying to do a _msearch using ElasticSearch from a browser, and can't figure out how to replicate this CURL command.
curl -XPOST http://localhost.com:9200/ratecards/_msearch -d '
{}
{"query":{"term":{"_id": "1"} }}'
Notice the presence of the new line. That's what I want to replicate.
This is the JavaScript I'm using, it's using Angular's $http which is just a thin wrapper around jQuery's ajax commands.
if (routing) {
address += '?routing=' + routing;
}
var data = '\n';
_.each(payloads, function addPayload(payload) {
data += '{}\n' + JSON.stringify(payload);
})
var config = { data: data, method: 'POST', url: address };
$http(config).success(doStuff);
Finally figured it out, using straight jquery I can do this for my data.
config.data = '\n\n{}\n' + JSON.stringify(myQueryObject)
config.type = 'POST'
Then use
$.ajax(config)