Unable to create a script field

Hello,

I am trying to create a simple script field to display the key size of the SSL certificate, the key size value differs between 256 to 270 bytes, so I created the below script field.

if (doc['ssl_certificate_subject_key_size.keyword'].value >= 256 && doc['ssl_certificate_subject_key_size.keyword'].value <= 270 )
return "2048";

After I configured this scripted field, I am getting the error "llegal_state_exception a document doesn't have a value for this field"

Error:
"reason": "No field found for [ssl_certificate_subject_key_size.keyword] in mapping

Can someone help to sort out this issue?

Thanks,
Ram Mohan

Welcome to the community @Rammohan !
There are two issues I see in the script you're trying to add:

  1. keyword fields are strings, so a numeric range comparison won't work for those. You'll need to change the mapping to a number.
  2. you'll need to check your index mapping and use a field that is mapped.

I don't know what your current mapping looks like or if you can reindex your data into a new index with updated mappings.
If you can't reindex the data, then try using a runtime field to cast the data to a numeric value.

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