Create Scripted Field using substring before "."

So it looks like the below should work.

String str = doc['name.keyword'].value;
if (str.contains(".")) {
    String[] result = /./.split(str);
    return result[0];
}
return str;

But it leads to the error below. So if you're going down this route you might need to make those changes or wait for someone else who might know an easier way.

     "reason": "Regexes are disabled. Set [script.painless.regex.enabled] to [true] in elasticsearch.yaml to allow them. Be careful though, regexes break out of Painless's protection against deep recursion and long loops."