# Elascticsearch scripting

**URL:** <https://discuss.elastic.co/t/elascticsearch-scripting/18278>\
**Category:** Elasticsearch\
**Created:** [June 24, 2014, 7:14am UTC](https://discuss.elastic.co/t/elascticsearch-scripting/18278 "2014-06-24T07:14:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![deep\_saxena](https://avatars.discourse-cdn.com/v4/letter/d/cdc98d/32.png) [@deep\_saxena](https://discuss.elastic.co/u/deep_saxena)\
**Post date:** [June 24, 2014, 7:14am UTC](https://discuss.elastic.co/t/elascticsearch-scripting/18278/1 "2014-06-24T07:14:08Z")

</div>

I am looking for the elegant solution where script can serve the purpose.

Some of my conditions are like this :-

changing the name of the field, Some script should run as part of the query  
itself and should return the modified field name.

For example

Data indexed in elasticsearch :- \_myField=\_myValue

I want to change the \_myField to \_newField so the query should  
be constructed in such a way that response returned by Elasticsearch should  
have \_newField = \_myValue in the response object.

I trying to find the script that can run dynamically that changes this  
value, but not able to get that. Can anybody help on this scenarios?????  
🙂

--  
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/fe924064-35e2-4dc4-ac98-485cf322f9b8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fe924064-35e2-4dc4-ac98-485cf322f9b8%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Cedric\_Hourcade](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cedric_hourcade/32/1451_2.png) [@Cedric\_Hourcade](https://discuss.elastic.co/u/Cedric_Hourcade)\
**Post date:** [June 24, 2014, 7:52am UTC](https://discuss.elastic.co/t/elascticsearch-scripting/18278/2 "2014-06-24T07:52:32Z")

</div>

For that specific need you can use the script fields:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

With something like:

{  
"query": {  
"match\_all": {}  
},  
"script\_fields": {  
"\_myNewField": {  
"script": "\_source.\_myField"  
}  
}  
}

Cédric Hourcade  
[ced@wal.fr](mailto:ced@wal.fr)

On Tue, Jun 24, 2014 at 9:14 AM, deep saxena [sandy100ster@gmail.com](mailto:sandy100ster@gmail.com) wrote:

> I am looking for the elegant solution where script can serve the purpose.
> 
> Some of my conditions are like this :-
> 
> changing the name of the field, Some script should run as part of the query  
> itself and should return the modified field name.
> 
> For example
> 
> Data indexed in elasticsearch :- \_myField=\_myValue
> 
> I want to change the \_myField to \_newField so the query should be  
> constructed in such a way that response returned by Elasticsearch should  
> have \_newField = \_myValue in the response object.
> 
> I trying to find the script that can run dynamically that changes this  
> value, but not able to get that. Can anybody help on this scenarios????? 🙂
> 
> --  
> 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/fe924064-35e2-4dc4-ac98-485cf322f9b8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fe924064-35e2-4dc4-ac98-485cf322f9b8%40googlegroups.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/CAJQxjPNfW6\_2Ae7YOA9\_s8QsR\_UMZREWFGn\_%2Bpe65h6P%2Bc8ZCQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAJQxjPNfW6_2Ae7YOA9_s8QsR_UMZREWFGn_%2Bpe65h6P%2Bc8ZCQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:20am UTC](https://discuss.elastic.co/t/elascticsearch-scripting/18278/3 "2017-07-06T01:20:16Z")

</div>


