Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the default for include_type_name to false. #37285

Merged
merged 21 commits into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
376dc7d
Add a constant for the default include_type_name value.
jtibshirani Jan 10, 2019
ddf73b9
Some minor clean-ups around the get index API.
jtibshirani Jan 11, 2019
83b4be1
Default include_type_name to false for get and put mappings.
jtibshirani Jan 10, 2019
b96d640
Default include_type_name to false for get field mappings.
jtibshirani Jan 10, 2019
776b097
Default include_type_name to false for get and put index templates.
jtibshirani Jan 10, 2019
2495ae7
Default include_type_name to false for create index.
jtibshirani Jan 11, 2019
8b74660
Update create index calls in REST documentation to use include_type_n…
jtibshirani Jan 11, 2019
0edfc3b
In REST tests, use include_type_name=true by default for index creation.
jtibshirani Jan 11, 2019
1f202c8
Make sure to use 'expression == false'.
jtibshirani Jan 11, 2019
af45f15
Clarify the different IndexTemplateMetaData toXContent methods.
jtibshirani Jan 11, 2019
92f8243
Fix FullClusterRestartIT#testSnapshotRestore.
jtibshirani Jan 11, 2019
197746e
Fix the ml_anomalies_default_mappings test.
jtibshirani Jan 11, 2019
ace36e0
Fix GetFieldMappingsResponseTests and GetIndexTemplateResponseTests.
jtibshirani Jan 11, 2019
0b33b85
Improve some wording in the create index documentation.
jtibshirani Jan 12, 2019
a6e0ada
Add a note about types removal in the create index docs.
jtibshirani Jan 12, 2019
8c32905
Fix more REST tests.
jtibshirani Jan 12, 2019
7497ce8
Fix SmokeTestMonitoringWithSecurityIT#testHTTPExporterWithSSL.
jtibshirani Jan 13, 2019
0ee6bc7
Make sure to mention include_type_name in the REST docs for affected …
jtibshirani Jan 14, 2019
35b7b47
Make sure to use 'expression == false' in FullClusterRestartIT.
jtibshirani Jan 14, 2019
03115c3
Mention include_type_name in the REST templates docs.
jtibshirani Jan 14, 2019
e3281dc
Merge remote-tracking branch 'upstream/master' into include-type-name…
jtibshirani Jan 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
import java.io.IOException;
import java.util.Locale;

import static org.elasticsearch.rest.BaseRestHandler.INCLUDE_TYPE_NAME_PARAMETER;

final class IndicesRequestConverters {

private IndicesRequestConverters() {}
Expand Down Expand Up @@ -103,6 +105,7 @@ static Request createIndex(CreateIndexRequest createIndexRequest) throws IOExcep
parameters.withTimeout(createIndexRequest.timeout());
parameters.withMasterTimeout(createIndexRequest.masterNodeTimeout());
parameters.withWaitForActiveShards(createIndexRequest.waitForActiveShards());
parameters.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true");
cbuescher marked this conversation as resolved.
Show resolved Hide resolved

request.setEntity(RequestConverters.createEntity(createIndexRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
return request;
Expand Down Expand Up @@ -131,6 +134,7 @@ static Request putMapping(PutMappingRequest putMappingRequest) throws IOExceptio
RequestConverters.Params parameters = new RequestConverters.Params(request);
parameters.withTimeout(putMappingRequest.timeout());
parameters.withMasterTimeout(putMappingRequest.masterNodeTimeout());
parameters.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true");

request.setEntity(RequestConverters.createEntity(putMappingRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
return request;
Expand All @@ -146,6 +150,8 @@ static Request getMappings(GetMappingsRequest getMappingsRequest) throws IOExcep
parameters.withMasterTimeout(getMappingsRequest.masterNodeTimeout());
parameters.withIndicesOptions(getMappingsRequest.indicesOptions());
parameters.withLocal(getMappingsRequest.local());
parameters.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true");

return request;
}

Expand All @@ -165,6 +171,8 @@ static Request getFieldMapping(GetFieldMappingsRequest getFieldMappingsRequest)
parameters.withIndicesOptions(getFieldMappingsRequest.indicesOptions());
parameters.withIncludeDefaults(getFieldMappingsRequest.includeDefaults());
parameters.withLocal(getFieldMappingsRequest.local());
parameters.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true");

return request;
}

Expand Down Expand Up @@ -357,6 +365,7 @@ static Request putTemplate(PutIndexTemplateRequest putIndexTemplateRequest) thro
if (Strings.hasText(putIndexTemplateRequest.cause())) {
params.putParam("cause", putIndexTemplateRequest.cause());
}
params.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true");
request.setEntity(RequestConverters.createEntity(putIndexTemplateRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
return request;
}
Expand Down Expand Up @@ -395,6 +404,7 @@ static Request getTemplates(GetIndexTemplatesRequest getIndexTemplatesRequest) {
final RequestConverters.Params params = new RequestConverters.Params(request);
params.withLocal(getIndexTemplatesRequest.isLocal());
params.withMasterTimeout(getIndexTemplatesRequest.getMasterNodeTimeout());
params.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true");
return request;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ public void testSourceDoesNotExist() throws IOException {
.put("number_of_shards", 1)
.put("number_of_replicas", 0)
.build();
String mapping = "\"_doc\": { \"_source\": {\n" +
" \"enabled\": false\n" +
" } }";
String mapping = "\"_source\": {\"enabled\": false}";
createIndex(noSourceIndex, settings, mapping);
assertEquals(
RestStatus.OK,
Expand Down Expand Up @@ -1242,7 +1240,7 @@ public void testTermvectors() throws IOException {
.put("number_of_shards", 1)
.put("number_of_replicas", 0)
.build();
String mappings = "\"_doc\":{\"properties\":{\"field\":{\"type\":\"text\"}}}";
String mappings = "\"properties\":{\"field\":{\"type\":\"text\"}}";
createIndex(sourceIndex, settings, mappings);
assertEquals(
RestStatus.OK,
Expand Down Expand Up @@ -1318,7 +1316,7 @@ public void testMultiTermvectors() throws IOException {
.put("number_of_shards", 1)
.put("number_of_replicas", 0)
.build();
String mappings = "\"_doc\":{\"properties\":{\"field\":{\"type\":\"text\"}}}";
String mappings = "\"properties\":{\"field\":{\"type\":\"text\"}}";
createIndex(sourceIndex, settings, mappings);
assertEquals(
RestStatus.OK,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public void testGetIndex() throws IOException {
.put(SETTING_NUMBER_OF_SHARDS, 1)
.put(SETTING_NUMBER_OF_REPLICAS, 0)
.build();
String mappings = "\"_doc\":{\"properties\":{\"field-1\":{\"type\":\"integer\"}}}";
String mappings = "\"properties\":{\"field-1\":{\"type\":\"integer\"}}";
createIndex(indexName, basicSettings, mappings);

GetIndexRequest getIndexRequest = new GetIndexRequest()
Expand Down Expand Up @@ -371,7 +371,7 @@ public void testGetIndexWithDefaults() throws IOException {
.put(SETTING_NUMBER_OF_SHARDS, 1)
.put(SETTING_NUMBER_OF_REPLICAS, 0)
.build();
String mappings = "\"_doc\":{\"properties\":{\"field-1\":{\"type\":\"integer\"}}}";
String mappings = "\"properties\":{\"field-1\":{\"type\":\"integer\"}}";
createIndex(indexName, basicSettings, mappings);

GetIndexRequest getIndexRequest = new GetIndexRequest()
Expand Down Expand Up @@ -1251,8 +1251,8 @@ public void testPutTemplate() throws Exception {
assertThat(extractRawValues("my-template.index_patterns", templates), contains("pattern-1", "name-*"));
assertThat(extractValue("my-template.settings.index.number_of_shards", templates), equalTo("3"));
assertThat(extractValue("my-template.settings.index.number_of_replicas", templates), equalTo("0"));
assertThat(extractValue("my-template.mappings.doc.properties.host_name.type", templates), equalTo("keyword"));
assertThat(extractValue("my-template.mappings.doc.properties.description.type", templates), equalTo("text"));
assertThat(extractValue("my-template.mappings.properties.host_name.type", templates), equalTo("keyword"));
assertThat(extractValue("my-template.mappings.properties.description.type", templates), equalTo("text"));
assertThat((Map<String, String>) extractValue("my-template.aliases.alias-1", templates), hasEntry("index_routing", "abc"));
assertThat((Map<String, String>) extractValue("my-template.aliases.{index}-write", templates), hasEntry("search_routing", "xyz"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import static org.elasticsearch.index.RandomCreateIndexGenerator.randomCreateIndexRequest;
import static org.elasticsearch.index.RandomCreateIndexGenerator.randomIndexSettings;
import static org.elasticsearch.index.alias.RandomAliasActionsGenerator.randomAliasAction;
import static org.elasticsearch.rest.BaseRestHandler.INCLUDE_TYPE_NAME_PARAMETER;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.nullValue;

Expand Down Expand Up @@ -132,6 +133,7 @@ public void testCreateIndex() throws IOException {
RequestConvertersTests.setRandomTimeout(createIndexRequest::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams);
RequestConvertersTests.setRandomMasterTimeout(createIndexRequest, expectedParams);
RequestConvertersTests.setRandomWaitForActiveShards(createIndexRequest::waitForActiveShards, expectedParams);
expectedParams.put(INCLUDE_TYPE_NAME_PARAMETER, "true");

Request request = IndicesRequestConverters.createIndex(createIndexRequest);
Assert.assertEquals("/" + createIndexRequest.index(), request.getEndpoint());
Expand Down Expand Up @@ -173,6 +175,7 @@ public void testPutMapping() throws IOException {

RequestConvertersTests.setRandomTimeout(putMappingRequest::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams);
RequestConvertersTests.setRandomMasterTimeout(putMappingRequest, expectedParams);
expectedParams.put(INCLUDE_TYPE_NAME_PARAMETER, "true");

Request request = IndicesRequestConverters.putMapping(putMappingRequest);
StringJoiner endpoint = new StringJoiner("/", "/", "");
Expand Down Expand Up @@ -214,6 +217,7 @@ public void testGetMapping() throws IOException {
getMappingRequest::indicesOptions, expectedParams);
RequestConvertersTests.setRandomMasterTimeout(getMappingRequest, expectedParams);
RequestConvertersTests.setRandomLocal(getMappingRequest, expectedParams);
expectedParams.put(INCLUDE_TYPE_NAME_PARAMETER, "true");

Request request = IndicesRequestConverters.getMappings(getMappingRequest);
StringJoiner endpoint = new StringJoiner("/", "/", "");
Expand Down Expand Up @@ -266,6 +270,7 @@ public void testGetFieldMapping() throws IOException {
RequestConvertersTests.setRandomIndicesOptions(getFieldMappingsRequest::indicesOptions, getFieldMappingsRequest::indicesOptions,
expectedParams);
RequestConvertersTests.setRandomLocal(getFieldMappingsRequest::local, expectedParams);
expectedParams.put(INCLUDE_TYPE_NAME_PARAMETER, "true");

Request request = IndicesRequestConverters.getFieldMapping(getFieldMappingsRequest);
StringJoiner endpoint = new StringJoiner("/", "/", "");
Expand Down Expand Up @@ -835,6 +840,8 @@ public void testPutTemplateRequest() throws Exception {
expectedParams.put("cause", cause);
}
RequestConvertersTests.setRandomMasterTimeout(putTemplateRequest, expectedParams);
expectedParams.put(INCLUDE_TYPE_NAME_PARAMETER, "true");

Request request = IndicesRequestConverters.putTemplate(putTemplateRequest);
Assert.assertThat(request.getEndpoint(), equalTo("/_template/" + names.get(putTemplateRequest.name())));
Assert.assertThat(request.getParameters(), equalTo(expectedParams));
Expand Down Expand Up @@ -888,6 +895,8 @@ public void testGetTemplateRequest() throws Exception {
Map<String, String> expectedParams = new HashMap<>();
RequestConvertersTests.setRandomMasterTimeout(getTemplatesRequest::setMasterNodeTimeout, expectedParams);
RequestConvertersTests.setRandomLocal(getTemplatesRequest::setLocal, expectedParams);
expectedParams.put(INCLUDE_TYPE_NAME_PARAMETER, "true");

Request request = IndicesRequestConverters.getTemplates(getTemplatesRequest);
Assert.assertThat(request.getEndpoint(),
equalTo("/_template/" + names.stream().map(encodes::get).collect(Collectors.joining(","))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,9 @@ public void indexDocuments() throws IOException {
create.setJsonEntity(
"{" +
" \"mappings\": {" +
" \"_doc\": {" +
" \"properties\": {" +
" \"rating\": {" +
" \"type\": \"keyword\"" +
" }" +
" \"properties\": {" +
" \"rating\": {" +
" \"type\": \"keyword\"" +
" }" +
" }" +
" }" +
Expand Down Expand Up @@ -172,16 +170,14 @@ public void indexDocuments() throws IOException {
create.setJsonEntity(
"{" +
" \"mappings\": {" +
" \"_doc\": {" +
" \"properties\": {" +
" \"field1\": {" +
" \"type\": \"keyword\"," +
" \"store\": true" +
" }," +
" \"field2\": {" +
" \"type\": \"keyword\"," +
" \"store\": true" +
" }" +
" \"properties\": {" +
" \"field1\": {" +
" \"type\": \"keyword\"," +
" \"store\": true" +
" }," +
" \"field2\": {" +
" \"type\": \"keyword\"," +
" \"store\": true" +
" }" +
" }" +
" }" +
Expand Down Expand Up @@ -445,12 +441,10 @@ public void testSearchWithParentJoin() throws IOException {
createIndex.setJsonEntity(
"{\n" +
" \"mappings\": {\n" +
" \"_doc\" : {\n" +
" \"properties\" : {\n" +
" \"qa_join_field\" : {\n" +
" \"type\" : \"join\",\n" +
" \"relations\" : { \"question\" : \"answer\" }\n" +
" }\n" +
" \"properties\" : {\n" +
" \"qa_join_field\" : {\n" +
" \"type\" : \"join\",\n" +
" \"relations\" : { \"question\" : \"answer\" }\n" +
" }\n" +
" }\n" +
" }" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,17 +792,15 @@ public void testReindex() throws Exception {
RestHighLevelClient client = highLevelClient();
{
String mapping =
"\"_doc\": {\n" +
" \"properties\": {\n" +
" \"user\": {\n" +
" \"type\": \"text\"\n" +
" },\n" +
" \"field1\": {\n" +
" \"type\": \"integer\"\n" +
" },\n" +
" \"field2\": {\n" +
" \"type\": \"integer\"\n" +
" }\n" +
" \"properties\": {\n" +
" \"user\": {\n" +
" \"type\": \"text\"\n" +
" },\n" +
" \"field1\": {\n" +
" \"type\": \"integer\"\n" +
" },\n" +
" \"field2\": {\n" +
" \"type\": \"integer\"\n" +
" }\n" +
" }";
createIndex("source1", Settings.EMPTY, mapping);
Expand Down Expand Up @@ -1000,19 +998,17 @@ public void testUpdateByQuery() throws Exception {
RestHighLevelClient client = highLevelClient();
{
String mapping =
"\"_doc\": {\n" +
" \"properties\": {\n" +
" \"user\": {\n" +
" \"type\": \"text\"\n" +
" },\n" +
" \"field1\": {\n" +
" \"type\": \"integer\"\n" +
" },\n" +
" \"field2\": {\n" +
" \"type\": \"integer\"\n" +
" }\n" +
" }\n" +
" }";
" \"properties\": {\n" +
" \"user\": {\n" +
" \"type\": \"text\"\n" +
" },\n" +
" \"field1\": {\n" +
" \"type\": \"integer\"\n" +
" },\n" +
" \"field2\": {\n" +
" \"type\": \"integer\"\n" +
" }\n" +
" }";
createIndex("source1", Settings.EMPTY, mapping);
createIndex("source2", Settings.EMPTY, mapping);
createPipeline("my_pipeline");
Expand Down Expand Up @@ -1125,19 +1121,17 @@ public void testDeleteByQuery() throws Exception {
RestHighLevelClient client = highLevelClient();
{
String mapping =
"\"_doc\": {\n" +
" \"properties\": {\n" +
" \"user\": {\n" +
" \"type\": \"text\"\n" +
" },\n" +
" \"field1\": {\n" +
" \"type\": \"integer\"\n" +
" },\n" +
" \"field2\": {\n" +
" \"type\": \"integer\"\n" +
" }\n" +
" }\n" +
" }";
" \"properties\": {\n" +
" \"user\": {\n" +
" \"type\": \"text\"\n" +
" },\n" +
" \"field1\": {\n" +
" \"type\": \"integer\"\n" +
" },\n" +
" \"field2\": {\n" +
" \"type\": \"integer\"\n" +
" }\n" +
" }";
createIndex("source1", Settings.EMPTY, mapping);
createIndex("source2", Settings.EMPTY, mapping);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void testPutSettingsMissingBody() throws IOException {

public void testPutMappingsMissingBody() throws IOException {
ResponseException responseException = expectThrows(ResponseException.class, () ->
client().performRequest(new Request(randomBoolean() ? "POST" : "PUT", "/test_index/test_type/_mapping")));
client().performRequest(new Request(randomBoolean() ? "POST" : "PUT", "/test_index/_mapping")));
assertResponseException(responseException, "request body is required");
}

Expand Down
1 change: 1 addition & 0 deletions docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ for (int i = 0; i < 5; i++) {
buildRestTests.setups['library'] = '''
- do:
indices.create:
include_type_name: true
index: library
body:
settings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ the request URL.
+
[source,js]
----
PUT /seats
PUT /seats?include_type_name=true
{
"mappings": {
"seat": {
Expand Down
4 changes: 2 additions & 2 deletions docs/painless/painless-execute-script.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ index:: The name of an index containing a mapping that is compatible with the do

[source,js]
----------------------------------------------------------------
PUT /my-index
PUT /my-index?include_type_name=true
{
"mappings": {
"_doc": {
Expand Down Expand Up @@ -129,7 +129,7 @@ query:: If `_score` is used in the script then a query can specified that will b

[source,js]
----------------------------------------------------------------
PUT /my-index
PUT /my-index?include_type_name=true
{
"mappings": {
"_doc": {
Expand Down
Loading