question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

client6.sql.query is not work

See original GitHub issue

elastic version: 6.6.2

my code:

const { Client: Client7 } = require('@elastic/elasticsearch')
const client6 = new Client7({ node: 'http://localhost:9200' })


let aa = await client6.sql.query({
            body: {
                query: `SELECT * FROM "${this.elastic_name}"`,
            }
 });

Correct interface request:

POST _xpack/sql?format=json
{
  "query":"SELECT * FROM \"f271444afc2479560efc51b68a0cc996\" limit 10"
}

He works normally.

but api/sql.query.js

line 82:

path = '/' + '_sql'

The request is:

{ method: 'POST',
  path: '/_sql',
  body: { query: 'SELECT * FROM "f271444afc2479560efc51b68a0cc996"' },
  querystring: {} }

error:

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

Change the code to :

path = '/' + '_xpack/sql'

Can operate normally

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
mitjafelicijancommented, Mar 4, 2020

For whoever is looking for a direct solution, here it is.


const client = new Elastic({
  node: 'http://localhost:9200'
});

let results = await client.transport.request({
  method: 'POST',
  path: '/_opendistro/_sql',
  body: { query: 'select * from some-index limit 10' }
}) ;

console.log(results);
1reaction
delvedorcommented, Feb 13, 2020

@mitjafelicijan you can’t change the path via an option, as this client is generated from the Elasticsearch’s spec. You can either use the transport.request or use the extend API and override the default implementation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to troubleshoot SQL Server error 8645 - Microsoft Support
You may see the following 8645 error sporadically: Error 8645: A time out occurred while waiting for memory resources to execute the query....
Read more >
sql query is not working properly - Stack Overflow
i am using sql query to get the result. my first table is snd_marketvisits this table have properties like id ,pjpCode , section...
Read more >
MySQL
MySQL HeatWave is a fully managed service that enables customers to run OLTP, OLAP, and machine learning workloads directly from their MySQL Database....
Read more >
SQL AND, OR, NOT Operators - W3Schools
CustomerID CustomerName ContactName Address 1 Alfreds Futterkiste Maria Anders Obere Str. 57 2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución... 3 Antonio...
Read more >
The7 — Website and eCommerce Builder for WordPress
The theme is compatible with a wide range of search engine optimization plugins, ... The "Gradient" option is not working for image hovers....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found