code: def query_by_sql(self, sql):
          
          # https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-rest.html
          # https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-syntax-select.html
          body = {'query': sql}
  
          resp = self._es.transport.perform_request('POST', '/_xpack/sql', params={'format': 'json'}, body=body)
  
          # build key-value dictionary for each row to match results returned by query_by_string
          columns = [column['name'] for column in resp.get('columns')]
  
          return [dict(zip(columns, row)) for row in resp.get('rows')]
docs: Returns entries matching given SQL query
  
          :type sql str
          :rtype: list[dict]