Default values

Hi there,

Following a question in french mailing list, I didn't succeed in solving the
issue :
<https://groups.google.com/forum/?hl=fr&fromgroups#!topic/elasticsearch-fr/0
CfnLIoODDI>
https://groups.google.com/forum/?hl=fr&fromgroups#!topic/elasticsearch-fr/0C
fnLIoODDI

Problem is that null_value in mapping definition doesn't work as expected.

Curl recreation is here : https://gist.github.com/2145457

So we define a mapping here :

curl -XPUT $ES/$ESIDX/$ESTYPE/_mapping -d '{

"test" : {

"properties" : {

  "objectifs" : {"type" : "string", "null_value":"na"}

}

}

}'

Then we send a document :

curl -XPUT $ES/$ESIDX/$ESTYPE/1 -d '{
"objectifs" : null
}'

We should get something like "objectifs" : "na" but we get null:

{

"_index" : "test3",

"_type" : "test",

"_id" : "1",

"_version" : 1,

"exists" : true, "_source" : {

            "objectifs" : null

}

}

What's wrong ?

Thanks,
David.

Hiya

Following a question in french mailing list, I didn’t succeed in
solving the issue :
Rediriger vers Google Groupes!
topic/elasticsearch-fr/0CfnLIoODDI

Problem is that null_value in mapping definition doesn’t work as
expected.

Your expectation is incorrect :slight_smile:

Specifying a null value doesn't change the _source field. It just
specifies a value to index instead of 'null'.

I think there is no need to use the null_value parameter any more, now
that we have the 'existing' and 'missing' filters.

clint

Curl recreation is here : ES : Trying to play with default values · GitHub

So we define a mapping here :

curl -XPUT $ES/$ESIDX/$ESTYPE/_mapping -d '{

"test" : {

"properties" : {

  "objectifs" : {"type" : "string", "null_value":"na"}

}

}

}'

Then we send a document :

curl -XPUT $ES/$ESIDX/$ESTYPE/1 -d '{
"objectifs" : null
}'

We should get something like “objectifs” : “na” but we get null:

{

"_index" : "test3",

"_type" : "test",

"_id" : "1",

"_version" : 1,

"exists" : true, "_source" : {

            "objectifs" : null

}

}

What’s wrong ?

Thanks,
David.

Your expectation is incorrect :slight_smile:

Specifying a null value doesn't change the _source field. It just
specifies a value to index instead of 'null'.
Thanks ! Very clear now !!!
Of course, ES can't change my source doc !

I think there is no need to use the null_value parameter any more, now
that we have the 'existing' and 'missing' filters.
Yes. For sure !
But this is not my use case :wink:

Thanks for your help Clint !
Cheers