# Default value for field in mapping when not present during indexing

**URL:** <https://discuss.elastic.co/t/default-value-for-field-in-mapping-when-not-present-during-indexing/89771>\
**Category:** Elasticsearch\
**Created:** [June 16, 2017, 8:39pm UTC](https://discuss.elastic.co/t/default-value-for-field-in-mapping-when-not-present-during-indexing/89771 "2017-06-16T20:39:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pushshift](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pushshift/32/50408_2.png) [@pushshift](https://discuss.elastic.co/u/pushshift)\
**Post date:** [June 16, 2017, 8:39pm UTC](https://discuss.elastic.co/t/default-value-for-field-in-mapping-when-not-present-during-indexing/89771/1 "2017-06-16T20:39:46Z")

</div>

I would like to set a default value of 0 for an integer field if the key/value is not present when doing an index or bulk index. I tried using "null\_value" : 0 in my mapping, but that doesn't appear to handle missing key/values during indexing.

Is there something like a default\_value for mapping?

---

<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 14, 2017, 8:39pm UTC](https://discuss.elastic.co/t/default-value-for-field-in-mapping-when-not-present-during-indexing/89771/2 "2017-07-14T20:39:49Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
