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

jtibshirani
Copy link
Contributor

@jtibshirani jtibshirani 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.

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

Pinging @elastic/es-search

@jtibshirani jtibshirani force-pushed the deprecate-types-in-put-mapping branch 2 times, most recently from ee86fc8 to d55dc19 Compare January 9, 2019 23:29
@@ -70,25 +70,3 @@
properties:
"":
type: keyword

---
"PUT mapping with a type and include_type_name: false":
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was replaced by a unit test in RestPutMappingActionTests.

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 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.

/**
* Creates a random mapping, with no mention of types.
*/
public static XContentBuilder randomMapping() throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can update the old PutMappingRequestTests as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

@jtibshirani
Copy link
Contributor Author

@elasticmachine test this please

Copy link
Contributor

@hub-cap hub-cap left a comment

Choose a reason for hiding this comment

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

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)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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()));
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

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.

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");
Copy link
Contributor

Choose a reason for hiding this comment

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

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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
Copy link
Contributor Author

@elasticmachine test this please

@jtibshirani
Copy link
Contributor Author

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

@jtibshirani
Copy link
Contributor Author

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

@jtibshirani
Copy link
Contributor Author

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

@jtibshirani
Copy link
Contributor Author

@elasticmachine run gradle build tests 2

1 similar comment
@jtibshirani
Copy link
Contributor Author

@elasticmachine run gradle build tests 2

@jtibshirani jtibshirani merged commit 8da7a27 into elastic:master Jan 18, 2019
@jtibshirani jtibshirani deleted the deprecate-types-in-put-mapping branch January 18, 2019 20:28
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jan 21, 2019
* 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
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>deprecation :Search Foundations/Mapping Index mappings, including merging and defining field types v6.7.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants