# Control the returned fields values of a response

**URL:** <https://discuss.elastic.co/t/control-the-returned-fields-values-of-a-response/32555>\
**Category:** Elasticsearch\
**Created:** [October 20, 2015, 7:23am UTC](https://discuss.elastic.co/t/control-the-returned-fields-values-of-a-response/32555 "2015-10-20T07:23:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tpraizler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tpraizler/32/46271_2.png) [@tpraizler](https://discuss.elastic.co/u/tpraizler)\
**Post date:** [October 20, 2015, 7:23am UTC](https://discuss.elastic.co/t/control-the-returned-fields-values-of-a-response/32555/1 "2015-10-20T07:23:49Z")

</div>

Hi!

I have the following document:

```
{
   "name" : ["xxxx"],
   "data" : ["aaa|0.1", "bbb|0.2", "ccc|0.3", "ddd|0.4", "eee|0.5", "fff|0.6", "ggg|0.7", "hhh|0.8", "iii|0.9"],
}

```

I have 2 use cases:

1. I want to control in the returned fields\ values, so I would like to get a response like this:

Basically I want to retrieve the name field, and the payload of the "ggg" term in the "data" field.  
2.

```
{
    "hits" : {
       "total" : 1,
       "hits" : [ {
       "fields" : {
          "name" : ["xxxx"],
           "value" : ["ggg|0.7"]
        }
     } ]
   }
}

```

Here I want to retrieve the name field, and the load only "ggg|0.7" term to the "data" field.

I saw that maybe I can achieve this with script\_fields, is this the only option?  
If it is, should it be a native script, or inline script?

Thanks!

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [October 20, 2015, 10:46pm UTC](https://discuss.elastic.co/t/control-the-returned-fields-values-of-a-response/32555/2 "2015-10-20T22:46:23Z")

</div>

script\_fields might work but this looks to me like a very complex solution compared to just doing the processing on client side?

---

<div class="post-metadata">

**Author:** ![tpraizler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tpraizler/32/46271_2.png) [@tpraizler](https://discuss.elastic.co/u/tpraizler)\
**Post date:** [October 21, 2015, 12:03pm UTC](https://discuss.elastic.co/t/control-the-returned-fields-values-of-a-response/32555/3 "2015-10-21T12:03:52Z")

</div>

The problem is that this field can contain 800K terms, meaning the response will be huge..  
This is why I am doing the processing in Elasticsearch.

---

<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 5, 2017, 11:43pm UTC](https://discuss.elastic.co/t/control-the-returned-fields-values-of-a-response/32555/4 "2017-07-05T23:43:34Z")

</div>


