# Converting a SQL query to Elastic Query

**URL:** <https://discuss.elastic.co/t/converting-a-sql-query-to-elastic-query/148202>\
**Category:** Elasticsearch\
**Created:** [September 11, 2018, 6:50pm UTC](https://discuss.elastic.co/t/converting-a-sql-query-to-elastic-query/148202 "2018-09-11T18:50:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![premieredigital](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/premieredigital/32/26987_2.png) [@premieredigital](https://discuss.elastic.co/u/premieredigital)\
**Post date:** [September 11, 2018, 6:50pm UTC](https://discuss.elastic.co/t/converting-a-sql-query-to-elastic-query/148202/1 "2018-09-11T18:50:36Z")

</div>

I have the following SQL query that I'm looking to convert to ES:

```
UPDATE _index 
SET is_hidden = False
WHERE transaction_guid='XXX'

```

Is the following the closest equivalent?

```
body = {
  "script": {
    "lang": "painless",
    "inline": "ctx._source.is_hidden=false"
  },

  "query": {
    "match": {
      "transaction_guid": "XXX"
    }
  }
}

>>> self.es.update_by_query(body=body, doc_type='_doc', index='_index')

```

If not, what would be the preferred way to do the above?

---

<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:** [October 9, 2018, 6:50pm UTC](https://discuss.elastic.co/t/converting-a-sql-query-to-elastic-query/148202/2 "2018-10-09T18:50:40Z")

</div>

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