1

I'm trying to reference a groovy script file that I created, and getting unable to find (see below). I didn't have a config directory, and elasticsearch.yml is in etc/elasticsearch. I added config/scripts/ under usr/share/elasticsearch so I now have /usr/share/elasticsearch/config/scripts/.

In there, I placed my script- 'source_types.groovy', which I ran chown elasticsearch:elasticsearch on to ensure the user called elasticsearch owns it.

I also put a config/scripts/source_types.groovy in etc/elasticsearch.

I am trying to call the script as follows:

GET nr-01/_search
{
  "query": {
    "filtered": {
      "filter": {
        "script": {
          "file": "source_types.groovy",
          "lang": "groovy"
        }
      }
    }
  }
}

and I'm getting

nested: SearchParseException[[nr-01][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  \"query\": {\n    \"filtered\": {\n      \"filter\": {\n        \"script\": {\n          \"file\": \"source_types.groovy\",\n          \"lang\": \"groovy\"\n        }\n      }\n    }\n  }\n}\n]]]; nested: ElasticsearchIllegalArgumentException[Unable to find on disk script source_types.groovy]; }]",
   "status": 400

Obviously the file can't be found. Where does the script go? Am I calling it correctly?

6
  • If you remove the extension from the name of the file, like "file": "source_types", do you see any difference? Commented Jun 18, 2015 at 6:49
  • Also, try putting your *.groovy files under /etc/elasticsearch/scripts folder (meaning omitting config). Commented Jun 18, 2015 at 6:57
  • @AndreiStefan I just figured out that the scripts should be under /etc/elasticsearch/scripts folder as you suggested. I came back to answer my question but since you answered it, if you put it as an answer, I'll mark it correct. thanks. BTW I'm gonna put in another related question so be on the lookout! thx! :-) Commented Jun 18, 2015 at 7:08
  • Wow - annoying - I wanted to post a different question to avoid adding to this one because really this one is answer but I'm told by stack overflow that I can only post once in 90 minutes. that's a long time to wait for a follow-up question! I'm getting responses from 2 out of 3 nodes in the cluster but the file isn't being found on the 3rd node, but it's on all nodes with same name and permissions! Commented Jun 18, 2015 at 7:17
  • So, you have the exact file on all three nodes in the same location, but you get responses only from two nodes? Commented Jun 18, 2015 at 7:25

1 Answer 1

2

Put your *.groovy files under /etc/elasticsearch/scripts folder (meaning omitting config).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.