# Formatting field values? Or how to write this particular script preprocessor?

**URL:** https://discuss.elastic.co/t/formatting-field-values-or-how-to-write-this-particular-script-preprocessor/172045
**Category:** Elasticsearch
**Created:** [March 13, 2019, 2:46am UTC](https://discuss.elastic.co/t/formatting-field-values-or-how-to-write-this-particular-script-preprocessor/172045 "2019-03-13T02:46:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Atonal](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Atonal](https://discuss.elastic.co/u/Atonal)
#### Post date: [March 13, 2019, 2:46am UTC](https://discuss.elastic.co/t/formatting-field-values-or-how-to-write-this-particular-script-preprocessor/172045/1 "2019-03-13T02:46:58Z")

</div>

I have documents in my index that have a field whose value is a string of numbers, "." and `-`. I want to remove those `.` and `-` from the values and change the field type to an integer.

I can have these removed before I feed my data to elasticsearch, but then I still have the problem with the existing indexed documents.

I believe the solution is to define an ingest node and add it to the a new index's mapping, then reindex and alias the old one. However I simply can't write the conditional removal of `.` and `-` using painless in a script preprocessor! And I didn't understand the documentation.

How do I write it?!

Thanks!

---

<div class="post-metadata">

### Author: ![Atonal](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Atonal](https://discuss.elastic.co/u/Atonal)
#### Post date: [March 13, 2019, 7:11am UTC](https://discuss.elastic.co/t/formatting-field-values-or-how-to-write-this-particular-script-preprocessor/172045/2 "2019-03-13T07:11:28Z")

</div>

Anyone?

---

<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: [April 10, 2019, 7:11am UTC](https://discuss.elastic.co/t/formatting-field-values-or-how-to-write-this-particular-script-preprocessor/172045/3 "2019-04-10T07:11:32Z")

</div>

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