how to access scripted field value in another script field

Viewed 898

I'm trying to create a Scripted Field like :

return doc[scripted_field_a].value+doc[scripted_field_b].value

how to access to scripted field value in painless script ?

Thank you for any help!

1 Answers

Put your script in field a to script b.

// use script of script field a put to a function to get value
int script_a() { return doc['x'] * 2; }

//main section of script b
script_a() + 2
Related