【问题标题】:ElasticSearch | The "data" argument must be one of type string, TypedArray, or DataView弹性搜索 | “data”参数必须是 string、TypedArray 或 DataView 类型之一
【发布时间】:2019-06-07 07:53:43
【问题描述】:

我正在学习 ElasticSearch(托管在 AWS 上)。 我正在使用the javascript sdkthis connectionClass

我的代码:

let es = require('elasticsearch');
let client = new es.Client({
  hosts: ['https://search-nboardelastic-xxyy.foo.es.amazonaws.com'],
  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();

问题: 当我运行代码时,出现以下错误:

Error: Request error, retrying
  POST https://https://search-nboardelasticxxyy.foo.es.amazonaws.com/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

我无法弄清楚问题是什么,感谢任何帮助。

【问题讨论】:

  • 从错误信息中,我认为您应该从 hosts 参数中删除 https://

标签: javascript elasticsearch aws-elasticsearch


【解决方案1】:

我不确定 4 个月后这个答案对您有多大用处,但我遇到了同样的问题,解决方案是为 AWS sdk 设置区域。有很多方法可以解决这个问题,我使用的一种是将 aws-sdk 拉入我的 server.js 文件并添加 AWS.config.update({ region: "us-west-2" });

【讨论】:

  • 谢谢。这在不良错误消息的规模上排名相当高
  • 谢谢 Ben,你的回答拯救了我的一天!
  • 本,非常感谢你!你太棒了!
  • Ben..and anotherthankyou from here..很棒的发现..是的..另一个错误消息的兔子洞
猜你喜欢
  • 2020-09-04
  • 2021-08-07
  • 2021-03-16
  • 2022-01-21
  • 2020-02-06
  • 2020-12-09
  • 2021-10-27
  • 2020-03-29
相关资源
最近更新 更多