javascript - ElasticSearch | The "data" argument must be one of type string, TypedArray, or DataView

I'm learning ElasticSearch (hosted on AWS). I'm using the javascript sdk and this connection

I'm learning ElasticSearch (hosted on AWS). I'm using the javascript sdk and this connectionClass.

My code:

let es = require('elasticsearch');
let client = new es.Client({
  hosts: [''],
  connectionClass: require('http-aws-es')
});

function handler() {
  let params = {
    index: 'product',
    q: 'bar'
  };
  client.search(params, (err, data) => {
    if (err) {
      console.log('Error ', err);
    } else {
      console.log('Data ', data);
    }
  })
}

handler();

Problem: When I run the code I get the following error:

Error: Request error, retrying
  POST https:// => The "data" argument must be one of type string, TypedArray, or DataView
at checkRespForFailure (/Users/oscarandersen/WebstormProjects/peego/lambda/indexElasticSearch/node_modules/elasticsearch/src/lib/transport.js:266:18)
      at done (/Users/oscarandersen/WebstormProjects/peego/lambda/indexElasticSearch/node_modules/http-aws-es/connector.js:48:7)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:160:7)
      at Function.Module.runMain (module.js:703:11)
      at startup (bootstrap_node.js:193:16)
      at bootstrap_node.js:617:3

I cant figure out what the problem is, any help is appreciated.

I'm learning ElasticSearch (hosted on AWS). I'm using the javascript sdk and this connectionClass.

My code:

let es = require('elasticsearch');
let client = new es.Client({
  hosts: ['https://search-nboardelastic-xxyy.foo.es.amazonaws.'],
  connectionClass: require('http-aws-es')
});

function handler() {
  let params = {
    index: 'product',
    q: 'bar'
  };
  client.search(params, (err, data) => {
    if (err) {
      console.log('Error ', err);
    } else {
      console.log('Data ', data);
    }
  })
}

handler();

Problem: When I run the code I get the following error:

Error: Request error, retrying
  POST https://https://search-nboardelasticxxyy.foo.es.amazonaws./product/_search => The "data" argument must be one of type string, TypedArray, or DataView
at checkRespForFailure (/Users/oscarandersen/WebstormProjects/peego/lambda/indexElasticSearch/node_modules/elasticsearch/src/lib/transport.js:266:18)
      at done (/Users/oscarandersen/WebstormProjects/peego/lambda/indexElasticSearch/node_modules/http-aws-es/connector.js:48:7)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:160:7)
      at Function.Module.runMain (module.js:703:11)
      at startup (bootstrap_node.js:193:16)
      at bootstrap_node.js:617:3

I cant figure out what the problem is, any help is appreciated.

Share Improve this question asked Jun 7, 2019 at 7:53 VingtoftVingtoft 14.7k26 gold badges91 silver badges145 bronze badges 1
  • From the error message, I think you should remove https:// from the hosts parameter. – Pierre-Nicolas Mougel Commented Jun 7, 2019 at 9:09
Add a ment  | 

1 Answer 1

Reset to default 13

I am not sure how useful this answer will be to you 4 months later but I ran into the same problem and the solution was to set the region for the AWS sdk. There are a number of approaches to this, the one I used was pulling in the aws-sdk to my server.js file and adding AWS.config.update({ region: "us-west-2" });

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744094061a4557615.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信