Scripted field causes discover to fail kibana 7.8

i added a scripted field and after that i can no longer use the discover to search or create filters, on the particular index that i added the field on...

this is what i have in scripted field

if(doc['keywords.sentiment.score'].value == null || doc['keywords.sentiment.score'].value == '' ){ return 0; }else{ return (doc['keywords.sentiment.score'].value * -1); }

and this is the error

Error: Bad Request
at Fetch._callee3$ (
at l (
at Generator._invoke (
at Generator.forEach.e. [as next] (
at asyncGeneratorStep (
at _next (

Computing data on the fly with scripted fields can be very resource intensive and can have a direct impact on Kibana performance. Keep in mind that there’s no built-in validation of a scripted field. If your scripts are buggy, you’ll get exceptions whenever you try to view the dynamically generated data.

Use something like this to check if field exist in the doc

if (!doc.containsKey('myfield') || doc['myfield'].empty) { return "unavailable" } else { return doc['myfield'].value }

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