# Is it possible to use transform scripts in mappings to alter document \_id?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-use-transform-scripts-in-mappings-to-alter-document--id/20984>\
**Category:** Elasticsearch\
**Created:** [November 29, 2014, 3:20am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-transform-scripts-in-mappings-to-alter-document--id/20984 "2014-11-29T03:20:39Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Reason](https://avatars.discourse-cdn.com/v4/letter/r/e56c9b/32.png) [@Reason](https://discuss.elastic.co/u/Reason)\
**Post date:** [November 29, 2014, 3:20am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-transform-scripts-in-mappings-to-alter-document--id/20984/1 "2014-11-29T03:20:39Z")

</div>

The Elasticsearch documentation is always frustratingly silent on the  
things I seem to need to accomplish to make life easier.

Is it possible to use a transform script in a mapping to alter the document  
\_id? This would be a convenient way to de-dup incoming data I have too  
little control over if so.

After digging around online and not finding much of use, I naively tried  
this in Elasticsearch 1.4, which alas did nothing:

"typename": {  
"transform": {  
"script": "ctx.\_source['useAsId'] = ctx.\_source['a'] + ctx.\_source['b']"  
,  
"lang": "groovy"  
},  
"\_id" {  
"path": "useAsId"  
},  
"properties": {  
"a": { "type": "string" },  
"b": { "type": "string" },  
"useAsId": { "type": "string" }  
}  
}

It seems that the ordering of operations isn't what I'd like it to be under  
the hood; I don't get the \_id I'd want out of this, but rather get the  
standard auto-assigned \_id value.

So is there a way to process an incoming document to alter the \_id value in  
this sort of way? Or there another more generally accepted route to  
de-duping?

--  
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/0d2fbf40-619e-4af6-b991-4c4cfa4133c0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0d2fbf40-619e-4af6-b991-4c4cfa4133c0%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

_[View the full topic](https://discuss.elastic.co/t/is-it-possible-to-use-transform-scripts-in-mappings-to-alter-document--id/20984)._
