# Kibana scripted field is not showing value

**URL:** <https://discuss.elastic.co/t/kibana-scripted-field-is-not-showing-value/322183>\
**Category:** Kibana\
**Created:** [December 30, 2022, 1:01am UTC](https://discuss.elastic.co/t/kibana-scripted-field-is-not-showing-value/322183 "2022-12-30T01:01:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gloria123451](https://avatars.discourse-cdn.com/v4/letter/g/958977/32.png) [@gloria123451](https://discuss.elastic.co/u/gloria123451)\
**Post date:** [December 30, 2022, 1:01am UTC](https://discuss.elastic.co/t/kibana-scripted-field-is-not-showing-value/322183/1 "2022-12-30T01:01:29Z")

</div>

I am new to kibana..  
I am trying to create a scripted field, when I run the script nothing is displayed in the result.  
however, when I filter the field I get the expected result.. why is this not propagating?... what am I doing wrong ?

```auto
if (doc['failed_login_count'].value <= 5) {
     "Low"
}else if (doc['failed_login_count'].value > 5 && doc['failed_login_count'].value <= 10) {
     "Medium"
}else {
    "High"

```

 ![Screen Shot 2022-12-30 at 00.53.06](https://us1.discourse-cdn.com/elastic/original/3X/1/6/1660208286b0ceba1c1e46faac68da542151730e.png)

 ![Screen Shot 2022-12-30 at 00.43.43](https://us1.discourse-cdn.com/elastic/original/3X/2/2/22416c6d9e6ff53777c878303cdf628c97dff7b8.jpeg)

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [December 30, 2022, 11:57am UTC](https://discuss.elastic.co/t/kibana-scripted-field-is-not-showing-value/322183/2 "2022-12-30T11:57:29Z")

</div>

Can you try to execute the script directly in a query in the Kibana DevTools? You may get better feedback there.

I've created a minimal index with some data and your script runs as expected.

```auto
# Create index
PUT discuss-322183
{
  "settings": {
    "number_of_replicas": 1
  },
  "mappings": {
    "properties": {
      "failed_login_count": {"type": "integer"}
    }
  }
}

# Add some data
POST discuss-322183/_bulk
{"index": {}}
{"failed_login_count": 1}
{"index": {}}
{"failed_login_count": 7}
{"index": {}}
{"failed_login_count": 15}

# Search with an scripted field
GET discuss-322183/_search
{
  "_source": ["failed_login_count"], 
  "script_fields": {
    "count": {
      "script": {
        "source": """
if (doc['failed_login_count'].value <= 5) {
     "Low"
}else if (doc['failed_login_count'].value > 5 && doc['failed_login_count'].value <= 10) {
     "Medium"
}else {
    "High"
}
        """,
        "lang": "painless"
      }
    }
  },
  "query": {
    "match_all": {}
  }
}

# clean up
DELETE discuss-322183

```

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

---

<div class="post-metadata">

**Author:** ![gloria123451](https://avatars.discourse-cdn.com/v4/letter/g/958977/32.png) [@gloria123451](https://discuss.elastic.co/u/gloria123451)\
**Post date:** [December 30, 2022, 10:23pm UTC](https://discuss.elastic.co/t/kibana-scripted-field-is-not-showing-value/322183/3 "2022-12-30T22:23:40Z")

</div>

I don't have permission to use DevTool and need to do it using scripted field... I have been told its because I have not questioned if it exists or not... but not sure the right coding to do so... I have tried a few but nothing works so far

---

<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:** [January 27, 2023, 10:23pm UTC](https://discuss.elastic.co/t/kibana-scripted-field-is-not-showing-value/322183/4 "2023-01-27T22:23:48Z")

</div>

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