scripting.asciidoc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. ==== Stored search template apis removed
  26. The PUT, GET and DELETE `_search/template` apis have been removed. Store search templates with the stored scripts apis instead.
  27. For example, previously one might have stored a search template with the following:
  28. [source,js]
  29. --------------------------------------------------
  30. PUT /_search/template/my_template
  31. {
  32. "query": {
  33. "match": {
  34. "f1": "{{f1}}"
  35. }
  36. }
  37. }
  38. --------------------------------------------------
  39. And instead one would now use the following:
  40. [source,js]
  41. --------------------------------------------------
  42. PUT /_scripts/my_template
  43. {
  44. "script": {
  45. "lang": "mustache",
  46. "source": {
  47. "query": {
  48. "match": {
  49. "f1": "{{f1}}"
  50. }
  51. }
  52. }
  53. }
  54. }
  55. --------------------------------------------------