The error message you are receiving indicates that dynamic scripting is disabled, which is the default setting. You need to enable to get scripting to work:
Enabling dynamic scripting
We recommend running Elasticsearch behind an application or proxy,
which protects Elasticsearch from the outside world. If users are
allowed to run dynamic scripts (even in a search request), then they
have the same access to your box as the user that Elasticsearch is
running as. For this reason dynamic scripting is allowed only for
sandboxed languages by default.
First, you should not run Elasticsearch as the root user, as this
would allow a script to access or do anything on your server, without
limitations. Second, you should not expose Elasticsearch directly to
users, but instead have a proxy application inbetween. If you do
intend to expose Elasticsearch directly to your users, then you have
to decide whether you trust them enough to run scripts on your box or
not. If you do, you can enable dynamic scripting by adding the
following setting to the config/elasticsearch.yml file on every node:
script.disable_dynamic: false
While this still allows execution of named scripts provided in the
config, or native Java scripts registered through plugins, it also
allows users to run arbitrary scripts via the API. Instead of sending
the name of the file as the script, the body of the script can be sent
instead.
There are three possible configuration values for the
script.disable_dynamic setting, the default value is sandbox:
true: all dynamic scripting is disabled, scripts must be placed in the
config/scripts directory.
false: all dynamic scripting is enabled, scripts may be sent as
strings in requests.
sandbox: scripts may be sent as strings for languages that are
sandboxed.
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html