# Passing parameters to script dynamically in Elastic Search

**URL:** <https://discuss.elastic.co/t/passing-parameters-to-script-dynamically-in-elastic-search/185331>\
**Category:** Elasticsearch\
**Created:** [June 12, 2019, 6:17am UTC](https://discuss.elastic.co/t/passing-parameters-to-script-dynamically-in-elastic-search/185331 "2019-06-12T06:17:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikita.jain](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nikita.jain](https://discuss.elastic.co/u/nikita.jain)\
**Post date:** [June 12, 2019, 6:17am UTC](https://discuss.elastic.co/t/passing-parameters-to-script-dynamically-in-elastic-search/185331/1 "2019-06-12T06:17:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 10, 2019, 6:17am UTC](https://discuss.elastic.co/t/passing-parameters-to-script-dynamically-in-elastic-search/185331/2 "2019-07-10T06:17:13Z")

</div>

Closed on July 10, 2019, 6:17am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
