Elasticsearch SQL-Query not possible

2.9k Views Asked by At

I got a ElasticSearch Instance running locally which works fine. Now I want to query an index using SQL. I tried it with the NodeJS-Client (v7) and normally via the REST-Api. Rest call:

POST http://localhost:9200/_sql
{
   "body": {
       "query": "DESCRIBE indexname"
   }
}

And via nodeJS:

elasticClient.sql.query({
    format: "json",
    body: {
        query: "DESCRIBE indexname"
    }
}).then(result => {
    console.log(result);
}).catch(reject => {
    console.log(reject);
});

Both give back the same error:

Incorrect HTTP method for uri [/_sql] and method [POST], allowed: [GET, HEAD, PUT, DELETE] status: 405

Can anyone help? Cheers!

2

There are 2 best solutions below

2
On

Try

GET http://localhost:9200/_sql
{
   "body": {
       "query": "DESCRIBE indexname"
   }
}
0
On

This issue is normally caused by the incompatibility of your elastic/elasticsearch module. What is your ES version? Try to upgrade your NodeJS version to your ES version.

Check the compatibility here.

https://www.npmjs.com/package/@elastic/elasticsearch