scripting.asciidoc 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. [[breaking_60_scripting_changes]]
  2. === Scripting changes
  3. ==== Groovy, JavaScript, and Python languages removed
  4. The Groovy, JavaScript, and Python scripting languages were deprecated in
  5. elasticsearch 5.0 and have now been removed. Use painless instead.
  6. ==== Native scripts removed
  7. Native scripts have been removed. Instead,
  8. <<modules-scripting-engine, implement a `ScriptEngine`>>.
  9. ==== Date fields now return dates
  10. `doc.some_date_field.value` now returns ++ReadableDateTime++s instead of
  11. milliseconds since epoch as a `long`. The same is true for
  12. `doc.some_date_field[some_number]`. Use `doc.some_date_field.value.millis` to
  13. fetch the milliseconds since epoch if you need it.
  14. ==== Removed access to index internal via the `_index` variable
  15. The `_index` variable has been removed. If you used it for advanced scoring, consider writing a `Similarity` plugin.
  16. ==== Script Settings
  17. All of the existing scripting security settings have been removed. Instead
  18. they are replaced with `script.allowed_types` and `script.allowed_contexts`.
  19. ==== `lang` can no longer be specified when using a stored script as part of a request
  20. The `lang` variable can no longer be specified as part of a request that uses a stored
  21. script otherwise an error will occur. Note that a request using a stored script is
  22. different from a request that puts a stored script. The language of the script has
  23. already been stored as part of the cluster state and an `id` is sufficient to access
  24. all of the information necessary to execute a stored script.
  25. ==== 'lang` can no longer be used when putting, getting, or deleting a stored script
  26. Stored scripts can no longer have the `lang` parameter specified as part of the url
  27. when performing PUT, GET, and DELETE actions on the `_scripts/` path. All stored
  28. scripts must have a unique `id` as the namespace is only `id` now and no longer `lang`
  29. and `id`.
  30. ==== Stored search template apis removed
  31. The PUT, GET and DELETE `_search/template` apis have been removed. Store search templates with the stored scripts apis instead.
  32. For example, previously one might have stored a search template with the following:
  33. [source,js]
  34. --------------------------------------------------
  35. PUT /_search/template/my_template
  36. {
  37. "query": {
  38. "match": {
  39. "f1": "{{f1}}"
  40. }
  41. }
  42. }
  43. --------------------------------------------------
  44. And instead one would now use the following:
  45. [source,js]
  46. --------------------------------------------------
  47. PUT /_scripts/my_template
  48. {
  49. "script": {
  50. "lang": "mustache",
  51. "source": {
  52. "query": {
  53. "match": {
  54. "f1": "{{f1}}"
  55. }
  56. }
  57. }
  58. }
  59. }
  60. --------------------------------------------------