# Executing elasticsearch-sql using painless script

**URL:** <https://discuss.elastic.co/t/executing-elasticsearch-sql-using-painless-script/220488>\
**Category:** Elasticsearch\
**Created:** [February 22, 2020, 2:17pm UTC](https://discuss.elastic.co/t/executing-elasticsearch-sql-using-painless-script/220488 "2020-02-22T14:17:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yoavb](https://avatars.discourse-cdn.com/v4/letter/y/839c29/32.png) [@yoavb](https://discuss.elastic.co/u/yoavb)\
**Post date:** [February 22, 2020, 2:17pm UTC](https://discuss.elastic.co/t/executing-elasticsearch-sql-using-painless-script/220488/1 "2020-02-22T14:17:39Z")

</div>

Hello,  
\_xpack/sql?format=txt enable to run sql queries using curl.  
I was wondering if it is possible to run sql queries using painless script.  
If it is possible , kindly share an example  
Thanks  
Yoav

---

<div class="post-metadata">

**Author:** ![matriv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matriv/32/43656_2.png) [@matriv](https://discuss.elastic.co/u/matriv)\
**Post date:** [February 23, 2020, 4:02pm UTC](https://discuss.elastic.co/t/executing-elasticsearch-sql-using-painless-script/220488/2 "2020-02-23T16:02:36Z")

</div>

Could you provide some more info? What kind of painless script you'd like to use?  
ES SQL doesn't allow to use painless scripting in the query, but it provides a series of [functions and operators](https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-functions.html) which are translated to painless scripts where necessary.

You can check the ES API query that your SQL translate to by using the **/\_sql/translate** endpoint. And by the way the `/_xpack/sql` is deprecated, you should use `_sql`, what version of Elasticsearch are you using?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 22, 2020, 4:02pm UTC](https://discuss.elastic.co/t/executing-elasticsearch-sql-using-painless-script/220488/3 "2020-03-22T16:02:40Z")

</div>

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