Passing parameters to script dynamically in Elastic Search

Hello,

I want to run a script on documents that match a particular query, to boost those results which are accessed recently by user. The IDs of recently accessed documents are available as a list. I want to know how I can pass this list as a parameter to the script in ES so that I can compute a custom score for these results.

For eg: Results of query: Doc ID 1, 2, 5, 6,7
Recent documents: Doc ID 2, 6, 8,9
The desired result is Doc ID 2,6,1,5,7 (based on the custom score)

The list of the recently accessed documents is updated very frequently. How can I achieve this ranking?