# How to return predefined response fields?

**URL:** https://discuss.elastic.co/t/how-to-return-predefined-response-fields/95908
**Category:** Kibana
**Created:** [August 4, 2017, 3:04pm UTC](https://discuss.elastic.co/t/how-to-return-predefined-response-fields/95908 "2017-08-04T15:04:55Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![bterhorst](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@bterhorst](https://discuss.elastic.co/u/bterhorst)
#### Post date: [August 4, 2017, 3:04pm UTC](https://discuss.elastic.co/t/how-to-return-predefined-response-fields/95908/1 "2017-08-04T15:04:55Z")

</div>

Hi,

Is there a way to configure kibana to return specified fields in the response from es?

I am building a custom visual and am currently receiving only the document term field that I queried and thats defined as key:

```
    "buckets": [
            {
              "key": "6000014",
              "doc_count": 24
            },
            {
              "key": "6000013",
              "doc_count": 23
            },
            {
              "key": "6000012",
              "doc_count": 3
            }
          ]

```

I would like something like this in my esResponse from within mu custom visual:

```
"buckets": [
                {
                  "id_1": "6000014",
                  "id_2": "1000014",
                  "doc_count": 24
                },
                {
                 "id_1": "6000013",
                  "id_2": "1000013"
                  "doc_count": 23
                },
                {
                  "id_1": "6000012",
                  "id_2": "1000012",
                  "doc_count": 23
                }
              ]

```

How would I go about doing this?

Regards benny

---

<div class="post-metadata">

### Author: ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)
#### Post date: [August 4, 2017, 3:10pm UTC](https://discuss.elastic.co/t/how-to-return-predefined-response-fields/95908/2 "2017-08-04T15:10:32Z")

</div>

Hi Benny,

Kibana can't change the response from ES. May be you can use scripted fields in Kibana and build your visualization on top of it? Here is the documentation link for it: [https://www.elastic.co/guide/en/kibana/current/scripted-fields.html](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html)

Here is where you will build them:

 ![56 (2)](https://us1.discourse-cdn.com/elastic/original/3X/a/d/ad419e0f5421ec019971383eaa84bf74097b9c23.jpg)

Let us know if that helps.

Thanks,  
Bhavya

---

<div class="post-metadata">

### Author: ![bterhorst](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@bterhorst](https://discuss.elastic.co/u/bterhorst)
#### Post date: [August 8, 2017, 2:41pm UTC](https://discuss.elastic.co/t/how-to-return-predefined-response-fields/95908/3 "2017-08-08T14:41:23Z")

</div>

Hi Bhavya,

Thanks for your proposal.  
I created a scripted field containing the two id's as you sugusted and was able to get that within my custom visual.

Regards benny

---

<div class="post-metadata">

### Author: ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)
#### Post date: [August 9, 2017, 1:56pm UTC](https://discuss.elastic.co/t/how-to-return-predefined-response-fields/95908/4 "2017-08-09T13:56:29Z")

</div>

Awesome. Thanks for keeping me posted.

Cheers  
Bhavya

---

<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: [September 6, 2017, 1:56pm UTC](https://discuss.elastic.co/t/how-to-return-predefined-response-fields/95908/5 "2017-09-06T13:56:41Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
