最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin8浏览0评论

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论