4

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!

Andrei Stefan
  • 51,654
  • 6
  • 98
  • 89
m_____0
  • 375
  • 5
  • 18
  • Have the same issue on bonsai... but found nothing yet :-( – tiefenb Nov 08 '19 at 08:21
  • 1
    Which version of ES are you using? I suspect you're running the v7 JS client against a v6 cluster – Val Nov 08 '19 at 08:39
  • 1
    Can you run the same `POST _sql` request with `curl` or something else other than this client code? (asking because that error message is typical for a setup where either **x-pack is not installed**, or **ES-SQL is not enabled**) And it helps to know the exact version of ES server. Also, the body of a `POST` request for `_sql` should be `{"query": "DESCRIBE indexname"}`, not sure why you have `body` in there. – Andrei Stefan Nov 09 '19 at 14:03
  • 1
    @tiefenb can you elaborate more on the questions asked above? Being interested in a post and, also, offering a bounty for it, but not being ready to help with the investigation is not very productive. – Andrei Stefan Nov 12 '19 at 22:59

2 Answers2

0

Try

GET http://localhost:9200/_sql
{
   "body": {
       "query": "DESCRIBE indexname"
   }
}
Ryabchenko Alexander
  • 10,057
  • 7
  • 56
  • 88
0

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

Ke Zhu
  • 207
  • 1
  • 9