# Getting shard id in script engine

**URL:** <https://discuss.elastic.co/t/getting-shard-id-in-script-engine/362566>\
**Category:** Elasticsearch\
**Created:** [July 4, 2024, 3:51pm UTC](https://discuss.elastic.co/t/getting-shard-id-in-script-engine/362566 "2024-07-04T15:51:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ktech007](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ktech007/32/124751_2.png) [@ktech007](https://discuss.elastic.co/u/ktech007)\
**Post date:** [July 4, 2024, 3:51pm UTC](https://discuss.elastic.co/t/getting-shard-id-in-script-engine/362566/1 "2024-07-04T15:51:14Z")

</div>

In a plugin like [this](https://github.com/elastic/elasticsearch/blob/main/plugins/examples/script-expert-scoring/src/main/java/org/elasticsearch/example/expertscript/ExpertScriptPlugin.java) where it's extending ScriptEngine, LeafFactory, and DocReader, is it possible to get the shard the script is running on?

I assume the script would run on each shard individually and then combine data. I am passing something in the params per shard and would like to apply the logic based on the shard it is running on.
