# Filter on scripted field not working in Kibana UI

**URL:** https://discuss.elastic.co/t/filter-on-scripted-field-not-working-in-kibana-ui/203823
**Category:** Kibana
**Created:** [October 16, 2019, 11:33am UTC](https://discuss.elastic.co/t/filter-on-scripted-field-not-working-in-kibana-ui/203823 "2019-10-16T11:33:08Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![maarten](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@maarten](https://discuss.elastic.co/u/maarten)
#### Post date: [October 16, 2019, 11:33am UTC](https://discuss.elastic.co/t/filter-on-scripted-field-not-working-in-kibana-ui/203823/1 "2019-10-16T11:33:08Z")

</div>

Using version 6.4.2.

I have created a dashboard which contains multiple normal fields and scripted fields.  
On scripted fields, filtering works correctly; Standard filter queries are automatically created:  
`{ "query": { "match": { "dossier.label.raw": { "query": "ADVN", "type": "phrase" } } } }`

However, when using a scripted field, the filter query does not work and never yields any results. This is an example of an automatically created filter query on a scripted field:  
`{ "script": { "script": { "inline": "boolean compare(Supplier s, def v) {return s.get() == v;}compare(() -> { doc['dossier.label.raw'] }, params.value);", "lang": "painless", "params": { "value": "ADVN" } } } }`

When I manually correct this query to a standard filter query, the filtering actually works on scripted fields.  
How can I get filtering to work out-of-the-box on scripted fields?

---

<div class="post-metadata">

### Author: ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)
#### Post date: [October 17, 2019, 8:51pm UTC](https://discuss.elastic.co/t/filter-on-scripted-field-not-working-in-kibana-ui/203823/2 "2019-10-17T20:51:15Z")

</div>

Hmm, everything looks like it should be working correctly. Is the exact value for the scripted field `ADVN`, or is that only a portion of the value?

---

<div class="post-metadata">

### Author: ![maarten](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@maarten](https://discuss.elastic.co/u/maarten)
#### Post date: [October 18, 2019, 3:33am UTC](https://discuss.elastic.co/t/filter-on-scripted-field-not-working-in-kibana-ui/203823/3 "2019-10-18T03:33:56Z")

</div>

Hi Lukas, thanks for your feedback. Yes, 'ADVN' is the exact value for the scripted field (and not a portion of the value).

---

<div class="post-metadata">

### Author: ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)
#### Post date: [October 18, 2019, 8:46pm UTC](https://discuss.elastic.co/t/filter-on-scripted-field-not-working-in-kibana-ui/203823/4 "2019-10-18T20:46:37Z")

</div>

Hmm, is your script simply the following?

```auto
doc['dossier.label.raw']

```

If so, you may want to consider changing it to something like this:

```auto
doc['dossier.label'].value

```

---

<div class="post-metadata">

### Author: ![maarten](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@maarten](https://discuss.elastic.co/u/maarten)
#### Post date: [October 22, 2019, 9:55am UTC](https://discuss.elastic.co/t/filter-on-scripted-field-not-working-in-kibana-ui/203823/5 "2019-10-22T09:55:52Z")

</div>

Hi Lukas, thanks for the input.  
I got it to work with:

```auto
doc['dossier.label.raw'].value

```

---

<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: [November 19, 2019, 9:55am UTC](https://discuss.elastic.co/t/filter-on-scripted-field-not-working-in-kibana-ui/203823/6 "2019-11-19T09:55:55Z")

</div>

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