I'm using the elasticsearch API for node.js to make the following query to aws elasticsearch.
The elasticsearch documentation says that the request body search uses the GET method.
I'm using Wireshark to look at the request send by my application with the body search method and I see that the method used is a POST.
Why is sending a POST? I want to allow only GET request to my domain.
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);
});