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
1 Answer
Reset to default 13I 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" });