# Scripted field not available in Rest API

**URL:** <https://discuss.elastic.co/t/scripted-field-not-available-in-rest-api/264031>\
**Category:** Elasticsearch\
**Created:** [February 11, 2021, 3:35pm UTC](https://discuss.elastic.co/t/scripted-field-not-available-in-rest-api/264031 "2021-02-11T15:35:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gauti](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Gauti](https://discuss.elastic.co/u/Gauti)\
**Post date:** [February 11, 2021, 3:35pm UTC](https://discuss.elastic.co/t/scripted-field-not-available-in-rest-api/264031/1 "2021-02-11T15:35:44Z")

</div>

Hi All,

I'm trying to fetch data from elasticsaerch using rest api, i'm able to get all the documents by running the below query

`GET perfchk/_search?size=1000`

I have created few scripted fields in this index, those scripted field datas are not showing up in the rest output, Is this a normal behaviour of elasticsearch or i'm missing something in the query.

Please advice.

Thanks  
Gautham

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [February 11, 2021, 3:52pm UTC](https://discuss.elastic.co/t/scripted-field-not-available-in-rest-api/264031/2 "2021-02-11T15:52:41Z")

</div>

[Normal behavior](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html). Use Discover if you want to see the output of scripted fields.

> Scripted fields compute data on the fly from the data in your Elasticsearch indices. The data is shown on the **Discover** tab as part of the document data, and you can use scripted fields in your **visualizations**.

---

<div class="post-metadata">

**Author:** ![Gauti](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Gauti](https://discuss.elastic.co/u/Gauti)\
**Post date:** [February 11, 2021, 4:15pm UTC](https://discuss.elastic.co/t/scripted-field-not-available-in-rest-api/264031/3 "2021-02-11T16:15:18Z")

</div>

I'm able to view the field in discover tab and am able to create visualizations also thanks for that.

Actually i was trying to use rest api of elasticsearch to expose the data to another 3rd part tool, so was checking if the scripted field will be available using rest api?

Thanks  
Gautham

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [February 11, 2021, 4:27pm UTC](https://discuss.elastic.co/t/scripted-field-not-available-in-rest-api/264031/4 "2021-02-11T16:27:13Z")

</div>

Scripted fields are stored in `.kibana` index and I believe can only be used within Kibana (Visualizations and Discover).

When you query using Elastic API it doesn't reach out to `.kibana` to see if there are scripted fields to process. It just grabs the data per the query.

So the answer is you would just need to perform whatever transformations you were in the scripted field in your code after you grab the data.

---

<div class="post-metadata">

**Author:** ![Gauti](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Gauti](https://discuss.elastic.co/u/Gauti)\
**Post date:** [February 11, 2021, 4:42pm UTC](https://discuss.elastic.co/t/scripted-field-not-available-in-rest-api/264031/5 "2021-02-11T16:42:03Z")

</div>

Thanks @aaron-nimocks This cleared my doubts.

Thanks  
Gautham

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [February 11, 2021, 4:54pm UTC](https://discuss.elastic.co/t/scripted-field-not-available-in-rest-api/264031/6 "2021-02-11T16:54:26Z")

</div>

The 7.11 release gave [Runtime Fields](https://www.elastic.co/guide/en/elasticsearch/reference/current/runtime.html). I have yet to test those but the documentation kind of suggests you might be able to do this now.

---

<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:** [March 11, 2021, 4:55pm UTC](https://discuss.elastic.co/t/scripted-field-not-available-in-rest-api/264031/7 "2021-03-11T16:55:17Z")

</div>

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