# Need to know which filter is useful in my case?

**URL:** <https://discuss.elastic.co/t/need-to-know-which-filter-is-useful-in-my-case/41415>\
**Category:** Elasticsearch\
**Created:** [February 10, 2016, 6:10pm UTC](https://discuss.elastic.co/t/need-to-know-which-filter-is-useful-in-my-case/41415 "2016-02-10T18:10:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikas\_gopal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikas_gopal/32/47661_2.png) [@vikas\_gopal](https://discuss.elastic.co/u/vikas_gopal)\
**Post date:** [February 10, 2016, 6:10pm UTC](https://discuss.elastic.co/t/need-to-know-which-filter-is-useful-in-my-case/41415/1 "2016-02-10T18:10:15Z")

</div>

Hi Experts,

I have logs and most of them have "baseId" filed in it . But some logs don't have this field at all .I want to search those logs which does not have baseid in it . So out of **exist , Missing** filter , which will be the best option and why ?

Thanks  
VG

---

<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:** [February 10, 2016, 6:24pm UTC](https://discuss.elastic.co/t/need-to-know-which-filter-is-useful-in-my-case/41415/2 "2016-02-10T18:24:10Z")

</div>

IIRC missing will be removed.

So a bool query with a must not clause and exist query should work well.

---

<div class="post-metadata">

**Author:** ![vikas\_gopal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikas_gopal/32/47661_2.png) [@vikas\_gopal](https://discuss.elastic.co/u/vikas_gopal)\
**Post date:** [February 10, 2016, 6:27pm UTC](https://discuss.elastic.co/t/need-to-know-which-filter-is-useful-in-my-case/41415/3 "2016-02-10T18:27:21Z")

</div>

so something like

{ "filter" : {"bool" : {"must\_not" : {"exists":{"field":"baseEventIds"}}}}}

So I will be using must\_not as I want those logs which must not have baseEventids field in it ?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [February 10, 2016, 6:44pm UTC](https://discuss.elastic.co/t/need-to-know-which-filter-is-useful-in-my-case/41415/4 "2016-02-10T18:44:15Z")

</div>

You don't need the `filter` part. Depending on the context that might be a [post\_filter](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-post-filter.html) which isn't really what you want (probably).

If you are in 1.x you'd do a `filtered` query I believe.

---

<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, 11:17pm UTC](https://discuss.elastic.co/t/need-to-know-which-filter-is-useful-in-my-case/41415/5 "2017-07-05T23:17:30Z")

</div>

Closed on July 5, 2017, 11:17pm UTC


