node.js elasticsearch API 查询搜索请求发送 POST 方法而不是 GET
node.js elasticsearch API query search request sending a POST method instead of GET
我正在为 node.js 使用 elasticsearch API 来对 aws elasticsearch 进行 following 查询。
elasticsearch documentation说请求体搜索使用GET方式
我正在使用 wireshark 查看我的应用程序通过正文搜索方法发送的请求,我发现使用的方法是 POST.
为什么要发送 POST?我只想允许对我的域的 GET 请求。
elasticsearch.js
var elasticsearch = require('elasticsearch');
var AWS = require('aws-sdk');
AWS.config.update({ region: 'eu-central-1' });
var elasticClient = elasticsearch.Client({
hosts: [ 'host' ],
connectionClass: require('http-aws-es'),
log: ['error', 'warning'],
amazonES: {
region: 'eu-central-1',
accessKey: 'accessKey',
secretKey: 'secretKey'
}
});
var indexName = "indexName";
var type = "records";
function querySearch(data){
console.log("[INFO]: Check data "+JSON.stringify(data));
return elasticClient.search({
index: indexName,
type: type,
body: data
});
}
exports.querySearch = querySearch;
index.js
var elastic = require('./elasticsearch.js');
elastic.querySearch({"query": {"bool": {"must": [{ "match": { "id": "value" } }]}}}).then(function (resp) {
//If data doesn't exist in elasticsearch insert into Firehose
if (resp.hits.hits.length == 0){
console.log("[INFO]: No data");
}else{
console.log("[INFO]: Record already in Elasticsearch");
}
}, function (err) {
console.trace("[ERROR]: "+err.message);
});
当我浏览 elasticsearch
模块并发现在 search
中使用 POST
.
pi.search = ca({
params: {
includeTypeName: {
type: 'string',
name: 'include_type_name'
},
......
method: 'POST'
});
Link : filePath
我正在为 node.js 使用 elasticsearch API 来对 aws elasticsearch 进行 following 查询。
elasticsearch documentation说请求体搜索使用GET方式
我正在使用 wireshark 查看我的应用程序通过正文搜索方法发送的请求,我发现使用的方法是 POST.
为什么要发送 POST?我只想允许对我的域的 GET 请求。
elasticsearch.js
var elasticsearch = require('elasticsearch');
var AWS = require('aws-sdk');
AWS.config.update({ region: 'eu-central-1' });
var elasticClient = elasticsearch.Client({
hosts: [ 'host' ],
connectionClass: require('http-aws-es'),
log: ['error', 'warning'],
amazonES: {
region: 'eu-central-1',
accessKey: 'accessKey',
secretKey: 'secretKey'
}
});
var indexName = "indexName";
var type = "records";
function querySearch(data){
console.log("[INFO]: Check data "+JSON.stringify(data));
return elasticClient.search({
index: indexName,
type: type,
body: data
});
}
exports.querySearch = querySearch;
index.js
var elastic = require('./elasticsearch.js');
elastic.querySearch({"query": {"bool": {"must": [{ "match": { "id": "value" } }]}}}).then(function (resp) {
//If data doesn't exist in elasticsearch insert into Firehose
if (resp.hits.hits.length == 0){
console.log("[INFO]: No data");
}else{
console.log("[INFO]: Record already in Elasticsearch");
}
}, function (err) {
console.trace("[ERROR]: "+err.message);
});
当我浏览 elasticsearch
模块并发现在 search
中使用 POST
.
pi.search = ca({
params: {
includeTypeName: {
type: 'string',
name: 'include_type_name'
},
......
method: 'POST'
});
Link : filePath