0

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.

enter image description here

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);
    });

1 Answer 1

1

As I go through elasticsearch module and found that in search using POST.

pi.search = ca({
  params: {
    includeTypeName: {
      type: 'string',
      name: 'include_type_name'
    },
    ......
    method: 'POST'
});

Link : filePath

Sign up to request clarification or add additional context in comments.

1 Comment

could you please update the filePath link to the latest one?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.