# Custom return fields with native scripts

**URL:** <https://discuss.elastic.co/t/custom-return-fields-with-native-scripts/20023>\
**Category:** Elasticsearch\
**Created:** [October 1, 2014, 1:03pm UTC](https://discuss.elastic.co/t/custom-return-fields-with-native-scripts/20023 "2014-10-01T13:03:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_2](https://avatars.discourse-cdn.com/v4/letter/n/7ba0ec/32.png) [@Nick\_2](https://discuss.elastic.co/u/Nick_2)\
**Post date:** [October 1, 2014, 1:03pm UTC](https://discuss.elastic.co/t/custom-return-fields-with-native-scripts/20023/1 "2014-10-01T13:03:39Z")

</div>

Hi,

I'm currently looking for a solution to the following problem:

I've got a few formula's which need to be calculated by using data inside  
an elasticsearch index and filter parameters as arguments. This formula  
needs to be calculated for each record in a specific index.

I can create a native script which calculates the result for each function,  
and craft a score out of it. What I would like is to return the result of  
each function and 'append' it to the document, so the one performing the  
query with the specific function can see the outcome of each formula.

Could you tell me if this is possible in elasticsearch (by using native  
functions?) / how I can achieve this?

Thanks,

Nick

--  
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/8e4b6fb4-0ca5-4eeb-8b6d-e117096eae88%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8e4b6fb4-0ca5-4eeb-8b6d-e117096eae88%40googlegroups.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, 12:59am UTC](https://discuss.elastic.co/t/custom-return-fields-with-native-scripts/20023/2 "2017-07-06T00:59:00Z")

</div>


