# Exists query?

**URL:** https://discuss.elastic.co/t/exists-query/8254
**Category:** Elasticsearch
**Created:** [June 28, 2012, 2:49pm UTC](https://discuss.elastic.co/t/exists-query/8254 "2012-06-28T14:49:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![T\_Vinod\_Gupta](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@T\_Vinod\_Gupta](https://discuss.elastic.co/u/T_Vinod_Gupta)
#### Post date: [June 28, 2012, 2:49pm UTC](https://discuss.elastic.co/t/exists-query/8254/1 "2012-06-28T14:49:36Z")

</div>

hi,  
is there a query equivalent for exists filter in ES? i want to create a  
query to check for the absence of a field in the document. i can't use  
filter since i want to put it inside a query and add it to the percolator.

how do i achieve this, any ideas?

thanks

---

<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: [June 28, 2012, 3:20pm UTC](https://discuss.elastic.co/t/exists-query/8254/2 "2012-06-28T15:20:37Z")

</div>

Did you look at the missing filter ?

David 😉  
Twitter : @dadoonet / @elasticsearchfr

Le 28 juin 2012 à 16:49, T Vinod Gupta [tvinod@readypulse.com](mailto:tvinod@readypulse.com) a écrit :

> hi,  
> is there a query equivalent for exists filter in ES? i want to create a query to check for the absence of a field in the document. i can't use filter since i want to put it inside a query and add it to the percolator.
> 
> how do i achieve this, any ideas?
> 
> thanks

---

<div class="post-metadata">

### Author: ![T\_Vinod\_Gupta](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@T\_Vinod\_Gupta](https://discuss.elastic.co/u/T_Vinod_Gupta)
#### Post date: [June 28, 2012, 3:24pm UTC](https://discuss.elastic.co/t/exists-query/8254/3 "2012-06-28T15:24:40Z")

</div>

im looking at java api here.. i couldnt find anything relevant in  
QueryBuilders. did i miss something?

thanks

On Thu, Jun 28, 2012 at 8:20 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Did you look at the missing filter ?
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr
> 
> Le 28 juin 2012 à 16:49, T Vinod Gupta [tvinod@readypulse.com](mailto:tvinod@readypulse.com) a écrit :
> 
> > hi,  
> > is there a query equivalent for exists filter in ES? i want to create a  
> > query to check for the absence of a field in the document. i can't use  
> > filter since i want to put it inside a query and add it to the percolator.
> > 
> > how do i achieve this, any ideas?
> > 
> > thanks

---

<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: [June 28, 2012, 3:29pm UTC](https://discuss.elastic.co/t/exists-query/8254/4 "2012-06-28T15:29:00Z")

</div>

It's a filter. Use a filteredQuery with a matchAllQuery as the Query and a missingFilter as a Filter.

It should work.

Does it help ?

David 😉  
Twitter : @dadoonet / @elasticsearchfr

Le 28 juin 2012 à 17:24, T Vinod Gupta [tvinod@readypulse.com](mailto:tvinod@readypulse.com) a écrit :

> im looking at java api here.. i couldnt find anything relevant in QueryBuilders. did i miss something?
> 
> thanks
> 
> On Thu, Jun 28, 2012 at 8:20 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
> Did you look at the missing filter ?
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr
> 
> Le 28 juin 2012 à 16:49, T Vinod Gupta [tvinod@readypulse.com](mailto:tvinod@readypulse.com) a écrit :
> 
> > hi,  
> > is there a query equivalent for exists filter in ES? i want to create a query to check for the absence of a field in the document. i can't use filter since i want to put it inside a query and add it to the percolator.
> > 
> > how do i achieve this, any ideas?
> > 
> > thanks

---

<div class="post-metadata">

### Author: ![T\_Vinod\_Gupta](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@T\_Vinod\_Gupta](https://discuss.elastic.co/u/T_Vinod_Gupta)
#### Post date: [June 28, 2012, 5:58pm UTC](https://discuss.elastic.co/t/exists-query/8254/5 "2012-06-28T17:58:26Z")

</div>

i think that sounds correct.. yet to test it though.

thanks!

On Thu, Jun 28, 2012 at 8:29 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> It's a filter. Use a filteredQuery with a matchAllQuery as the Query and a  
> missingFilter as a Filter.
> 
> It should work.
> 
> Does it help ?
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr
> 
> Le 28 juin 2012 à 17:24, T Vinod Gupta [tvinod@readypulse.com](mailto:tvinod@readypulse.com) a écrit :
> 
> im looking at java api here.. i couldnt find anything relevant in  
> QueryBuilders. did i miss something?
> 
> thanks
> 
> On Thu, Jun 28, 2012 at 8:20 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:
> 
> > Did you look at the missing filter ?
> > 
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr
> > 
> > Le 28 juin 2012 à 16:49, T Vinod Gupta [tvinod@readypulse.com](mailto:tvinod@readypulse.com) a écrit :
> > 
> > > hi,  
> > > is there a query equivalent for exists filter in ES? i want to create a  
> > > query to check for the absence of a field in the document. i can't use  
> > > filter since i want to put it inside a query and add it to the percolator.
> > > 
> > > how do i achieve this, any ideas?
> > > 
> > > thanks

---

<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:22am UTC](https://discuss.elastic.co/t/exists-query/8254/6 "2017-07-06T03:22:08Z")

</div>


