AWS Elasticsearch cluster connects through nodejs.
const AWS = require('aws-sdk')
const elasticsearch = require('elasticsearch')
const awsHttpClient = require('http-aws-es')
let client = elasticsearch.Client({
host: 'http://---.us-east-1.es.amazonaws.com/',
connectionClass: awsHttpClient,
amazonES: {
region: 'us-east-1',
credentials: new AWS.Credentials('----', '-----')
}
});
client.search({
index: 'orders',
type: 'text',
body: {
query: {
match: {
source: 'ETH'
}
}
}
})
.then(res => console.log("Error : ",res));
Elasticsearch ERROR: 2021-08-28T07:40:03Z Error: Request error, retrying POST http://-------.us-east-1.es.amazonaws.com/eth_orders/_search?type=text => The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined at Log.error (C:\Users\genie\node_modules\elasticsearch\src\lib\log.js:239:56) at checkRespForFailure (C:\Users\genie\node_modules\elasticsearch\src\lib\transport.js:298:18) at done (C:\Users\genie\node_modules\http-aws-es\connector.js:48:7) at processTicksAndRejections (internal/process/task_queues.js:95:5)
Elasticsearch WARNING: 2021-08-28T07:40:03Z Unable to revive connection: http://-----.us-east-1.es.amazonaws.com/
Elasticsearch WARNING: 2021-08-28T07:40:03Z No living connections
(node:18256) UnhandledPromiseRejectionWarning: Error: No Living connections at sendReqWithConnection (C:\Users\genie\node_modules\elasticsearch\src\lib\transport.js:266:15) at next (C:\Users\genie\node_modules\elasticsearch\src\lib\connection_pool.js:243:7) at processTicksAndRejections (internal/process/task_queues.js:77:11) (Use
node --trace-warnings ...
to show where the warning was created) (node:18256) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:18256) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I am getting these errors can anyone help out.
Doctypes are not available in latest Elasticsearch version so probably just remove type: 'text',
client.search({
index: 'orders',
body: {
query: {
match: {
source: 'ETH'
}
}
}
})