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

Deprecate types in the put mapping API. #37280

Merged
merged 11 commits into from Jan 18, 2019

Conversation

Projects
None yet
6 participants
@jtibshirani
Copy link
Member

commented Jan 9, 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.
@elasticmachine

This comment has been minimized.

Copy link

commented Jan 9, 2019

@jtibshirani jtibshirani force-pushed the jtibshirani:deprecate-types-in-put-mapping branch 2 times, most recently from ee86fc8 to d55dc19 Jan 9, 2019

@jtibshirani jtibshirani referenced this pull request Jan 9, 2019

Closed

Implementation tracking for 7.0 types deprecation. #35190

48 of 48 tasks complete

@jtibshirani jtibshirani added the WIP label Jan 10, 2019

@jtibshirani jtibshirani force-pushed the jtibshirani:deprecate-types-in-put-mapping branch from d55dc19 to 027ce6d Jan 15, 2019

@@ -70,25 +70,3 @@
properties:
"":
type: keyword

---
"PUT mapping with a type and include_type_name: false":

This comment has been minimized.

Copy link
@jtibshirani

jtibshirani Jan 15, 2019

Author Member

This was replaced by a unit test in RestPutMappingActionTests.

@jtibshirani jtibshirani force-pushed the jtibshirani:deprecate-types-in-put-mapping branch from 339de14 to 4f94888 Jan 16, 2019

@jtibshirani jtibshirani force-pushed the jtibshirani:deprecate-types-in-put-mapping branch from 4f94888 to 49964a0 Jan 16, 2019

@jtibshirani jtibshirani requested review from hub-cap and cbuescher Jan 16, 2019

@cbuescher
Copy link
Member

left a comment

@jtibshirani thanks, I left some comments. I think introducing a dedicated new request object for the HLRC side here helps if that is acceptable by all parties. I left some comments about whether we should replicate some of the existing API setters if we are willing to make a fresh start on the client side anyway but I think that discussion needs to involve a few more people.

Show resolved Hide resolved ...el/src/main/java/org/elasticsearch/client/indices/PutMappingRequest.java Outdated
Show resolved Hide resolved ...el/src/main/java/org/elasticsearch/client/indices/PutMappingRequest.java Outdated
Show resolved Hide resolved ...el/src/main/java/org/elasticsearch/client/indices/PutMappingRequest.java Outdated
Show resolved Hide resolved ...el/src/main/java/org/elasticsearch/client/indices/PutMappingRequest.java
Show resolved Hide resolved ...c/test/java/org/elasticsearch/client/indices/PutMappingRequestTests.java
/**
* Creates a random mapping, with no mention of types.
*/
public static XContentBuilder randomMapping() throws IOException {

This comment has been minimized.

Copy link
@cbuescher

cbuescher Jan 16, 2019

Member

Could this be used in the "old" PutMappingRequestTests where it seems to be pulled from as well?

This comment has been minimized.

Copy link
@jtibshirani

jtibshirani Jan 16, 2019

Author Member

Sure, I can update the old PutMappingRequestTests as well.

This comment has been minimized.

Copy link
@jtibshirani

jtibshirani Jan 16, 2019

Author Member

Trying to make this switch actually exposed a bug in the server-side PutMappingRequest. If it's okay with you, I'd like to fix this in another PR.

This comment has been minimized.

Copy link
@cbuescher

cbuescher Jan 17, 2019

Member

Great you found it. Would be nice to track this in an issue then so we don't forget it. Can you open one please?

This comment has been minimized.

Copy link
@jtibshirani

jtibshirani Jan 22, 2019

Author Member

An update: I ended up opening a PR to fix the issue (#37720).

@jtibshirani

This comment has been minimized.

Copy link
Member Author

commented Jan 17, 2019

@elasticmachine test this please

@hub-cap
Copy link
Contributor

left a comment

I only had 1 question, the rest stuff LGTM.

@@ -70,12 +77,17 @@ public String getName() {
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")));
if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) {

This comment has been minimized.

Copy link
@hub-cap

hub-cap Jan 17, 2019

Contributor

is this supposed to log even if include_type_name is set to false?

This comment has been minimized.

Copy link
@jtibshirani

jtibshirani Jan 17, 2019

Author Member

Yes, on master we planned to issue a deprecation warning if the parameter is set at all. This is because the parameter is going to be removed in 8.0.

@@ -81,7 +83,7 @@ public static Settings randomIndexSettings() {
* Creates a random mapping, with no mention of types.
*/
public static XContentBuilder randomMapping() throws IOException {
XContentBuilder builder = XContentFactory.jsonBuilder();
XContentBuilder builder = XContentFactory.contentBuilder(randomFrom(XContentType.values()));

This comment has been minimized.

Copy link
@cbuescher

cbuescher Jan 17, 2019

Member

This might have side-effects on other tests using this. Its good that its tested though. Maybe make sure to run a few of the tests that somehow use this with a couple of repetitions locally (@repeat) just to be sure and not be suprised by test failures some time later on CI.

This comment has been minimized.

Copy link
@jtibshirani

jtibshirani Jan 17, 2019

Author Member

👍

@cbuescher
Copy link
Member

left a comment

I left two comments but nothing that should prevent this from going in as soon as tests pass.

@@ -465,7 +490,6 @@ public void testGetFieldMapping() throws IOException {
createIndex(indexName, Settings.EMPTY);

PutMappingRequest putMappingRequest = new PutMappingRequest(indexName);
putMappingRequest.type("_doc");
XContentBuilder mappingBuilder = JsonXContent.contentBuilder();
mappingBuilder.startObject().startObject("properties").startObject("field");
mappingBuilder.field("type", "text");

This comment has been minimized.

Copy link
@markharwood

markharwood Jan 17, 2019

Contributor

a little later in this test method we still have a type ref:

Map<String, Object> mappings = getMappingsResponse.getMappings().get(indexName).get("_doc").sourceAsMap();

@jpountz said in a recent email thread "we should feel free to use better objects"
Is that something we should address in this PR?

This comment has been minimized.

Copy link
@jtibshirani

jtibshirani Jan 17, 2019

Author Member

This PR is just focused on put mappings (and not get mappings), so I think we should plan to address that in a subsequent PR.

@jtibshirani

This comment has been minimized.

Copy link
Member Author

commented Jan 17, 2019

@elasticmachine test this please

@jtibshirani

This comment has been minimized.

Copy link
Member Author

commented Jan 17, 2019

@elasticmachine run gradle build tests 1
@elasticmachine run gradle build tests 2

@jtibshirani jtibshirani added the v6.7.0 label Jan 18, 2019

@jtibshirani

This comment has been minimized.

Copy link
Member Author

commented Jan 18, 2019

@elasticmachine run gradle build tests 1
@elasticmachine run gradle build tests 2

@jtibshirani

This comment has been minimized.

Copy link
Member Author

commented Jan 18, 2019

@elasticmachine run gradle build tests 1
@elasticmachine run gradle build tests 2

@jtibshirani

This comment has been minimized.

Copy link
Member Author

commented Jan 18, 2019

@elasticmachine run gradle build tests 2

1 similar comment
@jtibshirani

This comment has been minimized.

Copy link
Member Author

commented Jan 18, 2019

@elasticmachine run gradle build tests 2

@jtibshirani jtibshirani merged commit 8da7a27 into elastic:master Jan 18, 2019

8 checks passed

CLA Commit author has signed the CLA
Details
elasticsearch-ci-1 Build finished.
Details
elasticsearch-ci-2 Build finished.
Details
elasticsearch-ci/default-distro Build finished.
Details
elasticsearch-ci/docbldesx Build finished.
Details
elasticsearch-ci/docs-check Build finished.
Details
elasticsearch-ci/oss-distro-docs Build finished.
Details
elasticsearch-ci/packaging-sample Build finished.
Details

@jtibshirani jtibshirani deleted the jtibshirani:deprecate-types-in-put-mapping branch Jan 18, 2019

jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jan 21, 2019

Merge remote-tracking branch 'elastic/master' into sync-retention-leases
* elastic/master: (104 commits)
  Permission for restricted indices (elastic#37577)
  Remove Watcher Account "unsecure" settings (elastic#36736)
  Add cache cleaning task for ML snapshot (elastic#37505)
  Update jdk used by the docker builds (elastic#37621)
  Remove an unused constant in PutMappingRequest.
  Update get users to allow unknown fields (elastic#37593)
  Do not add index event listener if CCR disabled (elastic#37432)
  Add local session timeouts to leader node (elastic#37438)
  Add some deprecation optimizations (elastic#37597)
  refactor inner geogrid classes to own class files (elastic#37596)
  Remove obsolete deprecation checks (elastic#37510)
  ML: Add support for single bucket aggs in Datafeeds (elastic#37544)
  ML: creating ML State write alias and pointing writes there (elastic#37483)
  Deprecate types in the put mapping API. (elastic#37280)
  [ILM] Add unfollow action (elastic#36970)
  Packaging: Update marker used to allow ELASTIC_PASSWORD (elastic#37243)
  Fix setting openldap realm ssl config
  Document the need for JAVA11_HOME (elastic#37589)
  SQL: fix object extraction from sources (elastic#37502)
  Nit in settings.gradle for Eclipse
  ...

@colings86 colings86 added v7.0.0-beta1 and removed v7.0.0 labels Feb 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.