Unable to filter data when using a scripted-field

Hello,

I've created a scripted-field, sc-streaming-performance-score which is a ratio between 2 values and returns a float:

def a = doc['field'].value;
def b = doc['field'].value;

if (a > 0 && b > 0) {
  return (float) a / b;
}

Results:

values

Everything's working perfectly but when I want to filter scores via a lucene-query in the Discover panel, there's no result displayed:

no_values_when_filtering

I've tested with 1.0, same "issue". Is scripted-field subject to specific restrictions ?

Hi Yvan,

Lucene queries don't support scripted fields at all. You can use the "Add a filter" button below that bar to add a filter on that field. That way we will take care about writing the appropriate scripted filter to Elasticsearch, or you can switch to using KQL in the query bar which would support this (this can either be enabled directly in the bar - if you see an Options link in the right side of the bar) or in the advanced settings in earlier versions.

But using the filter UI will always work no matter if you are using Lucene or KQL.

Cheers,
Tim

1 Like

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