Trying to see how i can call the x-pack sql feature in python. Am I invoking xpack client correctly
AttributeError: 'XPackClient' object has no attribute 'sql'
from elasticsearch import Elasticsearch, RequestsHttpConnection
from requests_aws4auth import AWS4Auth
from elasticsearch_xpack import XPackClient
import boto3
host = ''
region = ''
service = 'es'
credentials = boto3.Session().get_credentials()
awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, region, service, session_token=credentials.token)
es = Elasticsearch(
hosts = [{'host': host, 'port': 443}],
http_auth = awsauth,
use_ssl = True,
verify_certs = True,
connection_class = RequestsHttpConnection
)
xpack = XPackClient(es)
document = {
"query": "SELECT * FROM movies ORDER BY id DESC",
"fetch_size": 2
}
print(xpack.sql(
body = document,
format = 'json'
))