# Elasticsearch 1.3 Transform Scripts

**URL:** <https://discuss.elastic.co/t/elasticsearch-1-3-transform-scripts/18885>\
**Category:** Elasticsearch\
**Created:** [July 25, 2014, 1:22am UTC](https://discuss.elastic.co/t/elasticsearch-1-3-transform-scripts/18885 "2014-07-25T01:22:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [July 25, 2014, 1:22am UTC](https://discuss.elastic.co/t/elasticsearch-1-3-transform-scripts/18885/1 "2014-07-25T01:22:21Z")

</div>

Just wanted to bring attention to the new and _very_ useful transform  
scripts that were introduced in elasticsearch 1.3 [1]. This feature allows  
you to manipulate the source BEFORE it is indexed so you can do things like  
add/remove fields, change field values, etc. Groovy scripts will be the  
default, but you can write native transform scripts as well [2].

[1]  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-transform.html#mapping-transform](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-transform.html#mapping-transform)  
[2] [https://github.com/imotov/elasticsearch-native-script-example/pull/7](https://github.com/imotov/elasticsearch-native-script-example/pull/7)

Thanks,  
Matt Weber

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5647d22b-9365-449d-922c-b5ed349c7826%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5647d22b-9365-449d-922c-b5ed349c7826%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [July 25, 2014, 2:01am UTC](https://discuss.elastic.co/t/elasticsearch-1-3-transform-scripts/18885/2 "2014-07-25T02:01:01Z")

</div>

I wanted to do conditional copy\_to and Andrian suggested implementing  
scripted transforms instead. Much more flexible. They mesh well with the  
shift to groovy too because groovy is much more stable. Stable enough to  
run on every insert.

I'm glad you are excited by it. It was fun to build and I hope lots of  
people enjoy it.

Nik  
On Jul 24, 2014 9:22 PM, "Matt Weber" [matt@mattweber.org](mailto:matt@mattweber.org) wrote:

> Just wanted to bring attention to the new and _very_ useful transform  
> scripts that were introduced in elasticsearch 1.3 [1]. This feature allows  
> you to manipulate the source BEFORE it is indexed so you can do things like  
> add/remove fields, change field values, etc. Groovy scripts will be the  
> default, but you can write native transform scripts as well [2].
> 
> [1]  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-transform.html#mapping-transform)  
> [2] [Add Native Transform Script Example by mattweber · Pull Request #7 · imotov/elasticsearch-native-script-example · GitHub](https://github.com/imotov/elasticsearch-native-script-example/pull/7)
> 
> Thanks,  
> Matt Weber
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/5647d22b-9365-449d-922c-b5ed349c7826%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5647d22b-9365-449d-922c-b5ed349c7826%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/5647d22b-9365-449d-922c-b5ed349c7826%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/5647d22b-9365-449d-922c-b5ed349c7826%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2N6KNnJ%3D7kVtiyS3UE45j36ktGxT%3DiDuPsDxMuwKGAPw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2N6KNnJ%3D7kVtiyS3UE45j36ktGxT%3DiDuPsDxMuwKGAPw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [July 25, 2014, 3:52am UTC](https://discuss.elastic.co/t/elasticsearch-1-3-transform-scripts/18885/3 "2014-07-25T03:52:03Z")

</div>

Yea, I really like it. I have been thinking about the exact same thing for  
a while but never had the time to put it together. I do have some things I  
would like to add such as the ability to stop a document from being indexed  
when the doc has/does not have a specific value. At any rate, great job!

Thanks,  
Matt Weber

On Thu, Jul 24, 2014 at 7:01 PM, Nikolas Everett [nik9000@gmail.com](mailto:nik9000@gmail.com) wrote:

> I wanted to do conditional copy\_to and Andrian suggested implementing  
> scripted transforms instead. Much more flexible. They mesh well with the  
> shift to groovy too because groovy is much more stable. Stable enough to  
> run on every insert.
> 
> I'm glad you are excited by it. It was fun to build and I hope lots of  
> people enjoy it.
> 
> Nik  
> On Jul 24, 2014 9:22 PM, "Matt Weber" [matt@mattweber.org](mailto:matt@mattweber.org) wrote:
> 
> > Just wanted to bring attention to the new and _very_ useful transform  
> > scripts that were introduced in elasticsearch 1.3 [1]. This feature allows  
> > you to manipulate the source BEFORE it is indexed so you can do things like  
> > add/remove fields, change field values, etc. Groovy scripts will be the  
> > default, but you can write native transform scripts as well [2].
> > 
> > [1]  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-transform.html#mapping-transform)  
> > [2] [Add Native Transform Script Example by mattweber · Pull Request #7 · imotov/elasticsearch-native-script-example · GitHub](https://github.com/imotov/elasticsearch-native-script-example/pull/7)
> > 
> > Thanks,  
> > Matt Weber
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/5647d22b-9365-449d-922c-b5ed349c7826%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5647d22b-9365-449d-922c-b5ed349c7826%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/5647d22b-9365-449d-922c-b5ed349c7826%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/5647d22b-9365-449d-922c-b5ed349c7826%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2N6KNnJ%3D7kVtiyS3UE45j36ktGxT%3DiDuPsDxMuwKGAPw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2N6KNnJ%3D7kVtiyS3UE45j36ktGxT%3DiDuPsDxMuwKGAPw%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2N6KNnJ%3D7kVtiyS3UE45j36ktGxT%3DiDuPsDxMuwKGAPw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2N6KNnJ%3D7kVtiyS3UE45j36ktGxT%3DiDuPsDxMuwKGAPw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAJ3KEoDfkUE%2B1%2BPGx-1KW%2BVQFXy2\_JgvU9s27krist3uAV\_9cQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAJ3KEoDfkUE%2B1%2BPGx-1KW%2BVQFXy2_JgvU9s27krist3uAV_9cQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [July 25, 2014, 8:09am UTC](https://discuss.elastic.co/t/elasticsearch-1-3-transform-scripts/18885/4 "2014-07-25T08:09:02Z")

</div>

Yeah, I use Groovy for input data transformations for years, so I'm very  
enthusiastic about ES embracing Groovy as default.

I use Groovy scripts before the source is passed to the bulk client, in a  
key/value stream processing.

It's good to see transformation machinery in the ES mapping, but I do also  
off-line transformations, without ES, i.e. converting from file to file ...  
🙂

Jörg

On Fri, Jul 25, 2014 at 5:52 AM, Matt Weber [matt.weber@gmail.com](mailto:matt.weber@gmail.com) wrote:

> Yea, I really like it. I have been thinking about the exact same thing  
> for a while but never had the time to put it together. I do have some  
> things I would like to add such as the ability to stop a document from  
> being indexed when the doc has/does not have a specific value. At any  
> rate, great job!
> 
> Thanks,  
> Matt Weber
> 
> On Thu, Jul 24, 2014 at 7:01 PM, Nikolas Everett [nik9000@gmail.com](mailto:nik9000@gmail.com)  
> wrote:
> 
> > I wanted to do conditional copy\_to and Andrian suggested implementing  
> > scripted transforms instead. Much more flexible. They mesh well with the  
> > shift to groovy too because groovy is much more stable. Stable enough to  
> > run on every insert.
> > 
> > I'm glad you are excited by it. It was fun to build and I hope lots of  
> > people enjoy it.
> > 
> > Nik  
> > On Jul 24, 2014 9:22 PM, "Matt Weber" [matt@mattweber.org](mailto:matt@mattweber.org) wrote:
> > 
> > > Just wanted to bring attention to the new and _very_ useful transform  
> > > scripts that were introduced in elasticsearch 1.3 [1]. This feature allows  
> > > you to manipulate the source BEFORE it is indexed so you can do things like  
> > > add/remove fields, change field values, etc. Groovy scripts will be the  
> > > default, but you can write native transform scripts as well [2].
> > > 
> > > [1]  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-transform.html#mapping-transform)  
> > > [2] [Add Native Transform Script Example by mattweber · Pull Request #7 · imotov/elasticsearch-native-script-example · GitHub](https://github.com/imotov/elasticsearch-native-script-example/pull/7)
> > > 
> > > Thanks,  
> > > Matt Weber
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/5647d22b-9365-449d-922c-b5ed349c7826%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5647d22b-9365-449d-922c-b5ed349c7826%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/5647d22b-9365-449d-922c-b5ed349c7826%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/5647d22b-9365-449d-922c-b5ed349c7826%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2N6KNnJ%3D7kVtiyS3UE45j36ktGxT%3DiDuPsDxMuwKGAPw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2N6KNnJ%3D7kVtiyS3UE45j36ktGxT%3DiDuPsDxMuwKGAPw%40mail.gmail.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2N6KNnJ%3D7kVtiyS3UE45j36ktGxT%3DiDuPsDxMuwKGAPw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd2N6KNnJ%3D7kVtiyS3UE45j36ktGxT%3DiDuPsDxMuwKGAPw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAJ3KEoDfkUE%2B1%2BPGx-1KW%2BVQFXy2\_JgvU9s27krist3uAV\_9cQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAJ3KEoDfkUE%2B1%2BPGx-1KW%2BVQFXy2_JgvU9s27krist3uAV_9cQ%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAJ3KEoDfkUE%2B1%2BPGx-1KW%2BVQFXy2\_JgvU9s27krist3uAV\_9cQ%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAJ3KEoDfkUE%2B1%2BPGx-1KW%2BVQFXy2_JgvU9s27krist3uAV_9cQ%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFVdAXP1rcbbpGb5ujP--\_xfDOYWFLu28u%3DhhQRZ\_bS5w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFVdAXP1rcbbpGb5ujP--_xfDOYWFLu28u%3DhhQRZ_bS5w%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![amrelhagary](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@amrelhagary](https://discuss.elastic.co/u/amrelhagary)\
**Post date:** [August 4, 2014, 11:52am UTC](https://discuss.elastic.co/t/elasticsearch-1-3-transform-scripts/18885/5 "2014-08-04T11:52:17Z")

</div>

I have a problem i need to add dynamic fields according to certain fields value , i use groovy in simple case and it worked but the logic become more complicated and i need to separate it in external groovy script file and pass context as parameters but it didn't work and this must in mapping stage .

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [August 7, 2014, 8:14am UTC](https://discuss.elastic.co/t/elasticsearch-1-3-transform-scripts/18885/6 "2014-08-07T08:14:06Z")

</div>

Hi ,

I was looking for this.  
Thanks buddy.

Thanks  
Vineeth

On Mon, Aug 4, 2014 at 5:22 PM, amrelhagary [amr.elhagary@gmail.com](mailto:amr.elhagary@gmail.com) wrote:

> I have a problem i need to add dynamic fields according to certain fields  
> value , i use groovy in simple case and it worked but the logic become more  
> complicated and i need to separate it in external groovy script file and  
> pass context as parameters but it didn't work and this must in mapping  
> stage  
> .
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Elasticsearch-1-3-Transform-Scripts-tp4060592p4061206.html](http://elasticsearch-users.115913.n3.nabble.com/Elasticsearch-1-3-Transform-Scripts-tp4060592p4061206.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/1407153137385-4061206.post%40n3.nabble.com](https://groups.google.com/d/msgid/elasticsearch/1407153137385-4061206.post%40n3.nabble.com)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGdPd5kuyYyoGcV49ZJ21E9%3DPr3nuqCSutsOH0\_O3sHHp61ZqQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5kuyYyoGcV49ZJ21E9%3DPr3nuqCSutsOH0_O3sHHp61ZqQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![amrelhagary](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@amrelhagary](https://discuss.elastic.co/u/amrelhagary)\
**Post date:** [August 7, 2014, 10:36am UTC](https://discuss.elastic.co/t/elasticsearch-1-3-transform-scripts/18885/7 "2014-08-07T10:36:34Z")

</div>

Hello ,

after several tries finally i found a solution

> <https://gist.github.com/amrelhagary/f664c4bc239698a9b293>

---

<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, 1:10am UTC](https://discuss.elastic.co/t/elasticsearch-1-3-transform-scripts/18885/8 "2017-07-06T01:10:11Z")

</div>


