# Mapper\_parsing\_exception set value by default

**URL:** <https://discuss.elastic.co/t/mapper-parsing-exception-set-value-by-default/61617>\
**Category:** Elasticsearch\
**Created:** [September 27, 2016, 2:34pm UTC](https://discuss.elastic.co/t/mapper-parsing-exception-set-value-by-default/61617 "2016-09-27T14:34:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![minniek](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@minniek](https://discuss.elastic.co/u/minniek)\
**Post date:** [September 27, 2016, 2:34pm UTC](https://discuss.elastic.co/t/mapper-parsing-exception-set-value-by-default/61617/1 "2016-09-27T14:34:49Z")

</div>

I am looking for some script or configuration in order to set a value of a field after an error appears. In my case mapper\_parsing\_exception.  
In other words, If I have a value "N/A" it will get an mapper\_parsing\_exception because this field is waiting for a LONG (number) so I would like to automatically change the "N/A" to 0. Is it possible ???

Thanks!

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [September 27, 2016, 2:44pm UTC](https://discuss.elastic.co/t/mapper-parsing-exception-set-value-by-default/61617/2 "2016-09-27T14:44:36Z")

</div>

5.0 will make it possible with ingest pipelines, however in the current stable version there is no way to do it. The closest option I can think of would be to pass `null` rather than `"N/A"` and configuring a `null_value` in the mappings.

---

<div class="post-metadata">

**Author:** ![minniek](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@minniek](https://discuss.elastic.co/u/minniek)\
**Post date:** [September 27, 2016, 3:09pm UTC](https://discuss.elastic.co/t/mapper-parsing-exception-set-value-by-default/61617/3 "2016-09-27T15:09:39Z")

</div>

Yes, but I am not able to change the "N/A" to null. When I said N/A i meant any string . I am looking to change any value to 0 if the value is an string which means N/A, BLABLABLA; WHATEVER, etc.

what about a groovy script? Can I write a script which verify a value and change it to a number before inserting a document?

Thanks

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [September 27, 2016, 3:53pm UTC](https://discuss.elastic.co/t/mapper-parsing-exception-set-value-by-default/61617/4 "2016-09-27T15:53:08Z")

</div>

Maybe you could do this by using the update API rather than the index APIs: [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#\_literal\_scripted\_upsert\_literal](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#_literal_scripted_upsert_literal)

---

<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 5, 2017, 10:16pm UTC](https://discuss.elastic.co/t/mapper-parsing-exception-set-value-by-default/61617/5 "2017-07-05T22:16:55Z")

</div>


