# Unable to get script\_fields to work

**URL:** <https://discuss.elastic.co/t/unable-to-get-script-fields-to-work/22416>\
**Category:** Elasticsearch\
**Created:** [February 26, 2015, 6:32pm UTC](https://discuss.elastic.co/t/unable-to-get-script-fields-to-work/22416 "2015-02-26T18:32:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gerald\_DeConto](https://avatars.discourse-cdn.com/v4/letter/g/cc9497/32.png) [@Gerald\_DeConto](https://discuss.elastic.co/u/Gerald_DeConto)\
**Post date:** [February 26, 2015, 6:32pm UTC](https://discuss.elastic.co/t/unable-to-get-script-fields-to-work/22416/1 "2015-02-26T18:32:20Z")

</div>

Hopefully someone can point me in the right direction on this: I am having  
trouble getting the simple script\_fields example  
at [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html)  
to work

here is the info:

1. installed ES 1.4.3 on an ubuntu box in a three node cluster; cluster is  
healthy/green
2. created a test index and type and added about a million docs to it; my  
searches/etc work fine
3. created file /etc/elasticsearch/scripts/test.groovy and added this very  
simple script line (and nothing else) to it: 1 + my\_var
4. believe I have made the test.groovy file accessible to elasticsearch  
(made the file owner "elasticsearch" and set access to 666 (rw-rw-rw-)
5. added this line to my /etc/elasticsearch/elasticsearch.yml file to  
enable dynamic scripting (tho thought this wasn't needed for disk based  
scripts): script.disable\_dynamic: false
6. tried running this query in marvel sense but just get an error (shown at  
bottom of this post):  
GET test/\_search  
{  
"script\_fields" : {  
"my\_field" : {  
"params" : {  
"my\_var": 10  
},  
"script\_file":"test"  
}  
}  
}
7. this dynamic inline query runs fine with no error:  
GET moveapi/\_search  
{  
"script\_fields": {  
"my\_field": {  
"script": "1 + my\_var",  
"params": {  
"my\_var": 2  
}  
}  
}  
}

I have tried many variations of the disk based script without success. Can  
anyone provide some advice re how to get this to work? I must be missing  
some setting or something.

Any help REALLY appreciated. thanks in advance

* * *

the error message I get (with "\n" replace with cr/lf to make it readable):

{  
"error": "SearchPhaseExecutionException[Failed to execute phase [query],  
all shards failed; shardFailures {[ZkHUmZijTsuQbc8Q7dvpmg][moveapi][0]:  
RemoteTransportException[[homer][inet[/172.31.48.158:9300]][indices:data/read/search[phase/query]]];  
nested: SearchParseException[[moveapi][0]: from[-1],size[-1]: Parse Failure  
[Failed to parse source [{  
"script\_fields" : {  
"my\_field" : {  
"params" : {  
"my\_var": 10  
},  
"script\_file":"test"  
}  
}  
}  
]]]; nested: NullPointerException; }{[HW4kOpXXShCA3uCNasmrKA][moveapi][1]:  
SearchParseException[[moveapi][1]: from[-1],size[-1]: Parse Failure [Failed  
to parse source [{  
"script\_fields" : {  
"my\_field" : {  
"params" : {  
"my\_var": 10  
},  
"script\_file":"test"  
}  
}  
}  
]]]; nested: NullPointerException; }{[HW4kOpXXShCA3uCNasmrKA][moveapi][2]:  
SearchParseException[[moveapi][2]: from[-1],size[-1]: Parse Failure [Failed  
to parse source [{  
"script\_fields" : {  
"my\_field" : {  
"params" : {  
"my\_var": 10  
},  
"script\_file":"test"  
}  
}  
}  
]]]; nested: NullPointerException; }{[8GqmuI3wRtKCJQ6mDK\_6YA][moveapi][3]:  
RemoteTransportException[[marge][inet[/172.31.48.157:9300]][indices:data/read/search[phase/query]]];  
nested: SearchParseException[[moveapi][3]: from[-1],size[-1]: Parse Failure  
[Failed to parse source [{  
"script\_fields" : {  
"my\_field" : {  
"params" : {  
"my\_var": 10  
},  
"script\_file":"test"  
}  
}  
}  
]]]; nested: NullPointerException; }{[ZkHUmZijTsuQbc8Q7dvpmg][moveapi][4]:  
RemoteTransportException[[homer][inet[/172.31.48.158:9300]][indices:data/read/search[phase/query]]];  
nested: SearchParseException[[moveapi][4]: from[-1],size[-1]: Parse Failure  
[Failed to parse source [{  
"script\_fields" : {  
"my\_field" : {  
"params" : {  
"my\_var": 10  
},  
"script\_file":"test"  
}  
}  
}  
]]]; nested: NullPointerException; }]",  
"status": 400  
}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/35b61bc6-1f7a-4f2c-bd2d-38a8a34d9cf3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/35b61bc6-1f7a-4f2c-bd2d-38a8a34d9cf3%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Gerald\_DeConto](https://avatars.discourse-cdn.com/v4/letter/g/cc9497/32.png) [@Gerald\_DeConto](https://discuss.elastic.co/u/Gerald_DeConto)\
**Post date:** [February 26, 2015, 6:38pm UTC](https://discuss.elastic.co/t/unable-to-get-script-fields-to-work/22416/2 "2015-02-26T18:38:26Z")

</div>

fyi:

my config files (elasticsearch.yml and logging.yml) are  
in /etc/elasticsearch. the script\_fields documentation indicated that I  
put the test.groovy in "config/scripts" folder, so I assumed my location is  
correct as I am unable to find a "config" folder in any elasticsearch folder

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/af424481-4902-4d63-972d-7565c9c133fc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/af424481-4902-4d63-972d-7565c9c133fc%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Julia\_Neidert](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@Julia\_Neidert](https://discuss.elastic.co/u/Julia_Neidert)\
**Post date:** [March 31, 2015, 8:26pm UTC](https://discuss.elastic.co/t/unable-to-get-script-fields-to-work/22416/3 "2015-03-31T20:26:50Z")

</div>

I'm having the same problem. Were you able to resolve this? Thanks!

On Thursday, February 26, 2015 at 10:38:26 AM UTC-8, Gerald DeConto wrote:

> fyi:
> 
> my config files (elasticsearch.yml and logging.yml) are  
> in /etc/elasticsearch. the script\_fields documentation indicated that I  
> put the test.groovy in "config/scripts" folder, so I assumed my location is  
> correct as I am unable to find a "config" folder in any elasticsearch folder

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1b71e8f1-7cb7-41d2-8587-b6a5f88e5ebb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1b71e8f1-7cb7-41d2-8587-b6a5f88e5ebb%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Gerald\_DeConto](https://avatars.discourse-cdn.com/v4/letter/g/cc9497/32.png) [@Gerald\_DeConto](https://discuss.elastic.co/u/Gerald_DeConto)\
**Post date:** [April 1, 2015, 2:03pm UTC](https://discuss.elastic.co/t/unable-to-get-script-fields-to-work/22416/4 "2015-04-01T14:03:14Z")

</div>

Unfortunately no. Had to move on and skip scripts

On 1:27pm, Mar 31, 2015, at 1:27pm, Julia Neidert [neid0021@gmail.com](mailto:neid0021@gmail.com) wrote:

> I'm having the same problem. Were you able to resolve this? Thanks!
> 
> On Thursday, February 26, 2015 at 10:38:26 AM UTC-8, Gerald DeConto  
> wrote:
> 
> > fyi:
> > 
> > my config files (elasticsearch.yml and logging.yml) are  
> > in /etc/elasticsearch. the script\_fields documentation indicated  
> > that I  
> > put the test.groovy in "config/scripts" folder, so I assumed my  
> > location is  
> > correct as I am unable to find a "config" folder in any elasticsearch  
> > folder
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/4GOnbUeWw6c/unsubscribe](https://groups.google.com/d/topic/elasticsearch/4GOnbUeWw6c/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/1b71e8f1-7cb7-41d2-8587-b6a5f88e5ebb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1b71e8f1-7cb7-41d2-8587-b6a5f88e5ebb%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/649a33fd-1f7d-40ba-98d0-2236514f9a47%40email.typeapp.com](https://groups.google.com/d/msgid/elasticsearch/649a33fd-1f7d-40ba-98d0-2236514f9a47%40email.typeapp.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Wouter\_van\_Atteveldt](https://avatars.discourse-cdn.com/v4/letter/w/9fc29f/32.png) [@Wouter\_van\_Atteveldt](https://discuss.elastic.co/u/Wouter_van_Atteveldt)\
**Post date:** [April 5, 2015, 11:52am UTC](https://discuss.elastic.co/t/unable-to-get-script-fields-to-work/22416/5 "2015-04-05T11:52:12Z")

</div>

I had the same problem, but I think that the docs are plain wrong, and it  
should be script instead of script\_file. In any case, if I do that it works  
fine.

I've posted an issue under

> <https://github.com/elastic/elasticsearch/issues/10438>

Test program and session:

> <https://gist.github.com/vanatteveldt/59ff5730b025270e8035>

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/8d826037-1247-4c9d-b566-aaa59cf090fe%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8d826037-1247-4c9d-b566-aaa59cf090fe%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Gerald\_DeConto](https://avatars.discourse-cdn.com/v4/letter/g/cc9497/32.png) [@Gerald\_DeConto](https://discuss.elastic.co/u/Gerald_DeConto)\
**Post date:** [April 5, 2015, 3:05pm UTC](https://discuss.elastic.co/t/unable-to-get-script-fields-to-work/22416/6 "2015-04-05T15:05:44Z")

</div>

Will try that when I get a chance.thx

On 4:52am, Apr 5, 2015, at 4:52am, Wouter van Atteveldt [vanatteveldt@gmail.com](mailto:vanatteveldt@gmail.com) wrote:

> I had the same problem, but I think that the docs are plain wrong, and  
> it  
> should be script instead of script\_file. In any case, if I do that it  
> works  
> fine.
> 
> I've posted an issue under  
> [parameter script\_file does not seem to work (but "script": "script\_file\_name" does) · Issue #10438 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues/10438)
> 
> Test program and session:  
> [test\_script\_file.sh · GitHub](https://gist.github.com/vanatteveldt/59ff5730b025270e8035)
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/4GOnbUeWw6c/unsubscribe](https://groups.google.com/d/topic/elasticsearch/4GOnbUeWw6c/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/8d826037-1247-4c9d-b566-aaa59cf090fe%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8d826037-1247-4c9d-b566-aaa59cf090fe%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0cd6d3ca-0b54-4665-85c0-0cfcddf3e919%40email.typeapp.com](https://groups.google.com/d/msgid/elasticsearch/0cd6d3ca-0b54-4665-85c0-0cfcddf3e919%40email.typeapp.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:21am UTC](https://discuss.elastic.co/t/unable-to-get-script-fields-to-work/22416/7 "2017-07-06T00:21:40Z")

</div>


