# Default values

**URL:** <https://discuss.elastic.co/t/default-values/7078>\
**Category:** Elasticsearch\
**Created:** [March 21, 2012, 7:28am UTC](https://discuss.elastic.co/t/default-values/7078 "2012-03-21T07:28:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 21, 2012, 7:28am UTC](https://discuss.elastic.co/t/default-values/7078/1 "2012-03-21T07:28:45Z")

</div>

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](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](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](https://gist.github.com/2145457)

> <https://gist.github.com/dadoonet/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.

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [March 21, 2012, 7:52am UTC](https://discuss.elastic.co/t/default-values/7078/2 "2012-03-21T07:52:36Z")

</div>

Hiya

> Following a question in french mailing list, I didnât succeed in  
> solving the issue :  
> [Rediriger vers Google&nbsp;Groupes](https://groups.google.com/forum/?hl=fr&fromgroups#)!  
> topic/elasticsearch-fr/0CfnLIoODDI
> 
> Problem is that null\_value in mapping definition doesnât work as  
> expected.

Your expectation is incorrect 🙂

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](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.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 21, 2012, 8:03am UTC](https://discuss.elastic.co/t/default-values/7078/3 "2012-03-21T08:03:05Z")

</div>

> Your expectation is incorrect 🙂
> 
> 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 😉

Thanks for your help Clint !  
Cheers

---

<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, 3:35am UTC](https://discuss.elastic.co/t/default-values/7078/4 "2017-07-06T03:35:19Z")

</div>


