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

Conversation

jtibshirani
Copy link
Contributor

@jtibshirani jtibshirani commented Jan 10, 2019

This PR updates the default to include_type_name to false for all APIs that accept it (indices.create, indices.put_mapping, indices.get_mapping, indices.get_field_mapping, indices.put_template, indices.get_template).

It tries to fix up as many tests as possible so that they avoid using the include_type_name parameter altogether, and omit types from the mappings.

The following approach was taken for the REST tests:

  1. If the test is only running against 7.0.0 because it is testing typeless APIs, then omit the include_type_name parameter altogether. This lets us test the default behavior.
  2. If the test is explicitly testing the typed APIs (its name ends with _with_types.yml), then use include_type_name = true where appropriate, to continue to test the typed case.
  3. If the test is not explicitly testing typeless vs. typed APIs, then prefer to explicitly set include_type_name = false and omit types. This works in a mixed-cluster set-up because 6.7 nodes now understand this parameter as well.
  4. The one notable exception to point 3 is for indices.create requests. These are so common and scattered across so many tests that it would be too much for this PR to try to convert all of those tests to stop using types. The way we get around this is by a modification in the test harness: we check if the indices.create call contains the parameter include_type_name, and if not, set it to true when making the API call. Note that this is very much temporary and will need to be fixed in a series of follow-up PRs that update REST tests.

The approach for REST documentation:

  1. As much as possible, avoid using include_type_name altogether and switch to the new API format.
  2. However, when an index is created during set-up, I have simply added include_type_name=true. Like the REST tests, it is a very large amount of manual work to drop include_type_name everywhere, so I thought we would update the documentation in a series of follow-ups. I think it would be possible to take the same approach in the documentation that we do for other REST tests (don't add any parameter, but rely on setting include_type_name=true in the test harness). However, I thought that it was best to avoid non-working documentation examples.

Note that no changes were made to the Java HLRC yet (or HLRC tests), and we do not yet emit deprecation warnings. Those last pieces of work are coming in follow-up PRs.

@jtibshirani jtibshirani added >enhancement >breaking WIP :Search Foundations/Mapping Index mappings, including merging and defining field types v7.0.0 labels Jan 10, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@@ -49,7 +49,7 @@ public String getName() {

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, true);
final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, false);
Copy link
Contributor

@markharwood markharwood Jan 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we refer to a single constant here that controls our default policy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -86,7 +86,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
deprecationLogger.deprecated("Type exists requests are deprecated, as types have been deprecated.");
}

final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, true);
final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See earlier comment re single constant

@@ -68,11 +68,12 @@ public String getName() {

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, true);
final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See earlier comment re single constant

@markharwood
Copy link
Contributor

markharwood commented Jan 10, 2019

Further to earlier comments about adding a constant - I merged a PR for 6.x that adds such a constant. Could this PR perhaps add the same constant but with the new "false" setting ie:

public static final boolean DEFAULT_INCLUDE_TYPE_NAME_POLICY = false; 

Note that https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/action/admin/indices/get/GetIndexResponse.java#L257 should also need changing to refer to this new constant as well as the RestCreateIndexAction, RestGetMappingAction andRestPutMappingAction classes already in this PR

@jtibshirani
Copy link
Contributor Author

Thanks @markharwood, I'll make sure to introduce the same constant as part of this PR.

@jtibshirani jtibshirani force-pushed the include-type-name-default branch from 188cb0a to 6cd858e Compare January 11, 2019 07:56
@jtibshirani jtibshirani changed the title Default include_type_name to false for create index, and put and get mappings. Update the default for include_type_name to false. Jan 11, 2019
@jtibshirani jtibshirani removed the WIP label Jan 11, 2019
@jtibshirani jtibshirani force-pushed the include-type-name-default branch from 6cd858e to e20aebb Compare January 11, 2019 08:08
@jtibshirani jtibshirani requested a review from cbuescher January 11, 2019 08:08
@jtibshirani jtibshirani force-pushed the include-type-name-default branch from e20aebb to 64093c9 Compare January 11, 2019 08:11
@jtibshirani jtibshirani requested a review from jpountz January 11, 2019 08:12
Copy link
Member

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtibshirani I left a couple of questions, its probably not necessary to look at all the test adaptions in detail so I was mostly trying to see how the plan in the description fits the changes made and left some questions where I wasn't sure about the overall plan.

@@ -177,28 +175,3 @@ PUT test?wait_for_active_shards=2

A detailed explanation of `wait_for_active_shards` and its possible values can be found
<<index-wait-for-active-shards,here>>.

[float]
=== Skipping types
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have the reverse section as well explaining how to keep types although deprecated in case you still need them?

Copy link
Contributor Author

@jtibshirani jtibshirani Jan 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍good idea!

@@ -195,7 +195,8 @@ setup:
indices.refresh: {}

- do:
indices.get_mapping: {}
indices.get_mapping:
include_type_name: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary for mixed cluster?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not technically necessary, since we don't use the output of the call. However, I just tried to use include_type_name = false for all mixed-cluster set-ups for clarity/ consistency, as opposed to making individual calls on a test-by-test basis.

@@ -78,7 +78,7 @@ that can be set when creating an index, please check the
[[mappings]]
=== Mappings

The create index API allows to provide a type mapping:
The create index API allows to provide a mapping:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSON property is still called "mappings", plural so I'd be tempted to describe them as "field mappings".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@markharwood
Copy link
Contributor

markharwood commented Jan 11, 2019

Digging into the build failure I see GetFieldMappingResponseTests is failing because
GetFieldMappingResponse expects only one type as it loops around the mapping response.
However, GetFieldMappingsResponseTests generates a random mapping with multiple types:

@markharwood
Copy link
Contributor

Other build failure here is GetIndexTemplateResponseTests - the toXContent/fromXContent methods disagree - toXContent now provides typeless mappings due to default include_type_name=false param but IndexTemplateMetaData.fromXContent is hard-coded to assume a type is there so picks up properties as a type name.

@jtibshirani
Copy link
Contributor Author

Thanks @cbuescher and @markharwood for the review and for digging into the build failures. For the Get*Response unit tests, I plan to make sure that they only consider typed responses, as they've done before this PR. Then, when we open PRs to add Java HLRC support, we will introduce fromXContent methods that understand typeless mappings, and can migrate these tests to touch on both typeless and typed responses.

@jtibshirani jtibshirani force-pushed the include-type-name-default branch 2 times, most recently from 727f626 to 2e54beb Compare January 12, 2019 20:59
Copy link
Member

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates, looks good from my side.

@jtibshirani
Copy link
Contributor Author

@elastic/es-clients I forgot to ping the clients team, my apologies! I think it's important to be aware of this PR because of the modification in the test harness:

The one notable exception to point 3 is for indices.create requests. These are so common and scattered across so many tests that it would be too much for this PR to try to convert all of those tests to stop using types. The way we get around this is by a modification in the test harness: we check if the indices.create call contains the parameter include_type_name, and if not, set it to true when making the API call. Note that this is very much temporary and will need to be fixed in a series of follow-up PRs that update REST tests.

Feel free to ping me if you have any questions about the REST tests changes.

@jtibshirani jtibshirani merged commit 36a3b84 into elastic:master Jan 14, 2019
@jtibshirani jtibshirani deleted the include-type-name-default branch January 14, 2019 21:08
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jan 15, 2019
* master: (28 commits)
  Introduce retention lease serialization (elastic#37447)
  Update Delete Watch to allow unknown fields (elastic#37435)
  Make finalize step of recovery source non-blocking (elastic#37388)
  Update the default for include_type_name to false. (elastic#37285)
  Security: remove SSL settings fallback (elastic#36846)
  Adding mapping for hostname field (elastic#37288)
  Relax assertSameDocIdsOnShards assertion
  Reduce recovery time with compress or secure transport (elastic#36981)
  Implement ccr file restore (elastic#37130)
  Fix Eclipse specific compilation issue (elastic#37419)
  Performance fix. Reduce deprecation calls for the same bulk request (elastic#37415)
  [ML] Use String rep of Version in map for serialisation (elastic#37416)
  Cleanup Deadcode in Rest Tests (elastic#37418)
  Mute IndexShardRetentionLeaseTests.testCommit elastic#37420
  unmuted test
  Remove unused index store in directory service
  Improve CloseWhileRelocatingShardsIT (elastic#37348)
  Fix ClusterBlock serialization and Close Index API logic after backport to 6.x (elastic#37360)
  Update the scroll example in the docs (elastic#37394)
  Update analysis.asciidoc (elastic#37404)
  ...
tylersmalley pushed a commit to tylersmalley/kibana that referenced this pull request Jan 15, 2019
Follow-up to elastic#28497

Since elastic/elasticsearch#37285 has been merged, it's
aparent there are a couple more places we need to specify include_type_name
as a stop-gap until elastic#23650 is completed

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
chrisdavies pushed a commit to elastic/kibana that referenced this pull request Jan 15, 2019
* [migrations] Fetch additional mappings with types

Follow-up to #28497

Since elastic/elasticsearch#37285 has been merged, it's
aparent there are a couple more places we need to specify include_type_name
as a stop-gap until #23650 is completed

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>

* Updates tests

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
@karmi
Copy link
Contributor

karmi commented Jan 15, 2019

@jtibshirani, thanks for the ping! I've tried to do what you suggest — adding include_type_name=false to index.create calls which don't set it —, and it makes my tests green again.

cbuescher pushed a commit to cbuescher/elasticsearch that referenced this pull request Jan 17, 2019
The "include_type_name" parameter was temporarily introduced in elastic#37285 to facilitate
moving the default parameter setting to "false" in many places in the documentation
code snippets. Most of the places can simply be reverted without causing errors.
In this change I looked for asciidoc files that contained the
"include_type_name=true" addition when creating new indices but didn't look
likey they made use of the "_doc" type for mappings. This is mostly the case
e.g. in the analysis docs where index creating often only contains settings. I
manually corrected the use of types in some places where the docs still used an
explicit type name and not the dummy "_doc" type.
cbuescher pushed a commit that referenced this pull request Jan 18, 2019
The "include_type_name" parameter was temporarily introduced in #37285 to facilitate
moving the default parameter setting to "false" in many places in the documentation
code snippets. Most of the places can simply be reverted without causing errors.
In this change I looked for asciidoc files that contained the
"include_type_name=true" addition when creating new indices but didn't look
likey they made use of the "_doc" type for mappings. This is mostly the case
e.g. in the analysis docs where index creating often only contains settings. I
manually corrected the use of types in some places where the docs still used an
explicit type name and not the dummy "_doc" type.
jtibshirani added a commit that referenced this pull request Jan 18, 2019
From #29453 and #37285, the `include_type_name` parameter was already present and defaulted to false. This PR makes the following updates:
- Add deprecation warnings to `RestPutMappingAction`, plus tests in `RestPutMappingActionTests`.
- Add a typeless 'put mappings' method to the Java HLRC, and deprecate the old typed version. To do this cleanly, I opted to create a new `PutMappingRequest` object that differs from the existing server one.
jtibshirani added a commit that referenced this pull request Jan 24, 2019
From #29453 and #37285, the include_type_name parameter was already present and defaulted to false. This PR makes the following updates:
* Add deprecation warnings to RestCreateIndexAction, plus tests in RestCreateIndexActionTests.
* Add a typeless 'create index' method to the Java HLRC, and deprecate the old typed version. To do this cleanly, I created new CreateIndexRequest and CreateIndexResponse objects that differ from the existing server ones.
jtibshirani added a commit that referenced this pull request Jan 24, 2019
From #29453 and #37285, the include_type_name parameter was already present and defaulted to false. This PR makes the following updates:
* Add deprecation warnings to RestCreateIndexAction, plus tests in RestCreateIndexActionTests.
* Add a typeless 'create index' method to the Java HLRC, and deprecate the old typed version. To do this cleanly, I created new CreateIndexRequest and CreateIndexResponse objects that differ from the existing server ones.
jtibshirani added a commit that referenced this pull request Feb 1, 2019
This PR removes the temporary change we made to the yml test harness in #37285
to automatically set `include_type_name` to `true` in index creation requests
if it's not already specified. This is possible now that the vast majority of
index creation requests were updated to be typeless in #37611. A few additional
tests also needed updating here.

Additionally, this PR updates the test harness to set `include_type_name` to
`false` in index creation requests when communicating with 6.x nodes. This
mirrors the logic added in #37611 to allow for typeless document write requests
in test set-up code. With this update in place, we can remove many references
to `include_type_name: false` from the yml tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>breaking >enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants