# Filter For Field = Null

**URL:** <https://discuss.elastic.co/t/filter-for-field-null/4011>\
**Category:** Elasticsearch\
**Created:** [March 2, 2011, 2:45am UTC](https://discuss.elastic.co/t/filter-for-field-null/4011 "2011-03-02T02:45:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![timscott](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timscott/32/3220_2.png) [@timscott](https://discuss.elastic.co/u/timscott)\
**Post date:** [March 2, 2011, 2:45am UTC](https://discuss.elastic.co/t/filter-for-field-null/4011/1 "2011-03-02T02:45:31Z")

</div>

What's the expected behavior of the MissingFilter when applied to a  
(non-analyzed) field is present but with a null value? I am finding  
that documents with null values are returned (missing filter not  
applied). I tried instead to use the TermFilter with a null value,  
but ES choked on that.

How can I filter for a certain non analyzed field = null? I had  
solved this before with a wildcard query, but it's much better for me  
to use a filter if I can. Thanks.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 2, 2011, 3:15am UTC](https://discuss.elastic.co/t/filter-for-field-null/4011/2 "2011-03-02T03:15:47Z")

</div>

Can you gist a curl recreation where the missing filter is not working?  
On Wednesday, March 2, 2011 at 4:45 AM, Tim Scott wrote:

> What's the expected behavior of the MissingFilter when applied to a  
> (non-analyzed) field is present but with a null value? I am finding  
> that documents with null values are returned (missing filter not  
> applied). I tried instead to use the TermFilter with a null value,  
> but ES choked on that.
> 
> How can I filter for a certain non analyzed field = null? I had  
> solved this before with a wildcard query, but it's much better for me  
> to use a filter if I can. Thanks.

---

<div class="post-metadata">

**Author:** ![timscott](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timscott/32/3220_2.png) [@timscott](https://discuss.elastic.co/u/timscott)\
**Post date:** [March 2, 2011, 1:50pm UTC](https://discuss.elastic.co/t/filter-for-field-null/4011/3 "2011-03-02T13:50:17Z")

</div>

My mistake. The data was not what I thought it was. However, in the  
same query I am having trouble with the prefix filter. I will open a  
new topic with that question and create a gist for it.

On Mar 1, 9:15 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Can you gist a curl recreation where the missing filter is not working?
> 
> On Wednesday, March 2, 2011 at 4:45 AM, Tim Scott wrote:
> 
> > What's the expected behavior of the MissingFilter when applied to a  
> > (non-analyzed) field is present but with a null value? I am finding  
> > that documents with null values are returned (missing filter not  
> > applied). I tried instead to use the TermFilter with a null value,  
> > but ES choked on that.
> 
> > How can I filter for a certain non analyzed field = null? I had  
> > solved this before with a wildcard query, but it's much better for me  
> > to use a filter if I can. 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, 4:11am UTC](https://discuss.elastic.co/t/filter-for-field-null/4011/4 "2017-07-06T04:11:00Z")

</div>


