| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 | [[rest-api-compatibility]]== REST API compatibilityTo help REST clients mitigate the impact of non-compatible (breaking)API changes, {es} provides a per-request, opt-in API compatibility mode.{es} REST APIs are generally stable across versions. However, someimprovements require changes that are not compatible with previous versions.For example, {es} 7.x supported custom mapping types in many URL paths,but {es} 8.0+ does not (see <<removal-of-types>>). Specifying a custom typein a request sent to {es} 8.0+ returns an error. However, if you requestREST API compatibility, {es} accepts the request even though mapping typesare no longer supported.When an API is targeted for removal or is going to be changed in anon-compatible way, the original API is deprecated for one or more releases.Using the original API triggers a deprecation warning in the logs.This enables you to review the deprecation logs  and take the appropriate actionsbefore upgrading. However, in some cases it is difficult toidentify all places where deprecated APIs are being used. This is where REST APIcompatibility can help.When you request REST API compatibility, {es} attempts to honor the previousREST API version. {es} attempts to apply the most compatible URL, request body,response body, and HTTP parameters.For compatible APIs, this has no effect--it only impacts calls to APIsthat have breaking changes from the previous version. An error can still bereturned in compatibility mode if {es} cannot automatically resolve the incompatibilities.IMPORTANT: REST API compatibility does not guarantee the same behavioras the prior version. It instructs {es} to automatically resolve anyincompatibilities so the request can be processed instead of returning an error.REST API compatibility should be a bridge to smooth out the upgrade process,not a long term strategy. REST API compatibility is only honored across onemajor version: honor 7.x requests/responses from 8.x.When you submit requests using REST API compatibility and {es} resolvesthe incompatibility, a message is written to the deprecation log withthe category "compatible_api". Review the deprecation log to identifyany gaps in usage and fully supported features.For information about specific breaking changes and the impact of requestingcompatibility mode, see <<breaking_80_rest_api_changes, REST API changes>>in the migration guide.[discrete][[request-rest-api-compatibility]]=== Requesting REST API compatibilityREST API compatibility is implemented per request via the Acceptand/or Content-Type headers.For example:[source, text]------------------------------------------------------------Accept: "application/vnd.elasticsearch+json;compatible-with=7"Content-Type: "application/vnd.elasticsearch+json;compatible-with=7"------------------------------------------------------------The Accept header is always required and the Content-Type header isonly required when a body is sent with the request. The following values arevalid when communicating with a 7.x or 8.x {es} server:[source, text]------------------------------------------------------------"application/vnd.elasticsearch+json;compatible-with=7""application/vnd.elasticsearch+yaml;compatible-with=7""application/vnd.elasticsearch+smile;compatible-with=7""application/vnd.elasticsearch+cbor;compatible-with=7"------------------------------------------------------------The https://www.elastic.co/guide/en/elasticsearch/client/index.html[officially supported {es} clients]can enable REST API compatibility for all requests.To enable REST API compatibility for all requests receivedby {es} set the environment variable `ELASTIC_CLIENT_APIVERSIONING` to true.[discrete]=== REST API compatibility workflowTo leverage REST API compatibility during an upgrade from 7.17 to {version}:1. Upgrade your https://www.elastic.co/guide/en/elasticsearch/client/index.html[{es} clients]to the latest 7.x version and enable REST API compatibility.2. Use the {kibana-ref-all}/{prev-major-last}/upgrade-assistant.html[Upgrade Assistant]to review all critical issues and explore the deprecation logs.Some critical issues might be mitigated by REST API compatibility.3. Resolve all critical issues before proceeding with the upgrade.4. Upgrade Elasticsearch to {version}.5. Review the deprecation logs for entries with the category `compatible_api`.Review the workflow associated with the requests that relied on compatibility mode.6. Upgrade your {es} clients to 8.x and resolve compatibility issues manually where needed.
 |