No result when filter by scripted field

Hello,

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

length:<1

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

_exists_:length

Even worse, if I filter by

!_exists_:length

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 (https://www.elastic.co/guide/en/kibana/5.4/scripted-fields.html).

In the recent version of Kibana (elastic.co/guide/en/kibana/7.3/scripted-fields.html) there is a way to do this using the new experimental query language (https://www.elastic.co/guide/en/kibana/7.3/kuery-query.html).

Hope this helps,
Mike.

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.