# How could I have MySQL IN clause within my elasticsearch query?

**URL:** https://discuss.elastic.co/t/how-could-i-have-mysql-in-clause-within-my-elasticsearch-query/61764
**Category:** Elasticsearch
**Created:** [September 29, 2016, 5:22am UTC](https://discuss.elastic.co/t/how-could-i-have-mysql-in-clause-within-my-elasticsearch-query/61764 "2016-09-29T05:22:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Kulasangar\_Gowrisang](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@Kulasangar\_Gowrisang](https://discuss.elastic.co/u/Kulasangar_Gowrisang)
#### Post date: [September 29, 2016, 5:22am UTC](https://discuss.elastic.co/t/how-could-i-have-mysql-in-clause-within-my-elasticsearch-query/61764/1 "2016-09-29T05:22:54Z")

</div>

I'm trying perform an elasticsearch query as a GET request in order pull data from the index which I created. The data which is in the index is, a table from MySQL DB, configured though logstash.

Here is my request without the IN clause:

**[http://localhost:9200/response\_summary/\_search?q=myquery](http://localhost:9200/response_summary/_search?q=myquery)**

In the above, I should be able to append `AND responseCode IN (401,403)`. I tried giving it a search on the web, but couldn't find any solutions.

Any help could be appreaciated.

---

<div class="post-metadata">

### Author: ![Kulasangar\_Gowrisang](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@Kulasangar\_Gowrisang](https://discuss.elastic.co/u/Kulasangar_Gowrisang)
#### Post date: [September 29, 2016, 5:32am UTC](https://discuss.elastic.co/t/how-could-i-have-mysql-in-clause-within-my-elasticsearch-query/61764/2 "2016-09-29T05:32:41Z")

</div>

Found the solution, I've appended it at the end:

**[http://localhost:9200/response\_summary/\_search?q=myquery+responsecode:(401+404)](http://localhost:9200/response_summary/_search?q=myquery+responsecode:(401+404))**

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [September 29, 2016, 6:19am UTC](https://discuss.elastic.co/t/how-could-i-have-mysql-in-clause-within-my-elasticsearch-query/61764/3 "2016-09-29T06:19:07Z")

</div>

I'd recommend using the query DSL instead.  
You can clearly express what you want to do.

---

<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: [July 5, 2017, 10:16pm UTC](https://discuss.elastic.co/t/how-could-i-have-mysql-in-clause-within-my-elasticsearch-query/61764/4 "2017-07-05T22:16:16Z")

</div>


