From a4ea7e72234b480f89e8c59bb12061be11172db1 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Thu, 18 Aug 2016 12:36:53 +0200 Subject: [PATCH] Switch indices.exists_type from `{index}/{type}` to `{index}/_mapping/{type}`. #20055 This will help remove types as we will need `{index}/{id}` to tell whether a document exists. Relates #15613 --- .../rest/action/admin/indices/RestTypesExistsAction.java | 4 +++- docs/reference/indices/indices-exists.asciidoc | 4 +++- docs/reference/indices/types-exists.asciidoc | 4 +++- docs/reference/migration/migrate_5_0/rest.asciidoc | 7 +++++++ .../resources/rest-api-spec/api/indices.exists_type.json | 4 ++-- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestTypesExistsAction.java b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestTypesExistsAction.java index 791fc0eee39..3877715395c 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestTypesExistsAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/admin/indices/RestTypesExistsAction.java @@ -46,7 +46,9 @@ public class RestTypesExistsAction extends BaseRestHandler { @Inject public RestTypesExistsAction(Settings settings, RestController controller) { super(settings); - controller.registerHandler(HEAD, "/{index}/{type}", this); + controller.registerWithDeprecatedHandler( + HEAD, "/{index}/_mapping/{type}", this, + HEAD, "/{index}/{type}", deprecationLogger); } @Override diff --git a/docs/reference/indices/indices-exists.asciidoc b/docs/reference/indices/indices-exists.asciidoc index 1ffb1074a5a..184c649c279 100644 --- a/docs/reference/indices/indices-exists.asciidoc +++ b/docs/reference/indices/indices-exists.asciidoc @@ -5,8 +5,10 @@ Used to check if the index (indices) exists or not. For example: [source,js] -------------------------------------------------- -curl -XHEAD -i 'http://localhost:9200/twitter' +HEAD twitter -------------------------------------------------- +// CONSOLE +// TEST[setup:twitter] The HTTP status code indicates if the index exists or not. A `404` means it does not exist, and `200` means it does. diff --git a/docs/reference/indices/types-exists.asciidoc b/docs/reference/indices/types-exists.asciidoc index 739e0e9bf37..29a9be29e05 100644 --- a/docs/reference/indices/types-exists.asciidoc +++ b/docs/reference/indices/types-exists.asciidoc @@ -5,8 +5,10 @@ Used to check if a type/types exists in an index/indices. [source,js] -------------------------------------------------- -curl -XHEAD -i 'http://localhost:9200/twitter/tweet' +HEAD twitter/_mapping/tweet -------------------------------------------------- +// CONSOLE +// TEST[setup:twitter] The HTTP status code indicates if the type exists or not. A `404` means it does not exist, and `200` means it does. diff --git a/docs/reference/migration/migrate_5_0/rest.asciidoc b/docs/reference/migration/migrate_5_0/rest.asciidoc index 36f4071ce15..218bfb8f236 100644 --- a/docs/reference/migration/migrate_5_0/rest.asciidoc +++ b/docs/reference/migration/migrate_5_0/rest.asciidoc @@ -20,6 +20,13 @@ The `GET` HTTP verb for `/_forcemerge` is no longer supported, please use the It used to be possible to create an index by either calling `PUT index_name` or `POST index_name`. Only the former is now supported. +==== `HEAD {index}/{type}` replaced with `HEAD {index}/_mapping/{type}` + +The endpoint for checking whether a type exists has been changed from +`{index}/{type}` to `{index}/_mapping/{type}` in order to prepare for the +removal of types when `HEAD {index}/{id}` will be used to check whether a +document exists in an index. The old endpoint will keep working until 6.0. + ==== Removed `mem` section from `/_cluster/stats` response The `mem` section contained only one value, the total memory available diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.exists_type.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.exists_type.json index 37d9d979fa5..d793199bc27 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.exists_type.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.exists_type.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-types-exists.html", "methods": ["HEAD"], "url": { - "path": "/{index}/{type}", - "paths": ["/{index}/{type}"], + "path": "/{index}/_mapping/{type}", + "paths": ["/{index}/_mapping/{type}"], "parts": { "index": { "type" : "list",