# How can we use exists query in tandem with the search query in Elasticsearch

**URL:** <https://discuss.elastic.co/t/how-can-we-use-exists-query-in-tandem-with-the-search-query-in-elasticsearch/71204>\
**Category:** Elasticsearch\
**Created:** [January 11, 2017, 10:42am UTC](https://discuss.elastic.co/t/how-can-we-use-exists-query-in-tandem-with-the-search-query-in-elasticsearch/71204 "2017-01-11T10:42:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashit\_pupu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashit_pupu/32/101113_2.png) [@ashit\_pupu](https://discuss.elastic.co/u/ashit_pupu)\
**Post date:** [January 11, 2017, 10:42am UTC](https://discuss.elastic.co/t/how-can-we-use-exists-query-in-tandem-with-the-search-query-in-elasticsearch/71204/1 "2017-01-11T10:42:38Z")

</div>

I have a scenario in Elasticsearch where my indexed docs are like this :-

```
{"id":1,"name":"xyz", "address": "xyz123"}
{"id":1,"name":"xyz", "address": "xyz123"}
{"id":1,"name":"xyz", "address": "xyz123", "note": "imp"}

```

Here the requirement stress that we have to do a term match query and then provide relevance score to them which is a straight forward thing but the additional aspect here is if any doc found in search result has note field then it should be given higher relevance. How can we achieve it with DSL query? Using **exists** we can check which docs contain notes but how to integrate with **match** query in ES query. Have tried lot of ways but none worked. Any help will be appreciated.

Thanks  
Ashit

---

<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:** [February 8, 2017, 10:42am UTC](https://discuss.elastic.co/t/how-can-we-use-exists-query-in-tandem-with-the-search-query-in-elasticsearch/71204/2 "2017-02-08T10:42:49Z")

</div>

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