# Missing filter query still returns the field that should be missing

**URL:** <https://discuss.elastic.co/t/missing-filter-query-still-returns-the-field-that-should-be-missing/19913>\
**Category:** Elasticsearch\
**Created:** [September 22, 2014, 2:11pm UTC](https://discuss.elastic.co/t/missing-filter-query-still-returns-the-field-that-should-be-missing/19913 "2014-09-22T14:11:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriel\_Falkenberg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_falkenberg/32/1267_2.png) [@Gabriel\_Falkenberg](https://discuss.elastic.co/u/Gabriel_Falkenberg)\
**Post date:** [September 22, 2014, 2:11pm UTC](https://discuss.elastic.co/t/missing-filter-query-still-returns-the-field-that-should-be-missing/19913/1 "2014-09-22T14:11:02Z")

</div>

Hi!

I'm using ElasticSearch 1.2.1 and have an index with documents of the type  
html-widget. These documents can have (among other things) the property  
contentForMobile. I want to list all html-widget documents without the  
field contentForMobile. I use this query:

curl -XPOST '[http://my-elastic-host:9200/the-index/html-widget/\_search](http://my-elastic-host:9200/the-index/html-widget/_search)' -d  
'{  
"query": {  
"filtered": {  
"filter": {  
"bool": {  
"must": [  
{  
"missing": {  
"field": "contentForMobile"  
}  
}  
]  
}  
}  
}  
}  
}'

But this query returns results that do have contentForMobile set (and I'm  
not talking about null/empty strings but proper string values). I've also  
tried using the query:

{  
"query": {  
"constant\_score": {  
"filter": {  
"missing": {  
"field": "contentForMobile"  
}  
}  
}  
}  
}

With the same result. The field contentForMobile is mapped like this:

{  
"type": "string",  
"analyzer": "string\_untouched",  
"fields": {  
"analyzed": {  
"type": "string",  
"analyzer": "standard"  
},  
"lower": {  
"type": "string",  
"analyzer": "string\_lowercase"  
},  
"swedish": {  
"type": "string",  
"analyzer": "swedish"  
},  
"sort": {  
"type": "string",  
"analyzer": "string\_sort"  
}  
}  
}

I've also tried the exists filter and I can see that there is a difference  
in the result:

Total number of html-widget documents: 434  
Documents missing contentForMobile: 165  
Documents where contentForMobile exists: 269

All documents returned with the exists query does have the property set but  
most documents returned with the missing query also have the property set...

What have I not thought of?

Best regards,  
Gabriel Falkenberg

--  
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/064893ae-784d-4b9e-a5a9-838be7480b49%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/064893ae-784d-4b9e-a5a9-838be7480b49%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, 1:00am UTC](https://discuss.elastic.co/t/missing-filter-query-still-returns-the-field-that-should-be-missing/19913/2 "2017-07-06T01:00:40Z")

</div>


