Elasticsearch escape hyphenated field in groovy script
You can access the field using square brackets, i.e. simply do it like this:
{"script": "ctx._source.path.to['hyphen-separated-field'] = \"new data\""}
This one worked for me on 2.x (or maybe other version as well):
"script": { "inline": "ctx._source.path.to[field] = val", "params": { "val": "This is the new value", "field": "hyphen-separated-field" }}
Or this will also work
{"script": "ctx._source.path.to.'hyphen-separated-field' = 'new data'"}