# How to specify a script file via the Java API?

**URL:** <https://discuss.elastic.co/t/how-to-specify-a-script-file-via-the-java-api/29437>\
**Category:** Elasticsearch\
**Created:** [September 16, 2015, 7:56pm UTC](https://discuss.elastic.co/t/how-to-specify-a-script-file-via-the-java-api/29437 "2015-09-16T19:56:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![karussell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karussell/32/4823_2.png) [@karussell](https://discuss.elastic.co/u/karussell)\
**Post date:** [September 16, 2015, 7:56pm UTC](https://discuss.elastic.co/t/how-to-specify-a-script-file-via-the-java-api/29437/1 "2015-09-16T19:56:05Z")

</div>

I'm using ES 1.7.0

```
ScoreFunctionBuilders.scriptFunction("general_score", "groovy")

```

and everything works locally. But when I deploy I get:

```
GroovyScriptExecutionException[MissingPropertyException[No such property: general_score for class: Script4]]

```

So it seems now this is recognized as script itself and does no lookup. Is there normally some magic happening and for my deployed case the external scripts are just not found? Maybe due to the transport client I use for deployed code vs. embedded locally?

How can I be specific and force using a script under config/scripts via the Java API? (For the REST API it is "script\_file": "general\_score")

The issue [here](https://github.com/elastic/elasticsearch/issues/10011) and discussion [here](https://discuss.elastic.co/t/stats-aggregation-value-script-broken-due-to-groovy-scripting-disabled/22533) might be related but they didn't really help me further

Inlining the script helps, when doing settingsBuilder.put("script.search", "on");

---

<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 5, 2017, 11:49pm UTC](https://discuss.elastic.co/t/how-to-specify-a-script-file-via-the-java-api/29437/2 "2017-07-05T23:49:54Z")

</div>


