# Search the ScriptFields

**URL:** <https://discuss.elastic.co/t/search-the-scriptfields/101037>\
**Category:** Kibana\
**Created:** [September 19, 2017, 2:42pm UTC](https://discuss.elastic.co/t/search-the-scriptfields/101037 "2017-09-19T14:42:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kirtash](https://avatars.discourse-cdn.com/v4/letter/k/a8b319/32.png) [@Kirtash](https://discuss.elastic.co/u/Kirtash)\
**Post date:** [September 19, 2017, 2:42pm UTC](https://discuss.elastic.co/t/search-the-scriptfields/101037/1 "2017-09-19T14:42:47Z")

</div>

Hello!

How can I get the value of a script field? Using kibana I can get the value:

![image](https://us1.discourse-cdn.com/elastic/original/3X/f/3/f389edc5dcb0fe20f5af00296668806021e930ab.png)

But I don't know if is possible get this field using the "dev tools" of Kibana, like:

GET prova/\_search

Prova = index

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![BigFunger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bigfunger/32/7323_2.png) [@BigFunger](https://discuss.elastic.co/u/BigFunger)\
**Post date:** [September 19, 2017, 7:27pm UTC](https://discuss.elastic.co/t/search-the-scriptfields/101037/2 "2017-09-19T19:27:24Z")

</div>

Here is a link that can provide some information.

[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html)

Kibana scripted fields simply store the script and inject it into the ES query for you.

---

<div class="post-metadata">

**Author:** ![Kirtash](https://avatars.discourse-cdn.com/v4/letter/k/a8b319/32.png) [@Kirtash](https://discuss.elastic.co/u/Kirtash)\
**Post date:** [September 20, 2017, 9:53am UTC](https://discuss.elastic.co/t/search-the-scriptfields/101037/3 "2017-09-20T09:53:50Z")

</div>

First of all Thanks for the answer.

I thought that when I created the script field in Kibana, I didn't need specify again the script in the search.

Now I can get the scriptfield:

GET /prova/\_search  
{  
"script\_fields": {  
"a": {  
"script": "doc['opinion'].value\*2"  
}  
}

But I only can get the script value, not the other fields of the index, how can I get the fields of the index and the scriptField please?

**Search with fields**  
---\> GET prova/\_search

**Search with scriptfield**  
-----\>

GET /prova/\_search  
{  
"script\_fields": {  
"a": {  
"script": "doc['opinion'].value\*2"  
}  
}

}

Thanks for all the help!!

---

<div class="post-metadata">

**Author:** ![BigFunger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bigfunger/32/7323_2.png) [@BigFunger](https://discuss.elastic.co/u/BigFunger)\
**Post date:** [September 20, 2017, 3:05pm UTC](https://discuss.elastic.co/t/search-the-scriptfields/101037/4 "2017-09-20T15:05:45Z")

</div>

This one took a little playing around for me too.

If you include a `"_source"` property in your search object, it returns all of your fields.

ie:

```auto
POST script-field-test/_search
{
  "_source": {},
  "script_fields" : {
      "age-in-a-millennium" : {
          "script" : "doc['age'].value + 1000"
      }
  }
}

```

How I found this:  
I added a scripted field in Kibana, and then navigated to Discover. I then watched the Network tab in my browser developer tools and examined the request payload for the `_msearch` request I found there.

---

<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:** [October 18, 2017, 3:06pm UTC](https://discuss.elastic.co/t/search-the-scriptfields/101037/5 "2017-10-18T15:06:05Z")

</div>

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