我正在学习 ElasticSearch(托管在 AWS 上)。
我正在使用javascript SDK和这个连接类。
我的代码:
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
我无法弄清楚问题所在,需要帮助。
https://
。 - Pierre-Nicolas Mougel