I have a Node.js application. I need to query an ElasticSearch instance that's running on http://myserver.com to see if it still "alive". I'm trying to identify two things:
What is the most performant way to query ElasticSearch from Node.js? I know I can run queries against ElasticSearch in PostMan. For that reason, I think I can just use the http module in node. Yet, I'm not sure if this is really the most performant approach.
What is the smallest query I can run against ElasticSearch just to see if its running? I know if I was hitting a SQL database, I could just use SELECT 1. Is there something similar in ElasticSearch?
Thank you so much for your help!
For nodejs, you can use. Elasticsearch client elasticsearchjs
And, You can ping the cluster to see if it is running.
ie.
client.ping({
requestTimeout: 1000,
// undocumented params are appended to the query string
hello: "elasticsearch!"
}, function (error) {
if (error) {
console.error('elasticsearch cluster is down!');
} else {
console.log('All is well');
}
});
I think that helps, Good luck in starting elasticsearch in nodejs.