# Deleting documents that are missing fields

**URL:** <https://discuss.elastic.co/t/deleting-documents-that-are-missing-fields/18237>\
**Category:** Elasticsearch\
**Created:** [June 20, 2014, 7:13pm UTC](https://discuss.elastic.co/t/deleting-documents-that-are-missing-fields/18237 "2014-06-20T19:13:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Dupont](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeff_dupont/32/1355_2.png) [@Jeff\_Dupont](https://discuss.elastic.co/u/Jeff_Dupont)\
**Post date:** [June 20, 2014, 7:13pm UTC](https://discuss.elastic.co/t/deleting-documents-that-are-missing-fields/18237/1 "2014-06-20T19:13:56Z")

</div>

I can easily query for documents that are missing a particular term field,  
however I'd like to free up that space and remove those documents. I've  
tried this with no luck:

DELETE /my\_index/pages/\_search  
{  
"filter" : {  
"missing" : {  
"field" : "sentences",  
"existence" : true,  
"null\_value" : true  
}  
}  
}

It works fine to find them, but i can't find an easy way to remove them and  
I have about 2million to remove as well.

--  
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/c2d41bfb-145d-402e-a5aa-2f0329278bd9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c2d41bfb-145d-402e-a5aa-2f0329278bd9%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:** [June 20, 2014, 8:17pm UTC](https://discuss.elastic.co/t/deleting-documents-that-are-missing-fields/18237/2 "2014-06-20T20:17:26Z")

</div>

I do not use delete by query, but have you tried using a fully formed query  
and not just a filter? Perhaps an implicit match\_all query is not being  
set. Try using a filtered query with a match\_all query and your filter.

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

--  
Ivan

On Fri, Jun 20, 2014 at 12:13 PM, Jeff Dupont [jeff.dupont@gmail.com](mailto:jeff.dupont@gmail.com) wrote:

> I can easily query for documents that are missing a particular term field,  
> however I'd like to free up that space and remove those documents. I've  
> tried this with no luck:
> 
> DELETE /my\_index/pages/\_search  
> {  
> "filter" : {  
> "missing" : {  
> "field" : "sentences",  
> "existence" : true,  
> "null\_value" : true  
> }  
> }  
> }
> 
> It works fine to find them, but i can't find an easy way to remove them  
> and I have about 2million to remove as well.
> 
> --  
> 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/c2d41bfb-145d-402e-a5aa-2f0329278bd9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c2d41bfb-145d-402e-a5aa-2f0329278bd9%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/c2d41bfb-145d-402e-a5aa-2f0329278bd9%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/c2d41bfb-145d-402e-a5aa-2f0329278bd9%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%3DcQCguLamXCnrtV-bA-Ed03pGdB%2BVMrAt5-CYkqkvfnDaGw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQCguLamXCnrtV-bA-Ed03pGdB%2BVMrAt5-CYkqkvfnDaGw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Jeff\_Dupont](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeff_dupont/32/1355_2.png) [@Jeff\_Dupont](https://discuss.elastic.co/u/Jeff_Dupont)\
**Post date:** [June 21, 2014, 2:58pm UTC](https://discuss.elastic.co/t/deleting-documents-that-are-missing-fields/18237/3 "2014-06-21T14:58:48Z")

</div>

I tried the filter on the match\_all and it doesn't seem to find the results.

DELETE /my\_index/pages/\_search  
{  
"filtered": {  
"match\_all": {},  
"filter": {  
"missing": {  
"field": "sentences",  
"existence": true,  
"null\_value": true  
}  
}  
}  
}

--  
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/b9944c98-88c0-41f8-9dfa-fd268353caad%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b9944c98-88c0-41f8-9dfa-fd268353caad%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Jeff\_Dupont](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeff_dupont/32/1355_2.png) [@Jeff\_Dupont](https://discuss.elastic.co/u/Jeff_Dupont)\
**Post date:** [June 21, 2014, 3:04pm UTC](https://discuss.elastic.co/t/deleting-documents-that-are-missing-fields/18237/4 "2014-06-21T15:04:53Z")

</div>

I finally got it!! Thanks to this  
thread [https://groups.google.com/forum/#!topic/elasticsearch/Eb5ERjHXp4Y](https://groups.google.com/forum/#!topic/elasticsearch/Eb5ERjHXp4Y).  
The syntax has changed where it now requires that the whole be wrapped by a  
query property.

"query": {  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"missing": {  
"field": "sentences",  
"existence": true,  
"null\_value": true  
}  
}  
}  
}

--  
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/01502f85-eaf4-4433-9af4-553746cd641c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/01502f85-eaf4-4433-9af4-553746cd641c%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:** [June 21, 2014, 9:10pm UTC](https://discuss.elastic.co/t/deleting-documents-that-are-missing-fields/18237/5 "2014-06-21T21:10:29Z")

</div>

Yes, that was what I meant by fully formed query. I leave nothing to chance.

--  
Ivan  
On Jun 21, 2014 8:04 AM, "Jeff Dupont" [jeff.dupont@gmail.com](mailto:jeff.dupont@gmail.com) wrote:

> I finally got it!! Thanks to this thread  
> [Redirecting to Google Groups](https://groups.google.com/forum/#!topic/elasticsearch/Eb5ERjHXp4Y). The  
> syntax has changed where it now requires that the whole be wrapped by a  
> query property.
> 
> "query": {  
> "filtered": {  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "missing": {  
> "field": "sentences",  
> "existence": true,  
> "null\_value": true  
> }  
> }  
> }  
> }
> 
> --  
> 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/01502f85-eaf4-4433-9af4-553746cd641c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/01502f85-eaf4-4433-9af4-553746cd641c%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/01502f85-eaf4-4433-9af4-553746cd641c%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/01502f85-eaf4-4433-9af4-553746cd641c%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%3DcQDn%2B4hb%3DnL-M6kvG7NRxr7x0oz4V61-GosZNUC3y77u6g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQDn%2B4hb%3DnL-M6kvG7NRxr7x0oz4V61-GosZNUC3y77u6g%40mail.gmail.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:20am UTC](https://discuss.elastic.co/t/deleting-documents-that-are-missing-fields/18237/6 "2017-07-06T01:20:46Z")

</div>


