Script_lang not supported [groovy] error for script_fields

I am running an elasticsearch instance (from elasticsearch master code) on localhost.

I ran this query -

{
       "query" : {
             "match_all": {}
        },
        "script_fields": {
           "test": {
              "script": "_source.<field>"
           }
        }
 }

and this is the error I got -

{
   "error": {
      "root_cause": [
         {
            "type": "illegal_argument_exception",
            "reason": "script_lang not supported [groovy]"
         }
      ],
      "type": "search_phase_execution_exception",
      "reason": "all shards failed",
      "phase": "query",
      "grouped": true,
      "failed_shards": [
         {
            "shard": 0,
            "index": "<index_name>",
            "node": "XF48sEINTJu_JmWBWzTEKw",
            "reason": {
               "type": "illegal_argument_exception",
               "reason": "script_lang not supported [groovy]"
            }
         }
      ],
      "caused_by": {
         "type": "illegal_argument_exception",
         "reason": "script_lang not supported [groovy]"
      }
   },
   "status": 400
}

The solutions on internet is suggesting to add groovy dependency but I think master code already declares it. (Since I added groovy 2.4.6 as a dependency which gave an error of version conflict as 2.4.4 is already declared)

If you want to enable inline groovy script you'll need to add this lines to your config/elasticsearch.yml file on every node:

script.inline: true

You can check this page for further information:
https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html

Thanks for the help!
I have added these lines in distribution/src/main/resources/config/elasticsearch.yml

script.inline: true
script.indexed: true

elasticsearch is still giving the same error.

Where do we have to place the .groovy scripts ?

core/src/main/resources/config/scripts
Is this path correct?