# Does there exists an exists query

**URL:** <https://discuss.elastic.co/t/does-there-exists-an-exists-query/20670>\
**Category:** Elasticsearch\
**Created:** [November 10, 2014, 5:54pm UTC](https://discuss.elastic.co/t/does-there-exists-an-exists-query/20670 "2014-11-10T17:54:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Volker](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@Volker](https://discuss.elastic.co/u/Volker)\
**Post date:** [November 10, 2014, 5:54pm UTC](https://discuss.elastic.co/t/does-there-exists-an-exists-query/20670/1 "2014-11-10T17:54:41Z")

</div>

I would like to know whether there is an exists query in ES.

I know that there is an exists filter, but I would like to have an exists  
query. So documents, where a field exists, should be rated higher than the  
ones, where the field does not exists. But if there is no document in that  
query, where the field exists, it should still return the other documents.  
This would not work with the exists filter, as far as I know.

I know, that I could index an additional field, with the value (e.g.) true,  
when the field exists. But I would rather not have this additional data in  
the index.

So, what is the best solution for this use case?

thanks in advance!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e82e64a1-53d7-4067-9a91-ce77fda8c85f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e82e64a1-53d7-4067-9a91-ce77fda8c85f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [November 10, 2014, 6:12pm UTC](https://discuss.elastic.co/t/does-there-exists-an-exists-query/20670/2 "2014-11-10T18:12:43Z")

</div>

Off the top of my head, the easiest option would be to use a constant score  
query. Wrap the original query and provide a boost to documents that  
satisfy your exist filter.

Cheers,

Ivan

On Mon, Nov 10, 2014 at 12:54 PM, Volker [svs@klest.de](mailto:svs@klest.de) wrote:

> I would like to know whether there is an exists query in ES.
> 
> I know that there is an exists filter, but I would like to have an exists  
> query. So documents, where a field exists, should be rated higher than the  
> ones, where the field does not exists. But if there is no document in that  
> query, where the field exists, it should still return the other documents.  
> This would not work with the exists filter, as far as I know.
> 
> I know, that I could index an additional field, with the value (e.g.)  
> true, when the field exists. But I would rather not have this additional  
> data in the index.
> 
> So, what is the best solution for this use case?
> 
> thanks in advance!
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/e82e64a1-53d7-4067-9a91-ce77fda8c85f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e82e64a1-53d7-4067-9a91-ce77fda8c85f%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/e82e64a1-53d7-4067-9a91-ce77fda8c85f%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/e82e64a1-53d7-4067-9a91-ce77fda8c85f%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQDjKdKh7GquS%3DvND0vTbfmYGwF4bqLy16MSXCnCeJR2-w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQDjKdKh7GquS%3DvND0vTbfmYGwF4bqLy16MSXCnCeJR2-w%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Volker](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@Volker](https://discuss.elastic.co/u/Volker)\
**Post date:** [November 21, 2014, 3:46pm UTC](https://discuss.elastic.co/t/does-there-exists-an-exists-query/20670/3 "2014-11-21T15:46:35Z")

</div>

Hello Ivan

thank you very much for your suggestion. I will try this!

Kind regards

Am Montag, 10. November 2014 19:13:43 UTC+1 schrieb Ivan Brusic:

> Off the top of my head, the easiest option would be to use a constant  
> score query. Wrap the original query and provide a boost to documents that  
> satisfy your exist filter.
> 
> Cheers,
> 
> Ivan
> 
> On Mon, Nov 10, 2014 at 12:54 PM, Volker \<[s...@klest.de](mailto:s...@klest.de) \<javascript:\>\>  
> wrote:
> 
> > I would like to know whether there is an exists query in ES.
> > 
> > I know that there is an exists filter, but I would like to have an exists  
> > query. So documents, where a field exists, should be rated higher than the  
> > ones, where the field does not exists. But if there is no document in that  
> > query, where the field exists, it should still return the other documents.  
> > This would not work with the exists filter, as far as I know.
> > 
> > I know, that I could index an additional field, with the value (e.g.)  
> > true, when the field exists. But I would rather not have this additional  
> > data in the index.
> > 
> > So, what is the best solution for this use case?
> > 
> > thanks in advance!
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/e82e64a1-53d7-4067-9a91-ce77fda8c85f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e82e64a1-53d7-4067-9a91-ce77fda8c85f%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/e82e64a1-53d7-4067-9a91-ce77fda8c85f%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/e82e64a1-53d7-4067-9a91-ce77fda8c85f%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8b5a31b0-b3ee-4b82-991d-d85436793327%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8b5a31b0-b3ee-4b82-991d-d85436793327%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:48am UTC](https://discuss.elastic.co/t/does-there-exists-an-exists-query/20670/4 "2017-07-06T00:48:25Z")

</div>


