Creating a dynamic scripted field

hi there
i'm trying to get the latest value of a certain field into a scripted field
what i did is this
"query": {"term": {
"type": {
"value": "certain_type"
} ,
"fields": ["@timestamp" , "sum_users"],

"size": 1 ,
"sort": [
"@timestamp": {
"order": "desc"
] ,
"script_fields": {
"last_value": {
"script": "doc['sum_users'].value"

what i got here is the latest value of the field "sum_users" filtered by a certain type into a scripted field called "latest vlaue"
now i want this to become a single dynamic field that means that i want tihs script to run every few min or so , that the value of "latest value" will change acordingly - even making it like a unique document that changes over time acordingly

can anyone help me on that , how to create that scripted "document" in a certain index

thank you!