Browse Source

Removes typed URLs from mapping APIs (#41676)

Relates to #41059
Colin Goodheart-Smithe 6 years ago
parent
commit
a574a66a21
31 changed files with 68 additions and 1917 deletions
  1. 0 102
      client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java
  2. 0 3
      docs/reference/indices.asciidoc
  3. 0 16
      docs/reference/indices/types-exists.asciidoc
  4. 7 0
      docs/reference/migration/migrate_8_0/mappings.asciidoc
  5. 7 1
      docs/reference/redirects.asciidoc
  6. 0 16
      modules/transport-netty4/src/test/java/org/elasticsearch/rest/Netty4HeadBodyIsEmptyIT.java
  7. 0 46
      rest-api-spec/src/main/resources/rest-api-spec/api/indices.get_field_mapping.json
  8. 0 42
      rest-api-spec/src/main/resources/rest-api-spec/api/indices.get_mapping.json
  9. 0 145
      rest-api-spec/src/main/resources/rest-api-spec/api/indices.put_mapping.json
  10. 0 141
      rest-api-spec/src/main/resources/rest-api-spec/test/indices.create/11_basic_with_types.yml
  11. 0 120
      rest-api-spec/src/main/resources/rest-api-spec/test/indices.create/20_mix_typeless_typeful.yml
  12. 0 83
      rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/11_basic_with_types.yml
  13. 0 23
      rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/21_missing_field_with_types.yml
  14. 0 22
      rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/30_missing_type.yml
  15. 0 144
      rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/51_field_wildcards_with_types.yml
  16. 0 21
      rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/60_mix_typeless_typeful.yml
  17. 0 158
      rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/11_basic_with_types.yml
  18. 0 106
      rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/20_missing_type.yml
  19. 0 1
      rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/40_aliases.yml
  20. 0 20
      rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/61_empty_with_types.yml
  21. 0 19
      rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/70_mix_typeless_typeful.yml
  22. 28 0
      rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/10_basic.yml
  23. 0 74
      rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/11_basic_with_types.yml
  24. 0 77
      rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/20_mix_typeless_typeful.yml
  25. 0 227
      rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/all_path_options_with_types.yml
  26. 0 1
      rest-api-spec/src/main/resources/rest-api-spec/test/search/110_field_collapsing.yml
  27. 9 16
      server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingAction.java
  28. 8 80
      server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java
  29. 9 29
      server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java
  30. 0 86
      server/src/test/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingActionTests.java
  31. 0 98
      server/src/test/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingActionTests.java

+ 0 - 102
client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java

@@ -100,12 +100,9 @@ import org.elasticsearch.index.query.QueryBuilder;
 import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.rest.RestStatus;
 import org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction;
-import org.elasticsearch.rest.action.admin.indices.RestGetFieldMappingAction;
 import org.elasticsearch.rest.action.admin.indices.RestGetIndexTemplateAction;
 import org.elasticsearch.rest.action.admin.indices.RestGetIndicesAction;
-import org.elasticsearch.rest.action.admin.indices.RestGetMappingAction;
 import org.elasticsearch.rest.action.admin.indices.RestPutIndexTemplateAction;
-import org.elasticsearch.rest.action.admin.indices.RestPutMappingAction;
 import org.elasticsearch.rest.action.admin.indices.RestRolloverIndexAction;
 
 import java.io.IOException;
@@ -541,31 +538,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
             getIndexResponse));
     }
 
-    public void testPutMappingWithTypes() throws IOException {
-        String indexName = "mapping_index";
-        createIndex(indexName, Settings.EMPTY);
-
-        org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest =
-            new org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest(indexName);
-        putMappingRequest.type("some_type");
-
-        XContentBuilder mappingBuilder = JsonXContent.contentBuilder();
-        mappingBuilder.startObject().startObject("properties").startObject("field");
-        mappingBuilder.field("type", "text");
-        mappingBuilder.endObject().endObject().endObject();
-        putMappingRequest.source(mappingBuilder);
-
-        AcknowledgedResponse putMappingResponse = execute(putMappingRequest,
-            highLevelClient().indices()::putMapping,
-            highLevelClient().indices()::putMappingAsync,
-            expectWarnings(RestPutMappingAction.TYPES_DEPRECATION_MESSAGE));
-        assertTrue(putMappingResponse.isAcknowledged());
-
-        Map<String, Object> getIndexResponse = getAsMap(indexName);
-        assertEquals("text", XContentMapValues.extractValue(indexName + ".mappings.properties.field.type",
-            getIndexResponse));
-    }
-
     public void testGetMapping() throws IOException {
         String indexName = "test";
         createIndex(indexName, Settings.EMPTY);
@@ -602,44 +574,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
         assertThat(mappings, equalTo(expected));
     }
 
-    public void testGetMappingWithTypes() throws IOException {
-        String indexName = "test";
-        createIndex(indexName, Settings.EMPTY);
-
-        PutMappingRequest putMappingRequest = new PutMappingRequest(indexName);
-        XContentBuilder mappingBuilder = JsonXContent.contentBuilder();
-        mappingBuilder.startObject().startObject("properties").startObject("field");
-        mappingBuilder.field("type", "text");
-        mappingBuilder.endObject().endObject().endObject();
-        putMappingRequest.source(mappingBuilder);
-
-        AcknowledgedResponse putMappingResponse = execute(putMappingRequest,
-            highLevelClient().indices()::putMapping,
-            highLevelClient().indices()::putMappingAsync);
-        assertTrue(putMappingResponse.isAcknowledged());
-
-        Map<String, Object> getIndexResponse = getAsMap(indexName);
-        assertEquals("text", XContentMapValues.extractValue(indexName + ".mappings.properties.field.type", getIndexResponse));
-
-        org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest request =
-            new org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest().indices(indexName);
-
-        org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse getMappingsResponse = execute(
-            request,
-            highLevelClient().indices()::getMapping,
-            highLevelClient().indices()::getMappingAsync,
-            expectWarnings(RestGetMappingAction.TYPES_DEPRECATION_MESSAGE));
-
-        Map<String, Object> mappings = getMappingsResponse.getMappings().get(indexName).get("_doc").sourceAsMap();
-        Map<String, String> type = new HashMap<>();
-        type.put("type", "text");
-        Map<String, Object> field = new HashMap<>();
-        field.put("field", type);
-        Map<String, Object> expected = new HashMap<>();
-        expected.put("properties", field);
-        assertThat(mappings, equalTo(expected));
-    }
-
     public void testGetFieldMapping() throws IOException {
         String indexName = "test";
         createIndex(indexName, Settings.EMPTY);
@@ -673,42 +607,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
         assertThat(fieldMappingMap, equalTo(Collections.singletonMap("field", metaData)));
     }
 
-    public void testGetFieldMappingWithTypes() throws IOException {
-        String indexName = "test";
-        createIndex(indexName, Settings.EMPTY);
-
-        PutMappingRequest putMappingRequest = new PutMappingRequest(indexName);
-        XContentBuilder mappingBuilder = JsonXContent.contentBuilder();
-        mappingBuilder.startObject().startObject("properties").startObject("field");
-        mappingBuilder.field("type", "text");
-        mappingBuilder.endObject().endObject().endObject();
-        putMappingRequest.source(mappingBuilder);
-
-        AcknowledgedResponse putMappingResponse =
-            execute(putMappingRequest, highLevelClient().indices()::putMapping, highLevelClient().indices()::putMappingAsync);
-        assertTrue(putMappingResponse.isAcknowledged());
-
-        org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest getFieldMappingsRequest =
-            new org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest()
-            .indices(indexName)
-            .types("_doc")
-            .fields("field");
-
-        org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse getFieldMappingsResponse =
-            execute(getFieldMappingsRequest,
-                highLevelClient().indices()::getFieldMapping,
-                highLevelClient().indices()::getFieldMappingAsync,
-                expectWarnings(RestGetFieldMappingAction.TYPES_DEPRECATION_MESSAGE));
-
-        final Map<String, org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetaData>
-            fieldMappingMap = getFieldMappingsResponse.mappings().get(indexName).get("_doc");
-
-        final  org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetaData metaData =
-            new  org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetaData("field",
-                new BytesArray("{\"field\":{\"type\":\"text\"}}"));
-        assertThat(fieldMappingMap, equalTo(Collections.singletonMap("field", metaData)));
-    }
-
     public void testDeleteIndex() throws IOException {
         {
             // Delete index if exists

+ 0 - 3
docs/reference/indices.asciidoc

@@ -29,7 +29,6 @@ index settings, aliases, mappings, and index templates.
 * <<indices-put-mapping>>
 * <<indices-get-mapping>>
 * <<indices-get-field-mapping>>
-* <<indices-types-exists>>
 
 [float]
 [[alias-management]]
@@ -102,8 +101,6 @@ include::indices/get-mapping.asciidoc[]
 
 include::indices/get-field-mapping.asciidoc[]
 
-include::indices/types-exists.asciidoc[]
-
 include::indices/add-alias.asciidoc[]
 
 include::indices/delete-alias.asciidoc[]

+ 0 - 16
docs/reference/indices/types-exists.asciidoc

@@ -1,16 +0,0 @@
-[[indices-types-exists]]
-=== Types Exists
-
-deprecated[7.0.0, Types are deprecated and are in the process of being removed.  See <<removal-of-types>>.]
-
-Used to check if a type/types exists in an index/indices.
-
-[source,console]
---------------------------------------------------
-HEAD twitter/_mapping/tweet
---------------------------------------------------
-// TEST[setup:twitter]
-// TEST[warning:Type exists requests are deprecated, as types have been deprecated.]
-
-The HTTP status code indicates if the type exists or not. A `404` means
-it does not exist, and `200` means it does.

+ 7 - 0
docs/reference/migration/migrate_8_0/mappings.asciidoc

@@ -15,6 +15,13 @@
 The number of completion contexts within a single completion field
 has been limited to 10.
 
+[float]
+==== Removal of types
+
+The typed REST endpoints of the Put Mapping, Get Mapping and Get Field mapping
+APIs have been removed in favour of their typeless REST endpoints, since indexes
+no longer contain types, these typed endpoints are obsolete.
+
 [float]
 ==== Defining multi-fields within multi-fields
 

+ 7 - 1
docs/reference/redirects.asciidoc

@@ -616,6 +616,12 @@ The `common` terms query is deprecated. Use the <<query-dsl-match-query, `match`
 query>> instead. The `match` query skips blocks of documents efficiently,
 without any configuration, if the total number of hits is not tracked.
 
+[role="exclude",id="indices-types-exists"]
+=== Types Exists
+
+The types exists endpoint has been removed. See <<removal-of-types>> for
+more details.
+
 [role="exclude",id="xpack-api"]
 === X-Pack APIs
 
@@ -902,4 +908,4 @@ See <<transform-source>>.
 [role="exclude",id="data-frame-transform-pivot"]
 ==== Pivot objects
 
-See <<transform-pivot>>.
+See <<transform-pivot>>.

+ 0 - 16
modules/transport-netty4/src/test/java/org/elasticsearch/rest/Netty4HeadBodyIsEmptyIT.java

@@ -73,22 +73,6 @@ public class Netty4HeadBodyIsEmptyIT extends ESRestTestCase {
         headTestCase("/test", singletonMap("pretty", "true"), greaterThan(0));
     }
 
-    public void testTypeExists() throws IOException {
-        createTestDoc();
-        headTestCase("/test/_mapping/_doc", emptyMap(), OK.getStatus(), greaterThan(0),
-                "Type exists requests are deprecated, as types have been deprecated.");
-        headTestCase("/test/_mapping/_doc", singletonMap("pretty", "true"), OK.getStatus(), greaterThan(0),
-                "Type exists requests are deprecated, as types have been deprecated.");
-    }
-
-    public void testTypeDoesNotExist() throws IOException {
-        createTestDoc();
-        headTestCase("/test/_mapping/does-not-exist", emptyMap(), NOT_FOUND.getStatus(), greaterThan(0),
-                "Type exists requests are deprecated, as types have been deprecated.");
-        headTestCase("/text/_mapping/test,does-not-exist", emptyMap(), NOT_FOUND.getStatus(), greaterThan(0),
-                "Type exists requests are deprecated, as types have been deprecated.");
-    }
-
     public void testAliasExists() throws IOException {
         createTestDoc();
         try (XContentBuilder builder = jsonBuilder()) {

+ 0 - 46
rest-api-spec/src/main/resources/rest-api-spec/api/indices.get_field_mapping.json

@@ -34,52 +34,6 @@
               "description":"A comma-separated list of fields"
             }
           }
-        },
-        {
-          "path":"/_mapping/{type}/field/{fields}",
-          "methods":[
-            "GET"
-          ],
-          "parts":{
-            "type":{
-              "type":"list",
-              "description":"A comma-separated list of document types",
-              "deprecated":true
-            },
-            "fields":{
-              "type":"list",
-              "description":"A comma-separated list of fields"
-            }
-          },
-          "deprecated":{
-            "version":"7.0.0",
-            "description":"Specifying types in urls has been deprecated"
-          }
-        },
-        {
-          "path":"/{index}/_mapping/{type}/field/{fields}",
-          "methods":[
-            "GET"
-          ],
-          "parts":{
-            "index":{
-              "type":"list",
-              "description":"A comma-separated list of index names"
-            },
-            "type":{
-              "type":"list",
-              "description":"A comma-separated list of document types",
-              "deprecated":true
-            },
-            "fields":{
-              "type":"list",
-              "description":"A comma-separated list of fields"
-            }
-          },
-          "deprecated":{
-            "version":"7.0.0",
-            "description":"Specifying types in urls has been deprecated"
-          }
         }
       ]
     },

+ 0 - 42
rest-api-spec/src/main/resources/rest-api-spec/api/indices.get_mapping.json

@@ -24,52 +24,10 @@
               "description":"A comma-separated list of index names"
             }
           }
-        },
-        {
-          "path":"/_mapping/{type}",
-          "methods":[
-            "GET"
-          ],
-          "parts":{
-            "type":{
-              "type":"list",
-              "description":"A comma-separated list of document types",
-              "deprecated":true
-            }
-          },
-          "deprecated":{
-            "version":"7.0.0",
-            "description":"Specifying types in urls has been deprecated"
-          }
-        },
-        {
-          "path":"/{index}/_mapping/{type}",
-          "methods":[
-            "GET"
-          ],
-          "parts":{
-            "index":{
-              "type":"list",
-              "description":"A comma-separated list of index names"
-            },
-            "type":{
-              "type":"list",
-              "description":"A comma-separated list of document types",
-              "deprecated":true
-            }
-          },
-          "deprecated":{
-            "version":"7.0.0",
-            "description":"Specifying types in urls has been deprecated"
-          }
         }
       ]
     },
     "params":{
-      "include_type_name":{
-        "type":"boolean",
-        "description":"Whether to add the type name to the response (default: false)"
-      },
       "ignore_unavailable":{
         "type":"boolean",
         "description":"Whether specified concrete indices should be ignored when unavailable (missing or closed)"

+ 0 - 145
rest-api-spec/src/main/resources/rest-api-spec/api/indices.put_mapping.json

@@ -19,155 +19,10 @@
               "description":"A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices."
             }
           }
-        },
-        {
-          "path":"/{index}/{type}/_mapping",
-          "methods":[
-            "PUT",
-            "POST"
-          ],
-          "parts":{
-            "index":{
-              "type":"list",
-              "description":"A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices."
-            },
-            "type":{
-              "type":"string",
-              "description":"The name of the document type",
-              "deprecated":true
-            }
-          },
-          "deprecated":{
-            "version":"7.0.0",
-            "description":"Specifying types in urls has been deprecated"
-          }
-        },
-        {
-          "path":"/{index}/_mapping/{type}",
-          "methods":[
-            "PUT",
-            "POST"
-          ],
-          "parts":{
-            "index":{
-              "type":"list",
-              "description":"A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices."
-            },
-            "type":{
-              "type":"string",
-              "description":"The name of the document type",
-              "deprecated":true
-            }
-          },
-          "deprecated":{
-            "version":"7.0.0",
-            "description":"Specifying types in urls has been deprecated"
-          }
-        },
-        {
-          "path":"/{index}/{type}/_mappings",
-          "methods":[
-            "PUT",
-            "POST"
-          ],
-          "parts":{
-            "index":{
-              "type":"list",
-              "description":"A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices."
-            },
-            "type":{
-              "type":"string",
-              "description":"The name of the document type",
-              "deprecated":true
-            }
-          },
-          "deprecated":{
-            "version":"7.0.0",
-            "description":"Specifying types in urls has been deprecated"
-          }
-        },
-        {
-          "path":"/{index}/_mappings/{type}",
-          "methods":[
-            "PUT",
-            "POST"
-          ],
-          "parts":{
-            "index":{
-              "type":"list",
-              "description":"A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices."
-            },
-            "type":{
-              "type":"string",
-              "description":"The name of the document type",
-              "deprecated":true
-            }
-          },
-          "deprecated":{
-            "version":"7.0.0",
-            "description":"Specifying types in urls has been deprecated"
-          }
-        },
-        {
-          "path":"/_mappings/{type}",
-          "methods":[
-            "PUT",
-            "POST"
-          ],
-          "parts":{
-            "type":{
-              "type":"string",
-              "description":"The name of the document type",
-              "deprecated":true
-            }
-          },
-          "deprecated":{
-            "version":"7.0.0",
-            "description":"Specifying types in urls has been deprecated"
-          }
-        },
-        {
-          "path":"{index}/_mappings",
-          "methods":[
-            "PUT",
-            "POST"
-          ],
-          "parts":{
-            "index":{
-              "type":"list",
-              "description":"A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices."
-            }
-          },
-          "deprecated":{
-            "version":"7.0.0",
-            "description":"The plural mappings is accepted but only /_mapping is documented"
-          }
-        },
-        {
-          "path":"/_mapping/{type}",
-          "methods":[
-            "PUT",
-            "POST"
-          ],
-          "parts":{
-            "type":{
-              "type":"string",
-              "description":"The name of the document type",
-              "deprecated":true
-            }
-          },
-          "deprecated":{
-            "version":"7.0.0",
-            "description":"Specifying types in urls has been deprecated"
-          }
         }
       ]
     },
     "params":{
-      "include_type_name":{
-        "type":"boolean",
-        "description":"Whether a type should be expected in the body of the mappings."
-      },
       "timeout":{
         "type":"time",
         "description":"Explicit operation timeout"

+ 0 - 141
rest-api-spec/src/main/resources/rest-api-spec/test/indices.create/11_basic_with_types.yml

@@ -1,141 +0,0 @@
----
-"Create index with mappings":
-
-  - do:
-      indices.create:
-        include_type_name: true
-        index: test_index
-        body:
-          mappings:
-            type_1: {}
-
-  - do:
-      indices.get_mapping:
-        include_type_name: true
-        index: test_index
-
-  - is_true: test_index.mappings.type_1
-
----
-"Create index with settings":
-
-  - do:
-      indices.create:
-        include_type_name: true
-        index: test_index
-        body:
-          settings:
-            number_of_replicas: "0"
-
-  - do:
-      indices.get_settings:
-        index: test_index
-
-  - match: { test_index.settings.index.number_of_replicas: "0"}
-
----
-"Create index":
-
-  - do:
-      indices.create:
-        include_type_name: true
-        index: test_index
-
-  - match: { acknowledged: true }
-  - match: { index: "test_index"}
-
----
-"Create index with wait_for_active_shards set to all":
-
-  - do:
-      indices.create:
-        include_type_name: true
-        index: test_index
-        wait_for_active_shards: all
-        body:
-          settings:
-            number_of_replicas: "0"
-
-  - match: { acknowledged: true }
-  - match: { shards_acknowledged: true }
-
----
-"Create index with aliases":
-
-  - do:
-      indices.create:
-        include_type_name: true
-        index: test_index
-        body:
-          mappings:
-            type_1:
-              properties:
-                field:
-                  type: text
-          aliases:
-            test_alias: {}
-            test_blias:
-              routing: b
-            test_clias:
-              filter:
-                term:
-                  field : value
-
-  - do:
-      indices.get_alias:
-        index: test_index
-
-  - match: {test_index.aliases.test_blias.search_routing: b}
-  - match: {test_index.aliases.test_blias.index_routing: b}
-  - is_false: test_index.aliases.test_blias.filter
-  - match: {test_index.aliases.test_clias.filter.term.field: value}
-  - is_false: test_index.aliases.test_clias.index_routing
-  - is_false: test_index.aliases.test_clias.search_routing
-
----
-"Create index with write aliases":
-
-  - do:
-      indices.create:
-        include_type_name: true
-        index: test_index
-        body:
-          aliases:
-            test_alias: {}
-            test_blias:
-              is_write_index: false
-            test_clias:
-              is_write_index: true
-
-  - do:
-      indices.get_alias:
-        index: test_index
-
-  - is_false: test_index.aliases.test_alias.is_write_index
-  - is_false: test_index.aliases.test_blias.is_write_index
-  - is_true: test_index.aliases.test_clias.is_write_index
-
----
-"Create index with no type mappings":
-  - do:
-      catch: /illegal_argument_exception/
-      indices.create:
-        include_type_name: true
-        index: test_index
-        body:
-          mappings:
-           "" : {}
-
----
-"Create index with invalid mappings":
-  - do:
-      catch: /illegal_argument_exception/
-      indices.create:
-        include_type_name: true
-        index: test_index
-        body:
-          mappings:
-            test_type:
-              properties:
-                "":
-                  type:     keyword

+ 0 - 120
rest-api-spec/src/main/resources/rest-api-spec/test/indices.create/20_mix_typeless_typeful.yml

@@ -1,120 +0,0 @@
----
-"Create a typeless index while there is a typed template":
- - do:
-      indices.put_template:
-          include_type_name: true
-          name: test_template
-          body:
-              index_patterns: test-*
-              mappings:
-                  my_type:
-                      properties:
-                          foo:
-                              type: keyword
-
- - do:
-      indices.create:
-          index: test-1
-          body:
-              mappings:
-                  properties:
-                      bar:
-                          type: "long"
-
- - do:
-      indices.get_mapping:
-          include_type_name: true
-          index: test-1
-
- - is_true: test-1.mappings._doc # the index creation call won
- - is_false: test-1.mappings.my_type
- - is_true: test-1.mappings._doc.properties.foo
- - is_true: test-1.mappings._doc.properties.bar
-
----
-"Create a typed index while there is a typeless template":
- - do:
-      indices.put_template:
-          include_type_name: false
-          name: test_template
-          body:
-              index_patterns: test-*
-              mappings:
-                  properties:
-                      foo:
-                          type: keyword
-
- - do:
-      indices.create: 
-          include_type_name: true
-          index: test-1
-          body:
-              mappings:
-                  my_type:
-                      properties:
-                          bar:
-                              type: "long"
-
- - do:
-      indices.get_mapping:
-          include_type_name: true
-          index: test-1
-
- - is_true: test-1.mappings.my_type # the index creation call won
- - is_false: test-1.mappings._doc
- - is_true: test-1.mappings.my_type.properties.foo
- - is_true: test-1.mappings.my_type.properties.bar
-
----
-"Implicitly create a typed index while there is a typeless template":
- - do:
-      indices.put_template:
-          include_type_name: false
-          name: test_template
-          body:
-              index_patterns: test-*
-              mappings:
-                  properties:
-                      foo:
-                          type: keyword
-
- - do:
-      catch: /the final mapping would have more than 1 type/
-      index:
-          index: test-1
-          type: my_type
-          body: { bar: 42 }
-
----
-"Implicitly create a typeless index while there is a typed template":
- - do:
-      indices.put_template:
-          include_type_name: true
-          name: test_template
-          body:
-              index_patterns: test-*
-              mappings:
-                  my_type:
-                      properties:
-                          foo:
-                              type: keyword
-
- - do:
-      index:
-          index: test-1
-          body: { bar: 42 }
-
-# ensures dynamic mapping update is visible to get_mapping
- - do:
-     cluster.health:
-         wait_for_events: normal
-
- - do:
-      indices.get_mapping:
-          include_type_name: true
-          index: test-1
-
- - is_true: test-1.mappings.my_type # the template is honored
- - is_false: test-1.mappings._doc
- - is_true: test-1.mappings.my_type.properties.foo
- - is_true: test-1.mappings.my_type.properties.bar

+ 0 - 83
rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/11_basic_with_types.yml

@@ -1,83 +0,0 @@
----
-setup:
-  - do:
-        indices.create:
-          include_type_name: true
-          index: test_index
-          body:
-              mappings:
-                test_type:
-                  properties:
-                    text:
-                      type:     text
-
----
-"Get field mapping with no index and type":
-
-  - do:
-      indices.get_field_mapping:
-        include_type_name: true
-        fields: text
-
-  - match: {test_index.mappings.test_type.text.mapping.text.type:     text}
-
----
-"Get field mapping by index only":
-  - do:
-      indices.get_field_mapping:
-        include_type_name: true
-        index: test_index
-        fields: text
-
-  - match: {test_index.mappings.test_type.text.mapping.text.type:     text}
-
----
-"Get field mapping by type & field":
-
-  - do:
-      indices.get_field_mapping:
-        include_type_name: true
-        index: test_index
-        type: test_type
-        fields: text
-
-  - match: {test_index.mappings.test_type.text.mapping.text.type:     text}
-
----
-"Get field mapping by type & field, with another field that doesn't exist":
-
-  - do:
-      indices.get_field_mapping:
-        include_type_name: true
-        index: test_index
-        type: test_type
-        fields: [ text , text1 ]
-
-  - match: {test_index.mappings.test_type.text.mapping.text.type:     text}
-  - is_false: test_index.mappings.test_type.text1
-
----
-"Get field mapping with include_defaults":
-
-  - do:
-      indices.get_field_mapping:
-        include_type_name: true
-        index: test_index
-        type: test_type
-        fields: text
-        include_defaults: true
-
-  - match: {test_index.mappings.test_type.text.mapping.text.type:     text}
-  - match: {test_index.mappings.test_type.text.mapping.text.analyzer: default}
-
----
-"Get field mapping should work without index specifying type and fields":
-
-  - do:
-      indices.get_field_mapping:
-        include_type_name: true
-        type: test_type
-        fields: text
-
-  - match: {test_index.mappings.test_type.text.mapping.text.type:     text}
-

+ 0 - 23
rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/21_missing_field_with_types.yml

@@ -1,23 +0,0 @@
----
-"Return empty object if field doesn't exist, but type and index do":
-
-  - do:
-        indices.create:
-          include_type_name: true
-          index: test_index
-          body:
-              mappings:
-                test_type:
-                  properties:
-                    text:
-                      type:     text
-                      analyzer: whitespace
-
-  - do:
-      indices.get_field_mapping:
-        include_type_name: true
-        index: test_index
-        type: test_type
-        fields: not_existent
-
-  - match: { '': {}}

+ 0 - 22
rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/30_missing_type.yml

@@ -1,22 +0,0 @@
----
-"Raise 404 when type doesn't exist":
-
-  - do:
-        indices.create:
-          include_type_name: true
-          index: test_index
-          body:
-              mappings:
-                test_type:
-                  properties:
-                    text:
-                      type:     text
-                      analyzer: whitespace
-
-  - do:
-      catch: missing
-      indices.get_field_mapping:
-        include_type_name: true
-        index: test_index
-        type: not_test_type
-        fields: text

+ 0 - 144
rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/51_field_wildcards_with_types.yml

@@ -1,144 +0,0 @@
----
-setup:
-  - do:
-        indices.create:
-          include_type_name: true
-          index: test_index
-          body:
-              mappings:
-                test_type:
-                  properties:
-                    t1:
-                      type:     text
-                    t2:
-                      type:     text
-                    obj:
-                      properties:
-                        t1:
-                          type:   text
-                        i_t1:
-                          type:   text
-                        i_t3:
-                          type:   text
-
-  - do:
-        indices.create:
-          include_type_name: true
-          index: test_index_2
-          body:
-              mappings:
-                test_type_2:
-                  properties:
-                    t1:
-                      type:     text
-                    t2:
-                      type:     text
-                    obj:
-                      properties:
-                        t1:
-                          type:   text
-                        i_t1:
-                          type:   text
-                        i_t3:
-                          type:   text
-
----
-"Get field mapping with * for fields":
-
-  - do:
-      indices.get_field_mapping:
-        include_type_name: true
-        fields: "*"
-
-  - match: {test_index.mappings.test_type.t1.full_name:     t1     }
-  - match: {test_index.mappings.test_type.t2.full_name:     t2     }
-  - match: {test_index.mappings.test_type.obj\.t1.full_name: obj.t1 }
-  - match: {test_index.mappings.test_type.obj\.i_t1.full_name: obj.i_t1 }
-  - match: {test_index.mappings.test_type.obj\.i_t3.full_name: obj.i_t3 }
-
----
-"Get field mapping with t* for fields":
-
-  - do:
-      indices.get_field_mapping:
-        include_type_name: true
-        index: test_index
-        fields: "t*"
-
-  - match:  {test_index.mappings.test_type.t1.full_name:     t1       }
-  - match:  {test_index.mappings.test_type.t2.full_name:     t2       }
-  - length: {test_index.mappings.test_type: 2}
-
----
-"Get field mapping with *t1 for fields":
-
-  - do:
-      indices.get_field_mapping:
-        include_type_name: true
-        index: test_index
-        fields: "*t1"
-  - match:  {test_index.mappings.test_type.t1.full_name:        t1       }
-  - match:  {test_index.mappings.test_type.obj\.t1.full_name:   obj.t1   }
-  - match:  {test_index.mappings.test_type.obj\.i_t1.full_name: obj.i_t1 }
-  - length: {test_index.mappings.test_type: 3}
-
----
-"Get field mapping with wildcarded relative names":
-
-  - do:
-      indices.get_field_mapping:
-        include_type_name: true
-        index: test_index
-        fields: "obj.i_*"
-  - match:  {test_index.mappings.test_type.obj\.i_t1.full_name: obj.i_t1 }
-  - match:  {test_index.mappings.test_type.obj\.i_t3.full_name: obj.i_t3 }
-  - length: {test_index.mappings.test_type: 2}
-
----
-"Get field mapping should work using '_all' for indices and types":
-
-  - do:
-      indices.get_field_mapping:
-        include_type_name: true
-        index: _all
-        type: _all
-        fields: "t*"
-  - match:  {test_index.mappings.test_type.t1.full_name: t1 }
-  - match:  {test_index.mappings.test_type.t2.full_name: t2 }
-  - length: {test_index.mappings.test_type: 2}
-  - match:  {test_index_2.mappings.test_type_2.t1.full_name: t1 }
-  - match:  {test_index_2.mappings.test_type_2.t2.full_name: t2 }
-  - length: {test_index_2.mappings.test_type_2: 2}
-
----
-"Get field mapping should work using '*' for indices and types":
-
-  - do:
-      indices.get_field_mapping:
-        include_type_name: true
-        index: '*'
-        type: '*'
-        fields: "t*"
-  - match:  {test_index.mappings.test_type.t1.full_name: t1 }
-  - match:  {test_index.mappings.test_type.t2.full_name: t2 }
-  - length: {test_index.mappings.test_type: 2}
-  - match:  {test_index_2.mappings.test_type_2.t1.full_name: t1 }
-  - match:  {test_index_2.mappings.test_type_2.t2.full_name: t2 }
-  - length: {test_index_2.mappings.test_type_2: 2}
-
----
-"Get field mapping should work using comma_separated values for indices and types":
-
-  - do:
-      indices.get_field_mapping:
-        include_type_name: true
-        index: 'test_index,test_index_2'
-        type: 'test_type,test_type_2'
-        fields: "t*"
-  - match:  {test_index.mappings.test_type.t1.full_name: t1 }
-  - match:  {test_index.mappings.test_type.t2.full_name: t2 }
-  - length: {test_index.mappings.test_type: 2}
-  - match:  {test_index_2.mappings.test_type_2.t1.full_name: t1 }
-  - match:  {test_index_2.mappings.test_type_2.t2.full_name: t2 }
-  - length: {test_index_2.mappings.test_type_2: 2}
-

+ 0 - 21
rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_field_mapping/60_mix_typeless_typeful.yml

@@ -1,21 +0,0 @@
----
-"GET mapping with typeless API on an index that has types":
-
-  - do:
-      indices.create: # not using include_type_name: false on purpose
-        include_type_name: true
-        index: index
-        body:
-          mappings:
-            not_doc:
-              properties:
-                foo:
-                  type: "keyword"
-
-  - do:
-      indices.get_field_mapping:
-        include_type_name: false
-        index: index
-        fields: foo
-
-  - match: { index.mappings.foo.mapping.foo.type: "keyword" }

+ 0 - 158
rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/11_basic_with_types.yml

@@ -1,158 +0,0 @@
----
-setup:
-  - do:
-        indices.create:
-          include_type_name: true
-          index: test_1
-          body:
-              mappings:
-                doc: {}
-  - do:
-        indices.create:
-          include_type_name: true
-          index: test_2
-          body:
-              mappings:
-                doc: {}
----
-"Get /{index}/_mapping with empty mappings":
-
- - do:
-     indices.create:
-       index: t
-
- - do:
-     indices.get_mapping:
-       include_type_name: true
-       index: t
-
- - match: { t.mappings: {}}
-
----
-"Get /_mapping":
-
- - do:
-    indices.get_mapping:
-      include_type_name: true
-
- - is_true: test_1.mappings.doc
- - is_true: test_2.mappings.doc
-
----
-"Get /{index}/_mapping":
-
- - do:
-    indices.get_mapping:
-        include_type_name: true
-        index: test_1
-
- - is_true: test_1.mappings.doc
- - is_false: test_2
-
-
----
-"Get /{index}/_mapping/_all":
-
- - do:
-    indices.get_mapping:
-        include_type_name: true
-        index: test_1
-        type:  _all
-
- - is_true: test_1.mappings.doc
- - is_false: test_2
-
----
-"Get /{index}/_mapping/*":
-
- - do:
-    indices.get_mapping:
-        include_type_name: true
-        index: test_1
-        type:  '*'
-
- - is_true: test_1.mappings.doc
- - is_false: test_2
-
----
-"Get /{index}/_mapping/{type}":
-
- - do:
-    indices.get_mapping:
-        include_type_name: true
-        index: test_1
-        type:  doc
-
- - is_true: test_1.mappings.doc
- - is_false: test_2
-
----
-"Get /{index}/_mapping/{type*}":
-
- - do:
-    indices.get_mapping:
-        include_type_name: true
-        index: test_1
-        type:  'd*'
-
- - is_true: test_1.mappings.doc
- - is_false: test_2
-
----
-"Get /_mapping/{type}":
-
- - do:
-    indices.get_mapping:
-        include_type_name: true
-        type: doc
-
- - is_true: test_1.mappings.doc
- - is_true: test_2.mappings.doc
-
----
-"Get /_all/_mapping/{type}":
-
- - do:
-    indices.get_mapping:
-        include_type_name: true
-        index: _all
-        type: doc
-
- - is_true: test_1.mappings.doc
- - is_true: test_2.mappings.doc
-
----
-"Get /*/_mapping/{type}":
-
- - do:
-    indices.get_mapping:
-        include_type_name: true
-        index: '*'
-        type: doc
-
- - is_true: test_1.mappings.doc
- - is_true: test_2.mappings.doc
-
----
-"Get /index,index/_mapping/{type}":
-
- - do:
-    indices.get_mapping:
-        include_type_name: true
-        index: test_1,test_2
-        type: doc
-
- - is_true: test_1.mappings.doc
- - is_true: test_2.mappings.doc
-
----
-"Get /index*/_mapping/{type}":
-
- - do:
-    indices.get_mapping:
-        include_type_name: true
-        index: '*2'
-        type: doc
-
- - is_true: test_2.mappings.doc
- - is_false: test_1

+ 0 - 106
rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/20_missing_type.yml

@@ -1,106 +0,0 @@
----
-"Non-existent type returns 404":
-  - do:
-        indices.create:
-          include_type_name: true
-          index: test_index
-          body:
-              mappings:
-                test_type:
-                  properties:
-                    text:
-                      type:     text
-                      analyzer: whitespace
-
-  - do:
-      catch: missing
-      indices.get_mapping:
-        include_type_name: true
-        index: test_index
-        type: not_test_type
-
-  - match: { status: 404 }
-  - match: { error.reason: 'type[[not_test_type]] missing' }
-
----
-"No type matching pattern returns 404":
-  - do:
-        indices.create:
-          include_type_name: true
-          index: test_index
-          body:
-              mappings:
-                test_type:
-                  properties:
-                    text:
-                      type:     text
-                      analyzer: whitespace
-
-  - do:
-      catch: missing
-      indices.get_mapping:
-        include_type_name: true
-        index: test_index
-        type: test*,not*
-
-  - match: { status: 404 }
-  - match: { error: 'type [not*] missing' }
-  - is_true: test_index.mappings.test_type
-
----
-"Existent and non-existent type returns 404 and the existing type":
-  - do:
-        indices.create:
-          include_type_name: true
-          index: test_index
-          body:
-              mappings:
-                test_type:
-                  properties:
-                    text:
-                      type:     text
-                      analyzer: whitespace
-
-  - do:
-      catch: missing
-      indices.get_mapping:
-        include_type_name: true
-        index: test_index
-        type: test_type,not_test_type
-
-  - match: { status: 404 }
-  - match: { error: 'type [not_test_type] missing' }
-  - is_true: test_index.mappings.test_type
-
----
-"Existent and non-existent types returns 404 and the existing type":
-  - do:
-        indices.create:
-          include_type_name: true
-          index: test_index
-          body:
-              mappings:
-                test_type:
-                  properties:
-                    text:
-                      type:     text
-                      analyzer: whitespace
-
-  - do:
-      catch: missing
-      indices.get_mapping:
-        include_type_name: true
-        index: test_index
-        type: test_type,not_test_type,another_not_test_type
-
-  - match: { status: 404 }
-  - match: { error: 'types [another_not_test_type,not_test_type] missing' }
-  - is_true: test_index.mappings.test_type
-
----
-"Type missing when no types exist":
-  - do:
-      catch: missing
-      indices.get_mapping:
-        include_type_name: true
-        type: not_test_type

+ 0 - 1
rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/40_aliases.yml

@@ -18,7 +18,6 @@
 
   - do:
       indices.get_mapping:
-        include_type_name: false
         index: test_alias
 
   - match: {test_index.mappings.properties.text.type:     text}

+ 0 - 20
rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/61_empty_with_types.yml

@@ -1,20 +0,0 @@
----
-setup:
-
-  - do:
-      indices.create:
-        index: test_1
-
-  - do:
-      indices.create:
-        index: test_2
-
----
-"Check empty mapping when getting all mappings via /_mapping":
-
- - do:
-    indices.get_mapping:
-      include_type_name: true
-
- - match: { test_1.mappings: {}}
- - match: { test_2.mappings: {}}

+ 0 - 19
rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/70_mix_typeless_typeful.yml

@@ -1,19 +0,0 @@
----
-"GET mapping with typeless API on an index that has types":
-
- - do:
-      indices.create: # not using include_type_name: false on purpose
-          include_type_name: true
-          index: index
-          body:
-              mappings:
-                  not_doc:
-                      properties:
-                          foo:
-                              type: "keyword"
-
- - do:
-      indices.get_mapping:
-          index: index
-
- - match: { index.mappings.properties.foo.type: "keyword" }

+ 28 - 0
rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/10_basic.yml

@@ -64,6 +64,9 @@
 
 ---
 "Put mappings with explicit _doc type":
+  - skip:
+          version:     " - 7.99.99"
+          reason:      "deprecation message changed in 8.0"
   - do:
       indices.create:
         index: test_index
@@ -78,5 +81,30 @@
               field:
                 type: keyword
 
+  - match: { error.type: "illegal_argument_exception" }
+  - match: { error.reason: "Types cannot be provided in put mapping requests" }
+
+---
+"Put mappings with explicit _doc type bwc":
+  - skip:
+          version:     "8.0.0 - "
+          reason:      "old deprecation message for pre 8.0"
+          features:    "node_selector"
+  - do:
+      indices.create:
+        index: test_index
+
+  - do:
+      node_selector:
+        version: " - 7.99.99"
+      catch: bad_request
+      indices.put_mapping:
+        index: test_index
+        body:
+          _doc:
+            properties:
+              field:
+                type: keyword
+
   - match: { error.type: "illegal_argument_exception" }
   - match: { error.reason: "Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true." }

+ 0 - 74
rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/11_basic_with_types.yml

@@ -1,74 +0,0 @@
----
-"Test Create and update mapping":
-  - do:
-      indices.create:
-        index: test_index
-
-  - do:
-      indices.put_mapping:
-        include_type_name: true
-        index: test_index
-        type: test_type
-        body:
-          test_type:
-            properties:
-              text1:
-                type:     text
-                analyzer: whitespace
-              text2:
-                type:     text
-                analyzer: whitespace
-              subfield.text3:
-                type:     text
-
-  - do:
-      indices.get_mapping:
-        include_type_name: true
-        index: test_index
-  
-  - match: {test_index.mappings.test_type.properties.text1.type:     text}
-  - match: {test_index.mappings.test_type.properties.text1.analyzer: whitespace}
-  - match: {test_index.mappings.test_type.properties.text2.type:     text}
-  - match: {test_index.mappings.test_type.properties.text2.analyzer: whitespace}
-
-  - do:
-      indices.put_mapping:
-        include_type_name: true
-        index: test_index
-        type: test_type
-        body:
-          test_type:
-            properties:
-              text1:
-                type:     text
-                analyzer: whitespace
-                fields:
-                  text_raw:
-                    type:     keyword
-
-
-  - do:
-      indices.get_mapping:
-        include_type_name: true
-        index: test_index
-  
-  - match: {test_index.mappings.test_type.properties.text1.type:     text}
-  - match: {test_index.mappings.test_type.properties.subfield.properties.text3.type:     text}
-  - match: {test_index.mappings.test_type.properties.text1.fields.text_raw.type: keyword}
-
----
-"Create index with invalid mappings":
-  - do:
-      indices.create:
-        index: test_index
-  - do:
-      catch: /illegal_argument_exception/
-      indices.put_mapping:
-        include_type_name: true
-        index: test_index
-        type: test_type
-        body:
-          test_type:
-            properties:
-              "":
-               type:     keyword

+ 0 - 77
rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/20_mix_typeless_typeful.yml

@@ -1,77 +0,0 @@
----
-"PUT mapping with typeless API on an index that has types":
-
- - do:
-      indices.create: # not using include_type_name: false on purpose
-          include_type_name: true
-          index: index
-          body:
-              mappings:
-                  not_doc:
-                      properties:
-                          foo:
-                              type: "keyword"
-
- - do:
-      indices.put_mapping:
-          include_type_name: false
-          index: index
-          body:
-              properties:
-                  bar:
-                      type: "long"
-
- - do:
-      indices.get_mapping:
-          include_type_name: false
-          index: index
-
- - match: { index.mappings.properties.foo.type: "keyword" }
- - match: { index.mappings.properties.bar.type: "long" }
-
- - do:
-      indices.put_mapping:
-          include_type_name: false
-          index: index
-          body:
-              properties:
-                  foo:
-                      type: "keyword" # also test no-op updates that trigger special logic wrt the mapping version
-
- - do:
-      catch: /the final mapping would have more than 1 type/
-      indices.put_mapping:
-          include_type_name: true
-          index: index
-          type: some_other_type
-          body:
-              some_other_type:
-                  properties:
-                      bar:
-                          type: "long"
-
-
----
-"PUT mapping with _doc on an index that has types":
- - do:
-      indices.create:
-          include_type_name: true
-          index: index
-          body:
-              mappings:
-                  my_type:
-                      properties:
-                          foo:
-                              type: "keyword"
-
- - do:
-      catch: /the final mapping would have more than 1 type/
-      indices.put_mapping:
-          include_type_name: true
-          index: index
-          type: _doc
-          body:
-              _doc:
-                  properties:
-                      bar:
-                          type: "long"

+ 0 - 227
rest-api-spec/src/main/resources/rest-api-spec/test/indices.put_mapping/all_path_options_with_types.yml

@@ -1,227 +0,0 @@
-setup:
-  - do:
-      indices.create:
-        index: test_index1
-  - do:
-      indices.create:
-        index: test_index2
-  - do:
-      indices.create:
-        index: foo
-
-
----
-"put one mapping per index":
-  - do:
-      indices.put_mapping:
-        include_type_name: true
-        index: test_index1
-        type: test_type
-        body:
-          test_type:
-            properties:
-              text:
-                type:     text
-                analyzer: whitespace
-  - do:
-      indices.put_mapping:
-        include_type_name: true
-        index: test_index2
-        type: test_type
-        body:
-          test_type:
-            properties:
-              text:
-                type:     text
-                analyzer: whitespace
-
-
-  - do:
-      indices.get_mapping:
-        include_type_name: true
-
-  - match: {test_index1.mappings.test_type.properties.text.type:     text}
-  - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace}
-
-  - match: {test_index2.mappings.test_type.properties.text.type:     text}
-  - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace}
-
-  - match: { foo.mappings: {} }
-
----
-"put mapping in _all index":
-
-  - do:
-      indices.put_mapping:
-        include_type_name: true
-        index: _all
-        type: test_type
-        body:
-          test_type:
-            properties:
-              text:
-                type:     text
-                analyzer: whitespace
-
-  - do:
-      indices.get_mapping:
-        include_type_name: true
-
-  - match: {test_index1.mappings.test_type.properties.text.type:     text}
-  - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace}
-
-  - match: {test_index2.mappings.test_type.properties.text.type:     text}
-  - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace}
-
-  - match: {foo.mappings.test_type.properties.text.type:     text}
-  - match: {foo.mappings.test_type.properties.text.analyzer: whitespace}
-
----
-"put mapping in * index":
-  - do:
-      indices.put_mapping:
-        include_type_name: true
-        index: "*"
-        type: test_type
-        body:
-          test_type:
-            properties:
-              text:
-                type:     text
-                analyzer: whitespace
-
-  - do:
-      indices.get_mapping:
-        include_type_name: true
-
-  - match: {test_index1.mappings.test_type.properties.text.type:     text}
-  - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace}
-
-  - match: {test_index2.mappings.test_type.properties.text.type:     text}
-  - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace}
-
-  - match: {foo.mappings.test_type.properties.text.type:     text}
-  - match: {foo.mappings.test_type.properties.text.analyzer: whitespace}
-
----
-"put mapping in prefix* index":
-  - do:
-      indices.put_mapping:
-        include_type_name: true
-        index: "test_index*"
-        type: test_type
-        body:
-          test_type:
-            properties:
-              text:
-                type:     text
-                analyzer: whitespace
-
-  - do:
-      indices.get_mapping:
-        include_type_name: true
-
-  - match: {test_index1.mappings.test_type.properties.text.type:     text}
-  - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace}
-
-  - match: {test_index2.mappings.test_type.properties.text.type:     text}
-  - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace}
-
-  - match: { foo.mappings: {} }
-
----
-"put mapping in list of indices":
-  - do:
-      indices.put_mapping:
-        include_type_name: true
-        index: [test_index1, test_index2]
-        type: test_type
-        body:
-          test_type:
-            properties:
-              text:
-                type:     text
-                analyzer: whitespace
-
-  - do:
-      indices.get_mapping:
-        include_type_name: true
-
-  - match: {test_index1.mappings.test_type.properties.text.type:     text}
-  - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace}
-
-  - match: {test_index2.mappings.test_type.properties.text.type:     text}
-  - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace}
-
-  - match: { foo.mappings: {} }
-
----
-"put mapping with blank index":
-  - do:
-      indices.put_mapping:
-        include_type_name: true
-        type: test_type
-        body:
-          test_type:
-            properties:
-              text:
-                type:     text
-                analyzer: whitespace
-
-  - do:
-      indices.get_mapping:
-        include_type_name: true
-
-  - match: {test_index1.mappings.test_type.properties.text.type:     text}
-  - match: {test_index1.mappings.test_type.properties.text.analyzer: whitespace}
-
-  - match: {test_index2.mappings.test_type.properties.text.type:     text}
-  - match: {test_index2.mappings.test_type.properties.text.analyzer: whitespace}
-
-  - match: {foo.mappings.test_type.properties.text.type:     text}
-  - match: {foo.mappings.test_type.properties.text.analyzer: whitespace}
-
----
-"put mapping with missing type":
-
-
-  - do:
-      catch: param
-      indices.put_mapping:
-        include_type_name: true
-
----
-"post a mapping with default analyzer twice":
-
-  - do:
-      indices.put_mapping:
-        include_type_name: true
-        index: test_index1
-        type: test_type
-        body:
-          test_type:
-            dynamic: false
-            properties:
-              text:
-                analyzer: default
-                type:     text
-
-  - do:
-      indices.put_mapping:
-        include_type_name: true
-        index: test_index1
-        type: test_type
-        body:
-          test_type:
-            dynamic: false
-            properties:
-              text:
-                analyzer: default
-                type:     text
-
-  - do:
-      indices.get_mapping:
-        include_type_name: true
-
-  - match: {test_index1.mappings.test_type.properties.text.type:     text}
- 

+ 0 - 1
rest-api-spec/src/main/resources/rest-api-spec/test/search/110_field_collapsing.yml

@@ -366,7 +366,6 @@ setup:
 
   - do:
       indices.put_mapping:
-        include_type_name: false
         index: test
         body:
           properties:

+ 9 - 16
server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingAction.java

@@ -44,18 +44,13 @@ import static org.elasticsearch.rest.RestStatus.NOT_FOUND;
 import static org.elasticsearch.rest.RestStatus.OK;
 
 public class RestGetFieldMappingAction extends BaseRestHandler {
-
-    private static final DeprecationLogger deprecationLogger = new DeprecationLogger(
-        LogManager.getLogger(RestGetFieldMappingAction.class));
-    public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Using include_type_name in get " +
-        "field mapping requests is deprecated. The parameter will be removed in the next major version.";
+    private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestGetFieldMappingAction.class));
+    public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Using include_type_name in get "
+            + "field mapping requests is deprecated. The parameter will be removed in the next major version.";
 
     public RestGetFieldMappingAction(RestController controller) {
         controller.registerHandler(GET, "/_mapping/field/{fields}", this);
-        controller.registerHandler(GET, "/_mapping/{type}/field/{fields}", this);
         controller.registerHandler(GET, "/{index}/_mapping/field/{fields}", this);
-        controller.registerHandler(GET, "/{index}/{type}/_mapping/field/{fields}", this);
-        controller.registerHandler(GET, "/{index}/_mapping/{type}/field/{fields}", this);
     }
 
     @Override
@@ -66,20 +61,18 @@ public class RestGetFieldMappingAction extends BaseRestHandler {
     @Override
     public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
         final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
-        final String[] types = request.paramAsStringArrayOrEmptyIfAll("type");
         final String[] fields = Strings.splitStringByCommaToArray(request.param("fields"));
 
-        boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, DEFAULT_INCLUDE_TYPE_NAME_POLICY);
-        if (includeTypeName == false && types.length > 0) {
-            throw new IllegalArgumentException("Types cannot be specified unless include_type_name" +
-                " is set to true.");
-        }
         if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) {
+            boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, DEFAULT_INCLUDE_TYPE_NAME_POLICY);
+            if (includeTypeName) {
+                throw new IllegalArgumentException(INCLUDE_TYPE_NAME_PARAMETER + " no longer supports the value [true].");
+            }
             deprecationLogger.deprecatedAndMaybeLog("get_field_mapping_with_types", TYPES_DEPRECATION_MESSAGE);
         }
 
         GetFieldMappingsRequest getMappingsRequest = new GetFieldMappingsRequest();
-        getMappingsRequest.indices(indices).types(types).fields(fields).includeDefaults(request.paramAsBoolean("include_defaults", false));
+        getMappingsRequest.indices(indices).fields(fields).includeDefaults(request.paramAsBoolean("include_defaults", false));
         getMappingsRequest.indicesOptions(IndicesOptions.fromRequest(request, getMappingsRequest.indicesOptions()));
         getMappingsRequest.local(request.paramAsBoolean("local", getMappingsRequest.local()));
         return channel ->
@@ -88,7 +81,7 @@ public class RestGetFieldMappingAction extends BaseRestHandler {
                     public RestResponse buildResponse(GetFieldMappingsResponse response, XContentBuilder builder) throws Exception {
                         Map<String, Map<String, Map<String, FieldMappingMetaData>>> mappingsByIndex = response.mappings();
 
-                        boolean isPossibleSingleFieldRequest = indices.length == 1 && types.length == 1 && fields.length == 1;
+                boolean isPossibleSingleFieldRequest = indices.length == 1 && fields.length == 1;
                         if (isPossibleSingleFieldRequest && isFieldMappingMissingField(mappingsByIndex)) {
                             return new BytesRestResponse(OK, builder.startObject().endObject());
                         }

+ 8 - 80
server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java

@@ -19,21 +19,14 @@
 
 package org.elasticsearch.rest.action.admin.indices;
 
-import com.carrotsearch.hppc.cursors.ObjectCursor;
 import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
 import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest;
 import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
 import org.elasticsearch.action.support.IndicesOptions;
 import org.elasticsearch.client.node.NodeClient;
-import org.elasticsearch.cluster.metadata.MappingMetaData;
 import org.elasticsearch.common.Strings;
-import org.elasticsearch.common.collect.ImmutableOpenMap;
 import org.elasticsearch.common.logging.DeprecationLogger;
-import org.elasticsearch.common.regex.Regex;
-import org.elasticsearch.common.util.set.Sets;
 import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.indices.TypeMissingException;
 import org.elasticsearch.rest.BaseRestHandler;
 import org.elasticsearch.rest.BytesRestResponse;
 import org.elasticsearch.rest.RestController;
@@ -43,34 +36,19 @@ import org.elasticsearch.rest.RestStatus;
 import org.elasticsearch.rest.action.RestBuilderListener;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.stream.Collectors;
 
 import static org.elasticsearch.rest.RestRequest.Method.GET;
-import static org.elasticsearch.rest.RestRequest.Method.HEAD;
 
 public class RestGetMappingAction extends BaseRestHandler {
-    private static final Logger logger = LogManager.getLogger(RestGetMappingAction.class);
-    private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);
-    public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Using include_type_name in get" +
-        " mapping requests is deprecated. The parameter will be removed in the next major version.";
+    private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestGetMappingAction.class));
+    public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Using include_type_name in get"
+            + " mapping requests is deprecated. The parameter will be removed in the next major version.";
 
     public RestGetMappingAction(final RestController controller) {
         controller.registerHandler(GET, "/_mapping", this);
         controller.registerHandler(GET, "/_mappings", this);
-        controller.registerHandler(GET, "/{index}/{type}/_mapping", this);
         controller.registerHandler(GET, "/{index}/_mappings", this);
         controller.registerHandler(GET, "/{index}/_mapping", this);
-        controller.registerHandler(GET, "/{index}/_mappings/{type}", this);
-        controller.registerHandler(GET, "/{index}/_mapping/{type}", this);
-        controller.registerHandler(HEAD, "/{index}/_mapping/{type}", this);
-        controller.registerHandler(GET, "/_mapping/{type}", this);
     }
 
     @Override
@@ -81,74 +59,24 @@ public class RestGetMappingAction extends BaseRestHandler {
     @Override
     public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
         final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
-        final String[] types = request.paramAsStringArrayOrEmptyIfAll("type");
-        boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, DEFAULT_INCLUDE_TYPE_NAME_POLICY);
 
-        if (request.method().equals(HEAD)) {
-            deprecationLogger.deprecated("Type exists requests are deprecated, as types have been deprecated.");
-        } else if (includeTypeName == false && types.length > 0) {
-            throw new IllegalArgumentException("Types cannot be provided in get mapping requests, unless" +
-                " include_type_name is set to true.");
-        }
         if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) {
+            request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, DEFAULT_INCLUDE_TYPE_NAME_POLICY);
             deprecationLogger.deprecatedAndMaybeLog("get_mapping_with_types", TYPES_DEPRECATION_MESSAGE);
         }
 
         final GetMappingsRequest getMappingsRequest = new GetMappingsRequest();
-        getMappingsRequest.indices(indices).types(types);
+        getMappingsRequest.indices(indices);
         getMappingsRequest.indicesOptions(IndicesOptions.fromRequest(request, getMappingsRequest.indicesOptions()));
         getMappingsRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getMappingsRequest.masterNodeTimeout()));
         getMappingsRequest.local(request.paramAsBoolean("local", getMappingsRequest.local()));
-        return channel -> client.admin().indices().getMappings(getMappingsRequest, new RestBuilderListener<GetMappingsResponse>(channel) {
+        return channel -> client.admin().indices().getMappings(getMappingsRequest, new RestBuilderListener<>(channel) {
             @Override
             public RestResponse buildResponse(final GetMappingsResponse response, final XContentBuilder builder) throws Exception {
-                final ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappingsByIndex = response.getMappings();
-                if (mappingsByIndex.isEmpty() && types.length != 0) {
-                    builder.close();
-                    return new BytesRestResponse(channel, new TypeMissingException("_all", String.join(",", types)));
-                }
-
-                final Set<String> typeNames = new HashSet<>();
-                for (final ObjectCursor<ImmutableOpenMap<String, MappingMetaData>> cursor : mappingsByIndex.values()) {
-                    for (final ObjectCursor<String> inner : cursor.value.keys()) {
-                        typeNames.add(inner.value);
-                    }
-                }
-
-                final SortedSet<String> difference = Sets.sortedDifference(Arrays.stream(types).collect(Collectors.toSet()), typeNames);
-
-                // now remove requested aliases that contain wildcards that are simple matches
-                final List<String> matches = new ArrayList<>();
-                outer:
-                for (final String pattern : difference) {
-                    if (pattern.contains("*")) {
-                        for (final String typeName : typeNames) {
-                            if (Regex.simpleMatch(pattern, typeName)) {
-                                matches.add(pattern);
-                                continue outer;
-                            }
-                        }
-                    }
-                }
-                difference.removeAll(matches);
-
-                final RestStatus status;
                 builder.startObject();
-                {
-                    if (difference.isEmpty()) {
-                        status = RestStatus.OK;
-                    } else {
-                        status = RestStatus.NOT_FOUND;
-                        final String message = String.format(Locale.ROOT, "type" + (difference.size() == 1 ? "" : "s") +
-                            " [%s] missing", Strings.collectionToCommaDelimitedString(difference));
-                        builder.field("error", message);
-                        builder.field("status", status.getStatus());
-                    }
-                    response.toXContent(builder, request);
-                }
+                response.toXContent(builder, request);
                 builder.endObject();
-
-                return new BytesRestResponse(status, builder);
+                return new BytesRestResponse(RestStatus.OK, builder);
             }
         });
     }

+ 9 - 29
server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java

@@ -36,37 +36,21 @@ import java.io.IOException;
 import java.util.Map;
 
 import static org.elasticsearch.client.Requests.putMappingRequest;
-import static org.elasticsearch.index.mapper.MapperService.isMappingSourceTyped;
 import static org.elasticsearch.rest.RestRequest.Method.POST;
 import static org.elasticsearch.rest.RestRequest.Method.PUT;
 
 public class RestPutMappingAction extends BaseRestHandler {
-    private static final DeprecationLogger deprecationLogger = new DeprecationLogger(
-        LogManager.getLogger(RestPutMappingAction.class));
-    public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Using include_type_name in put " +
-        "mapping requests is deprecated. The parameter will be removed in the next major version.";
+    private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestPutMappingAction.class));
+    public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Using include_type_name in put "
+            + "mapping requests is deprecated. The parameter will be removed in the next major version.";
 
     public RestPutMappingAction(RestController controller) {
         controller.registerHandler(PUT, "/{index}/_mapping/", this);
-        controller.registerHandler(PUT, "/{index}/{type}/_mapping", this);
-        controller.registerHandler(PUT, "/{index}/_mapping/{type}", this);
-        controller.registerHandler(PUT, "/_mapping/{type}", this);
-
         controller.registerHandler(POST, "/{index}/_mapping/", this);
-        controller.registerHandler(POST, "/{index}/{type}/_mapping", this);
-        controller.registerHandler(POST, "/{index}/_mapping/{type}", this);
-        controller.registerHandler(POST, "/_mapping/{type}", this);
 
         //register the same paths, but with plural form _mappings
         controller.registerHandler(PUT, "/{index}/_mappings/", this);
-        controller.registerHandler(PUT, "/{index}/{type}/_mappings", this);
-        controller.registerHandler(PUT, "/{index}/_mappings/{type}", this);
-        controller.registerHandler(PUT, "/_mappings/{type}", this);
-
         controller.registerHandler(POST, "/{index}/_mappings/", this);
-        controller.registerHandler(POST, "/{index}/{type}/_mappings", this);
-        controller.registerHandler(POST, "/{index}/_mappings/{type}", this);
-        controller.registerHandler(POST, "/_mappings/{type}", this);
     }
 
     @Override
@@ -76,23 +60,19 @@ public class RestPutMappingAction extends BaseRestHandler {
 
     @Override
     public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
-        final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER,
-            DEFAULT_INCLUDE_TYPE_NAME_POLICY);
+        PutMappingRequest putMappingRequest = putMappingRequest(Strings.splitStringByCommaToArray(request.param("index")));
+
+        final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, DEFAULT_INCLUDE_TYPE_NAME_POLICY);
         if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) {
             deprecationLogger.deprecatedAndMaybeLog("put_mapping_with_types", TYPES_DEPRECATION_MESSAGE);
         }
 
-        PutMappingRequest putMappingRequest = putMappingRequest(Strings.splitStringByCommaToArray(request.param("index")));
-
-        final String type = request.param("type");
-        putMappingRequest.type(includeTypeName ? type : MapperService.SINGLE_MAPPING_NAME);
+        putMappingRequest.type(MapperService.SINGLE_MAPPING_NAME);
 
         Map<String, Object> sourceAsMap = XContentHelper.convertToMap(request.requiredContent(), false,
             request.getXContentType()).v2();
-        if (includeTypeName == false &&
-                (type != null || isMappingSourceTyped(MapperService.SINGLE_MAPPING_NAME, sourceAsMap))) {
-            throw new IllegalArgumentException("Types cannot be provided in put mapping requests, unless " +
-                "the include_type_name parameter is set to true.");
+        if (includeTypeName == false && MapperService.isMappingSourceTyped(MapperService.SINGLE_MAPPING_NAME, sourceAsMap)) {
+            throw new IllegalArgumentException("Types cannot be provided in put mapping requests");
         }
 
         putMappingRequest.source(sourceAsMap);

+ 0 - 86
server/src/test/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingActionTests.java

@@ -1,86 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.rest.action.admin.indices;
-
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.util.concurrent.ThreadContext;
-import org.elasticsearch.rest.RestRequest;
-import org.elasticsearch.rest.RestStatus;
-import org.elasticsearch.test.rest.FakeRestChannel;
-import org.elasticsearch.test.rest.FakeRestRequest;
-import org.elasticsearch.test.rest.RestActionTestCase;
-import org.junit.Before;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.elasticsearch.rest.BaseRestHandler.INCLUDE_TYPE_NAME_PARAMETER;
-
-public class RestGetFieldMappingActionTests extends RestActionTestCase {
-
-    @Before
-    public void setUpAction() {
-        new RestGetFieldMappingAction(controller());
-    }
-
-    public void testIncludeTypeName() {
-        Map<String, String> params = new HashMap<>();
-        String path;
-        if (randomBoolean()) {
-            params.put(INCLUDE_TYPE_NAME_PARAMETER, "true");
-            path = "some_index/some_type/_mapping/field/some_field";
-        } else {
-            params.put(INCLUDE_TYPE_NAME_PARAMETER, "false");
-            path = "some_index/_mapping/field/some_field";
-        }
-        RestRequest deprecatedRequest = new FakeRestRequest.Builder(xContentRegistry())
-            .withMethod(RestRequest.Method.GET)
-            .withPath(path)
-            .withParams(params)
-            .build();
-        dispatchRequest(deprecatedRequest);
-        assertWarnings(RestGetFieldMappingAction.TYPES_DEPRECATION_MESSAGE);
-
-        RestRequest validRequest = new FakeRestRequest.Builder(xContentRegistry())
-            .withMethod(RestRequest.Method.GET)
-            .withPath("some_index/_mapping/field/some_field")
-            .build();
-        dispatchRequest(validRequest);
-    }
-
-    public void testTypeInPath() {
-        // Test that specifying a type while setting include_type_name to false
-        // results in an illegal argument exception.
-        Map<String, String> params = new HashMap<>();
-        params.put(INCLUDE_TYPE_NAME_PARAMETER, "false");
-        RestRequest request = new FakeRestRequest.Builder(xContentRegistry())
-            .withMethod(RestRequest.Method.GET)
-            .withPath("some_index/some_type/_mapping/field/some_field")
-            .withParams(params)
-            .build();
-
-        FakeRestChannel channel = new FakeRestChannel(request, false, 1);
-        ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
-        controller().dispatchRequest(request, channel, threadContext);
-
-        assertEquals(1, channel.errors().get());
-        assertEquals(RestStatus.BAD_REQUEST, channel.capturedResponse().status());
-    }
-}

+ 0 - 98
server/src/test/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingActionTests.java

@@ -1,98 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.rest.action.admin.indices;
-
-import org.elasticsearch.client.node.NodeClient;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.util.concurrent.ThreadContext;
-import org.elasticsearch.rest.RestController;
-import org.elasticsearch.rest.RestRequest;
-import org.elasticsearch.rest.RestStatus;
-import org.elasticsearch.test.rest.FakeRestChannel;
-import org.elasticsearch.test.rest.FakeRestRequest;
-import org.elasticsearch.test.rest.RestActionTestCase;
-import org.junit.Before;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.elasticsearch.rest.BaseRestHandler.INCLUDE_TYPE_NAME_PARAMETER;
-import static org.mockito.Mockito.mock;
-
-public class RestGetMappingActionTests extends RestActionTestCase {
-
-    @Before
-    public void setUpAction() {
-        new RestGetMappingAction(controller());
-    }
-
-    public void testTypeExistsDeprecation() throws Exception {
-        Map<String, String> params = new HashMap<>();
-        params.put("type", "_doc");
-        RestRequest request = new FakeRestRequest.Builder(xContentRegistry())
-            .withMethod(RestRequest.Method.HEAD)
-            .withParams(params)
-            .build();
-
-        RestGetMappingAction handler = new RestGetMappingAction(mock(RestController.class));
-        handler.prepareRequest(request, mock(NodeClient.class));
-
-        assertWarnings("Type exists requests are deprecated, as types have been deprecated.");
-    }
-
-    public void testTypeInPath() {
-        // Test that specifying a type while setting include_type_name to false
-        // results in an illegal argument exception.
-        Map<String, String> params = new HashMap<>();
-        params.put(INCLUDE_TYPE_NAME_PARAMETER, "false");
-        RestRequest request = new FakeRestRequest.Builder(xContentRegistry())
-            .withMethod(RestRequest.Method.GET)
-            .withPath("some_index/some_type/_mapping/some_field")
-            .withParams(params)
-            .build();
-
-        FakeRestChannel channel = new FakeRestChannel(request, false, 1);
-        ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
-        controller().dispatchRequest(request, channel, threadContext);
-
-        assertEquals(1, channel.errors().get());
-        assertEquals(RestStatus.BAD_REQUEST, channel.capturedResponse().status());
-    }
-
-    /**
-     * Setting "include_type_name" to true or false should cause a deprecation warning starting in 7.0
-     */
-    public void testTypeUrlParameterDeprecation() throws Exception {
-        Map<String, String> params = new HashMap<>();
-        params.put(INCLUDE_TYPE_NAME_PARAMETER, Boolean.toString(randomBoolean()));
-        RestRequest request = new FakeRestRequest.Builder(xContentRegistry())
-            .withMethod(RestRequest.Method.GET)
-            .withParams(params)
-            .withPath("/some_index/_mappings")
-            .build();
-
-        FakeRestChannel channel = new FakeRestChannel(request, false, 1);
-        ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
-        controller().dispatchRequest(request, channel, threadContext);
-
-        assertWarnings(RestGetMappingAction.TYPES_DEPRECATION_MESSAGE);
-    }
-
-}