rest-api-compatibility.asciidoc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. [[rest-api-compatibility]]
  2. == REST API compatibility
  3. To help REST clients mitigate the impact of non-compatible (breaking)
  4. API changes, {es} provides a per-request, opt-in API compatibility mode.
  5. {es} REST APIs are generally stable across versions. However, some
  6. improvements require changes that are not compatible with previous versions.
  7. For example, {es} 7.x supported custom mapping types in many URL paths,
  8. but {es} 8.0+ does not (see <<removal-of-types>>). Specifying a custom type
  9. in a request sent to {es} 8.0+ returns an error. However, if you request
  10. REST API compatibility, {es} accepts the request even though mapping types
  11. are no longer supported.
  12. When an API is targeted for removal or is going to be changed in a
  13. non-compatible way, the original API is deprecated for one or more releases.
  14. Using the original API triggers a deprecation warning in the logs.
  15. This enables you to review the deprecation logs and take the appropriate actions
  16. before upgrading. However, in some cases it is difficult to
  17. identify all places where deprecated APIs are being used. This is where REST API
  18. compatibility can help.
  19. When you request REST API compatibility, {es} attempts to honor the previous
  20. REST API version. {es} attempts to apply the most compatible URL, request body,
  21. response body, and HTTP parameters.
  22. For compatible APIs, this has no effect--it only impacts calls to APIs
  23. that have breaking changes from the previous version. An error can still be
  24. returned in compatibility mode if {es} cannot automatically resolve the incompatibilities.
  25. IMPORTANT: REST API compatibility does not guarantee the same behavior
  26. as the prior version. It instructs {es} to automatically resolve any
  27. incompatibilities so the request can be processed instead of returning an error.
  28. REST API compatibility should be a bridge to smooth out the upgrade process,
  29. not a long term strategy. REST API compatibility is only honored across one
  30. major version: honor 7.x requests/responses from 8.x.
  31. When you submit requests using REST API compatibility and {es} resolves
  32. the incompatibility, a message is written to the deprecation log with
  33. the category "compatible_api". Review the deprecation log to identify
  34. any gaps in usage and fully supported features.
  35. For information about specific breaking changes and the impact of requesting
  36. compatibility mode, see <<breaking_80_rest_api_changes, REST API changes>>
  37. in the migration guide.
  38. [discrete]
  39. [[request-rest-api-compatibility]]
  40. === Requesting REST API compatibility
  41. REST API compatibility is implemented per request via the Accept
  42. and/or Content-Type headers.
  43. For example:
  44. [source, text]
  45. ------------------------------------------------------------
  46. Accept: "application/vnd.elasticsearch+json;compatible-with=7"
  47. Content-Type: "application/vnd.elasticsearch+json;compatible-with=7"
  48. ------------------------------------------------------------
  49. The Accept header is always required and the Content-Type header is
  50. only required when a body is sent with the request. The following values are
  51. valid when communicating with a 7.x or 8.x {es} server:
  52. [source, text]
  53. ------------------------------------------------------------
  54. "application/vnd.elasticsearch+json;compatible-with=7"
  55. "application/vnd.elasticsearch+yaml;compatible-with=7"
  56. "application/vnd.elasticsearch+smile;compatible-with=7"
  57. "application/vnd.elasticsearch+cbor;compatible-with=7"
  58. ------------------------------------------------------------
  59. The https://www.elastic.co/guide/en/elasticsearch/client/index.html[officially supported {es} clients]
  60. can enable REST API compatibility for all requests.
  61. To enable REST API compatibility for all requests received
  62. by {es} set the environment variable `ELASTIC_CLIENT_APIVERSIONING` to true.
  63. [discrete]
  64. === REST API compatibility workflow
  65. To leverage REST API compatibility during an upgrade from 7.17 to {version}:
  66. 1. Upgrade your https://www.elastic.co/guide/en/elasticsearch/client/index.html[{es} clients]
  67. to the latest 7.x version and enable REST API compatibility.
  68. 2. Use the {kibana-ref-all}/{prev-major-last}/upgrade-assistant.html[Upgrade Assistant]
  69. to review all critical issues and explore the deprecation logs.
  70. Some critical issues might be mitigated by REST API compatibility.
  71. 3. Resolve all critical issues before proceeding with the upgrade.
  72. 4. Upgrade Elasticsearch to {version}.
  73. 5. Review the deprecation logs for entries with the category `compatible_api`.
  74. Review the workflow associated with the requests that relied on compatibility mode.
  75. 6. Upgrade your {es} clients to 8.x and resolve compatibility issues manually where needed.