No result when filter by scripted field


using Kibana 5.4.1

My documents in ElasticSearch have 2 date fields: start and end. Or only start while the event is still happening.
I have created a scripted field in Kibana, length, defined like this

if (!doc['end'].empty) { 
    return (doc['end'].value - doc['start'].value)/3600000.0
} else {
    return null;

I can see their values in the Discover page. However, if I try to filter in the query bar with something like this


I only get a blank page, with a "No results found" message.
Same with


Even worse, if I filter by


I expected to see those documents with no value defined yet for the field. However, that is not always the result. Sometimes it returns documents with a valid value of the field.

Is it OK to return "null" for a scripted field of type "number"? Is that the issue?

Hi @jcaballero,

Querying on scripted fields isn't something that is supported in 5.4. A more detailed explanation of how scripted fields work can be found here (

In the recent version of Kibana ( there is a way to do this using the new experimental query language (

Hope this helps,

Ah, I see. I guess I missed the part "Kibana cannot query scripted fields" :stuck_out_tongue:
Thanks a lot!!

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