# Querying in ES with SQL IN equivalent

**URL:** https://discuss.elastic.co/t/querying-in-es-with-sql-in-equivalent/6932
**Category:** Elasticsearch
**Created:** [March 7, 2012, 3:36pm UTC](https://discuss.elastic.co/t/querying-in-es-with-sql-in-equivalent/6932 "2012-03-07T15:36:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![vannya](https://avatars.discourse-cdn.com/v4/letter/v/e495f1/32.png) [@vannya](https://discuss.elastic.co/u/vannya)
#### Post date: [March 7, 2012, 3:36pm UTC](https://discuss.elastic.co/t/querying-in-es-with-sql-in-equivalent/6932/1 "2012-03-07T15:36:34Z")

</div>

Hi all,

I would like to search in my ES index all name fields with values  
within a list of - as example - ('name1', 'name2', 'name3').  
However, I cannot find a simple way to do it! I could use "or"... but  
as my list of names grows with time, I could end up doing "or's" with  
a huge list of millions!

What I really want is to be able to do something like SQL "IN"  
keyword...

Does anyone knows a simpler way to do this?

Thanks in advance!

---

<div class="post-metadata">

### Author: ![vannya](https://avatars.discourse-cdn.com/v4/letter/v/e495f1/32.png) [@vannya](https://discuss.elastic.co/u/vannya)
#### Post date: [March 7, 2012, 4:15pm UTC](https://discuss.elastic.co/t/querying-in-es-with-sql-in-equivalent/6932/2 "2012-03-07T16:15:29Z")

</div>

Hi!

I found the solution here:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

And, then, testing:

curl -XGET [http://localhost:9200/my\_index/my\_type/\_search](http://localhost:9200/my_index/my_type/_search) -d '{  
"query" : {  
"in" : {  
"name" : ["name1", "name2"]  
}  
}  
}'

I only got the 2 documents I was searching for!

It's solved!

On Wednesday, March 7, 2012 3:36:34 PM UTC, Vania S. wrote:

> Hi all,
> 
> I would like to search in my ES index all name fields with values  
> within a list of - as example - ('name1', 'name2', 'name3').  
> However, I cannot find a simple way to do it! I could use "or"... but  
> as my list of names grows with time, I could end up doing "or's" with  
> a huge list of millions!
> 
> What I really want is to be able to do something like SQL "IN"  
> keyword...
> 
> Does anyone knows a simpler way to do this?
> 
> Thanks in advance!

---

<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 6, 2017, 3:36am UTC](https://discuss.elastic.co/t/querying-in-es-with-sql-in-equivalent/6932/3 "2017-07-06T03:36:49Z")

</div>


