get-stored-script-api.asciidoc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. [[get-stored-script-api]]
  2. === Get stored script API
  3. ++++
  4. <titleabbrev>Get stored script</titleabbrev>
  5. ++++
  6. Retrieves a <<script-stored-scripts,stored script>> or <<search-template,search
  7. template>>.
  8. ////
  9. [source,console]
  10. ----
  11. PUT _scripts/my-stored-script
  12. {
  13. "script": {
  14. "lang": "painless",
  15. "source": """
  16. TimestampHour date = doc['@timestamp'].value;
  17. return date.getHour()
  18. """
  19. }
  20. }
  21. ----
  22. ////
  23. [source,console]
  24. ----
  25. GET _scripts/my-stored-script
  26. ----
  27. // TEST[continued]
  28. [[get-stored-script-api-request]]
  29. ==== {api-request-title}
  30. `GET _scripts/<script-id>`
  31. [[get-stored-script-api-prereqs]]
  32. ==== {api-prereq-title}
  33. * If the {es} {security-features} are enabled, you must have the `manage`
  34. <<privileges-list-cluster,cluster privilege>> to use this API.
  35. [[get-stored-script-api-path-params]]
  36. ==== {api-path-parms-title}
  37. `<script-id>`::
  38. (Required, string)
  39. Identifier for the stored script or search template.
  40. [[get-stored-script-api-query-params]]
  41. ==== {api-query-parms-title}
  42. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]