Skip to content

Commit

Permalink
Remove include_type_name parameter from REST layer (#48632)
Browse files Browse the repository at this point in the history
This commit removes support for the include_type_name parameter from all
REST actions that receive or return mapping configurations.

Relates to #41059
  • Loading branch information
romseygeek authored Nov 1, 2019
1 parent d92f362 commit 37a997a
Show file tree
Hide file tree
Showing 39 changed files with 85 additions and 829 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,5 @@ private static void toXContent(GetFieldMappingsResponse response, XContentBuilde
}
builder.endObject();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@
import org.elasticsearch.action.admin.indices.rollover.MaxSizeCondition;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.common.xcontent.ToXContent.Params;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -38,7 +35,6 @@
import java.util.Map;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.Collections;

import static org.elasticsearch.test.AbstractXContentTestCase.xContentTester;

Expand Down Expand Up @@ -83,8 +79,6 @@ private Predicate<String> getRandomFieldsExcludeFilter() {
}

private static void toXContent(RolloverResponse response, XContentBuilder builder) throws IOException {
Params params = new ToXContent.MapParams(
Collections.singletonMap(BaseRestHandler.INCLUDE_TYPE_NAME_PARAMETER, "false"));
org.elasticsearch.action.admin.indices.rollover.RolloverResponse serverResponse =
new org.elasticsearch.action.admin.indices.rollover.RolloverResponse(
response.getOldIndex(),
Expand All @@ -95,6 +89,6 @@ private static void toXContent(RolloverResponse response, XContentBuilder builde
response.isAcknowledged(),
response.isShardsAcknowledged()
);
serverResponse.toXContent(builder, params);
serverResponse.toXContent(builder, null);
}
}
2 changes: 0 additions & 2 deletions docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -550,14 +550,12 @@ for (int i = 0; i < 5; i++) {
buildRestTests.setups['library'] = '''
- do:
indices.create:
include_type_name: true
index: library
body:
settings:
number_of_shards: 1
number_of_replicas: 1
mappings:
book:
properties:
name:
type: text
Expand Down
30 changes: 7 additions & 23 deletions docs/reference/mapping/removal_of_types.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ See some examples of interactions with Elasticsearch with this option set to `fa

[source,console]
--------------------------------------------------
PUT index?include_type_name=false
PUT index
{
"mappings": {
"properties": { <1>
Expand All @@ -472,7 +472,7 @@ PUT index?include_type_name=false

[source,console]
--------------------------------------------------
PUT index/_mappings?include_type_name=false
PUT index/_mappings
{
"properties": { <1>
"bar": {
Expand All @@ -487,7 +487,7 @@ PUT index/_mappings?include_type_name=false

[source,console]
--------------------------------------------------
GET index/_mappings?include_type_name=false
GET index/_mappings
--------------------------------------------------
// TEST[continued]

Expand Down Expand Up @@ -622,28 +622,12 @@ PUT _template/template1
}
}
PUT _template/template2?include_type_name=true
PUT index-1-01
{
"index_patterns":[ "index-2-*" ],
"mappings": {
"type": {
"properties": {
"foo": {
"type": "keyword"
}
}
}
}
}
PUT index-1-01?include_type_name=true
{
"mappings": {
"type": {
"properties": {
"bar": {
"type": "long"
}
"properties": {
"bar": {
"type": "long"
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions docs/reference/mapping/types/date_nanos.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ For instance:

[source,console]
--------------------------------------------------
PUT my_index?include_type_name=true
PUT my_index
{
"mappings": {
"_doc": {
"properties": {
"date": {
"type": "date_nanos" <1>
}
"properties": {
"date": {
"type": "date_nanos" <1>
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ setup:

- do:
indices.create:
include_type_name: false
index: test_nanos
body:
mappings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,3 @@
properties:
"":
type: keyword

---
"Create index with explicit _doc type":

- do:
catch: bad_request
indices.create:
index: test_index
body:
mappings:
_doc:
properties:
field:
type: keyword

- match: { error.type: "illegal_argument_exception" }
- match: { error.reason: "The mapping definition cannot be nested under a type [_doc] unless include_type_name is set to true." }

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -229,21 +229,3 @@
indices.put_template:
name: test
body: {}

---
"Put template with explicit _doc type":

- do:
catch: bad_request
indices.put_template:
name: test
body:
index_patterns: test-*
mappings:
_doc:
properties:
field:
type: keyword

- match: { error.type: "illegal_argument_exception" }
- match: { error.reason: "The mapping definition cannot be nested under a type [_doc] unless include_type_name is set to true." }

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,3 @@
- match: { conditions: { "[max_docs: 2]": true } }
- match: { rolled_over: true }

---
"Mappings with explicit _doc type":
- do:
indices.create:
index: logs-1
body:
aliases:
logs_search: {}

- do:
catch: bad_request
indices.rollover:
alias: "logs_search"
body:
conditions:
max_docs: 2
mappings:
_doc:
properties:
field:
type: keyword

- match: { error.caused_by.type: "illegal_argument_exception" }
- match: { error.caused_by.reason: "The mapping definition cannot be nested under a type [_doc] unless include_type_name is set to true." }
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
setup:
- do:
indices.create:
include_type_name: false
index: test_1
body:
settings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ setup:

- do:
indices.create:
include_type_name: false
index: test_1
body:
settings:
Expand Down
Loading

0 comments on commit 37a997a

Please sign in to comment.