Missing Fields


(James Cook) #1

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: "" }

(Shay Banon) #2

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: "" }


(James Cook-2) #3

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 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: "" }


(Shay Banon) #4

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"
}
}
}
}
}

Doc1 = { firstName: "Ted" }
Doc2 = { name: null }
Doc3 = { name: undefined }
Doc4 = { name: "" }


(James Cook) #5

I added this issue:

thanks

On Sun, Jun 12, 2011 at 8:10 PM, Shay Banon shay.banon@elasticsearch.comwrote:

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
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: "" }

(system) #6