| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 | [[breaking_50_scripting]]=== Script related changes==== Indexed scripts and templatesIndexed scrips and templates have been replaced by <<modules-scripting-stored-scripts,stored scripts>>which stores the scripts and templates in the cluster state instead of a dedicate `.scripts` index.For the size of stored scripts there is a soft limit of 65535 bytes. If scripts exceed that size thenthe `script.max_size_in_bytes` setting can be added to elasticsearch.yml to change the soft limit to a higher value.If scripts are really large, other options like native scripts should be considered.Previously indexed scripts in the `.scripts` index will not be used any more asElasticsearch will now try to fetch the scripts from the cluster state. Upon upgradingto 5.x the `.scripts` index will remain to exist, so it can be used by a script to migratethe stored scripts from the `.scripts` index into the cluster state. The format of the scriptshasn't changed.The following Python script can be used to import your indexed scripts into the cluster stateas stored scripts:[source,python]-----------------------------------from elasticsearch import Elasticsearch,helperses = Elasticsearch([	{'host': 'localhost'}])for doc in helpers.scan(es, index=".scripts", preserve_order=True):	es.put_script(lang=doc['_type'], id=doc['_id'], body=doc['_source'])-----------------------------------This script makes use of the official Elasticsearch Python client andtherefor you need to make sure that your have installed the client in yourenvironment. For more information on this please visit thehttps://www.elastic.co/guide/en/elasticsearch/client/python-api/current/index.html[elasticsearch-py page].After you have moved the scripts via the provided script or otherwise then you can verify with the followingrequest if the migration has happened successfully:[source,js]-----------------------------------GET _cluster/state?filter_path=metadata.stored_scripts-----------------------------------The response should include all your scripts from the `.scripts` index.After you have verified that all your scripts have been moved, optionally as a last step,you can delete the `.scripts` index as Elasticsearch no longer uses it.==== Indexed scripts Java APIsAll the methods related to interacting with indexed scripts have been removed.The Java API methods for interacting with stored scripts have been added under `ClusterAdminClient` class.The sugar methods that used to exist on the indexed scripts API methods don't exist on the methods forstored scripts. The only way to provide scripts is by using `BytesReference` implementation, if a string needs to beprovided the `BytesArray` class should be used.
 |