Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I list all stored scripts on an Elasticsearch cluster?

I would like to be able to list all of the scripts stored on a given Elasticsearch cluster.

The elasticsearch documentation has clear examples for how to create, retrieve, use and delete a script with a particular name. Unfortunately, there is no mention of a list endpoint.

The following do not work (at least in Elasticsearch 5.4.1):

  • GET _cat/scripts
  • GET _scripts
  • GET _scripts/
like image 723
billkw Avatar asked Jul 11 '18 16:07

billkw


People also ask

Can you store queries in Elasticsearch?

Introducing: Stored Queries for Elasticsearch Whether you’re looking to secure your ElasticSearch DSL queries from script injection over the network, or creating REST endpoints for your search queries, the Stored Query feature from appbase.iohas got you covered!

How do I view all the shards in an Elasticsearch cluster?

To view all the shards in an Elasticsearch cluster, you can use the GE request at the _cat/shards API endpoint, as follows: If you are a cURL user, use the following command:

What is a script in Elasticsearch?

The script is a standard JSON object that defines scripts under most APIs in Elasticsearch. This object requires source to define the script itself. The script doesn’t specify a language, so it defaults to Painless. Use parameters in your script edit

Why does Elasticsearch use painless?

The script doesn’t specify a language, so it defaults to Painless. The first time Elasticsearch sees a new script, it compiles the script and stores the compiled version in a cache. Compilation can be a heavy process. Rather than hard-coding values in your script, pass them as named params instead.


2 Answers

as the metadata output could be huge, use the filter_path to display the scripts only:

GET _cluster/state/metadata?pretty&filter_path=**.stored_scripts
like image 53
jetnet Avatar answered Oct 01 '22 01:10

jetnet


Per the Elastic forums, this content is embedded in the response to GET _cluster/state/metadata

like image 36
billkw Avatar answered Oct 01 '22 01:10

billkw