ES 6.3.2 elasticsearch-py API with _xpack/sql

Hi Guys,

A quick question please.

I am playing around with the new SQL syntax feature: https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-syntax-select.html

But I noticed that the SQL Rest API is currently not available in the official elasticsearch-py API yet - or maybe I'm missing something?

I am currently working around this by using the Transport.perform_request() function to perform the request like so but if you know a better way please do let me know:

# 'es' is the instantiated Elasticsearch client

query = {
    "query": 'SELECT some_field FROM "some_table" LIMIT 10'
}

results = es.transport.perform_request('POST', '/_xpack/sql', params={'format': 'json'}, body=query)

Cheers,

Hey there,
I am not aware of an implementation either. But, as you did, you could use any mean of sending an HTTP request to Elasticsearch with the appropriate endpoint to get a response back.

1 Like

Thanks!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.