【发布时间】:2014-03-20 14:01:21
【问题描述】:
我正在使用 Node.js 和 request 模块来创建后端,我们选择 Elasticsearch 作为我们的数据存储。到目前为止一切都很好,除了似乎 Node 不支持 GET 请求的请求主体?这对于Elasticsearch's _search API 来说是必要的,它只期望 GET 请求作为其语义设计的一部分。即使在 GET 请求的情况下,是否有强制 Node 发送请求正文的解决方案,或者意味着在 Elasticsearch 上使用 _search 和另一个 HTTP 动词?
function elasticGet(url, data) {
data = data || {};
return Q.nfcall(request.get, {
uri: url,
body: JSON.stringify(data) //<-- noop
}).then(function(response) {
return JSON.parse(response[1]);
}, function(err) {
console.log(err);
});
}
【问题讨论】:
标签: node.js get request elasticsearch node-request