# Missing Fields

**URL:** <https://discuss.elastic.co/t/missing-fields/4603>\
**Category:** Elasticsearch\
**Created:** [June 10, 2011, 3:47pm UTC](https://discuss.elastic.co/t/missing-fields/4603 "2011-06-10T15:47:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Cook](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@James\_Cook](https://discuss.elastic.co/u/James_Cook)\
**Post date:** [June 10, 2011, 3:47pm UTC](https://discuss.elastic.co/t/missing-fields/4603/1 "2011-06-10T15:47:48Z")

</div>

How will the "missing" filter be applied in the following cases:

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

1. Doc1 = { firstName: "Ted" }
2. Doc2 = { name: null }
3. Doc3 = { name: undefined }
4. Doc4 = { name: "" }

---

<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:** [June 12, 2011, 7:24am UTC](https://discuss.elastic.co/t/missing-fields/4603/2 "2011-06-12T07:24:53Z")

</div>

The null and empty string will qualify as missing (since they produced no terms). Not sure about the undefined since it depends on the client lib and what json it produces.

On Friday, June 10, 2011 at 6:47 PM, James Cook wrote:

> How will the "missing" filter be applied in the following cases:
> 
> {  
> "query":{  
> "constant\_score" : {  
> "filter" : {  
> "missing" :{  
> "field" :"name"  
> }  
> }  
> }  
> }  
> }
> 
> Doc1 = { firstName: "Ted" }  
> Doc2 = { name: null }  
> Doc3 = { name: undefined }  
> Doc4 = { name: "" }

---

<div class="post-metadata">

**Author:** ![James\_Cook\_2](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@James\_Cook\_2](https://discuss.elastic.co/u/James_Cook_2)\
**Post date:** [June 12, 2011, 11:55pm UTC](https://discuss.elastic.co/t/missing-fields/4603/3 "2011-06-12T23:55:42Z")

</div>

So, the follow up would be to inquire whether there is any way to query for an empty string value?

Sent from my iPad

On Jun 12, 2011, at 3:24 AM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:

> The null and empty string will qualify as missing (since they produced no terms). Not sure about the undefined since it depends on the client lib and what json it produces.  
> On Friday, June 10, 2011 at 6:47 PM, James Cook wrote:
> 
> > How will the "missing" filter be applied in the following cases:
> > 
> > {  
> > "query":{  
> > "constant\_score" : {  
> > "filter" : {  
> > "missing" :{  
> > "field" :"name"  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > Doc1 = { firstName: "Ted" }  
> > Doc2 = { name: null }  
> > Doc3 = { name: undefined }  
> > Doc4 = { name: "" }

---

<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:** [June 13, 2011, 12:10am UTC](https://discuss.elastic.co/t/missing-fields/4603/4 "2011-06-13T00:10:12Z")

</div>

There isn't a way to check for an empty string value. You can knindda hack it, by providing null-value in the mappings, and then, use that null-value to check for cases where the field is explicitly set to null, and missing when the field has an empty string or missing completely. For string fields, we can add an enhancement to support empty-value mapping (different than null-value).

On Monday, June 13, 2011 at 2:59 AM, James Cook wrote:

> So, the follow up would be to inquire whether there is any way to query for an empty string value?
> 
> Sent from my iPad
> 
> On Jun 12, 2011, at 3:24 AM, Shay Banon \<[shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) ([mailto:shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com))\> wrote:
> 
> > The null and empty string will qualify as missing (since they produced no terms). Not sure about the undefined since it depends on the client lib and what json it produces.
> > 
> > On Friday, June 10, 2011 at 6:47 PM, James Cook wrote:
> > 
> > > How will the "missing" filter be applied in the following cases:
> > > 
> > > {  
> > > "query":{  
> > > "constant\_score" : {  
> > > "filter" : {  
> > > "missing" :{  
> > > "field" :"name"  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > Doc1 = { firstName: "Ted" }  
> > > Doc2 = { name: null }  
> > > Doc3 = { name: undefined }  
> > > Doc4 = { name: "" }

---

<div class="post-metadata">

**Author:** ![James\_Cook](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@James\_Cook](https://discuss.elastic.co/u/James_Cook)\
**Post date:** [June 13, 2011, 5:26pm UTC](https://discuss.elastic.co/t/missing-fields/4603/5 "2011-06-13T17:26:44Z")

</div>

I added this issue:

> <https://github.com/elastic/elasticsearch/issues/1027>
>
> Add an enhancement to support empty-value mapping (different than null-value) fo…r String fields.

thanks

On Sun, Jun 12, 2011 at 8:10 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> There isn't a way to check for an empty string value. You can knindda  
> hack it, by providing null-value in the mappings, and then, use that  
> null-value to check for cases where the field is explicitly set to null, and  
> missing when the field has an empty string or missing completely. For string  
> fields, we can add an enhancement to support empty-value mapping (different  
> than null-value).
> 
> On Monday, June 13, 2011 at 2:59 AM, James Cook wrote:
> 
> So, the follow up would be to inquire whether there is any way to query for  
> an empty string value?
> 
> Sent from my iPad
> 
> On Jun 12, 2011, at 3:24 AM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)  
> wrote:
> 
> The null and empty string will qualify as missing (since they produced no  
> terms). Not sure about the undefined since it depends on the client lib and  
> what json it produces.
> 
> On Friday, June 10, 2011 at 6:47 PM, James Cook wrote:
> 
> How will the "missing" filter be applied in the following cases:
> 
> {  
> "query":{  
> "constant\_score" : {  
> "filter" : {  
> "missing" :{  
> "field" :"name"  
> }  
> }  
> }  
> }  
> }
> 
> 1. Doc1 = { firstName: "Ted" }
> 2. Doc2 = { name: null }
> 3. Doc3 = { name: undefined }
> 4. Doc4 = { name: "" }

---

<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:03am UTC](https://discuss.elastic.co/t/missing-fields/4603/6 "2017-07-06T04:03:44Z")

</div>


