-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Deprecate types in the put mapping API. #37280
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
Conversation
|
Pinging @elastic/es-search |
ee86fc8 to
d55dc19
Compare
d55dc19 to
027ce6d
Compare
There was a problem hiding this comment.
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.
339de14 to
4f94888
Compare
4f94888 to
49964a0
Compare
cbuescher
left a comment
There was a problem hiding this 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.
client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutMappingRequest.java
Outdated
Show resolved
Hide resolved
client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutMappingRequest.java
Outdated
Show resolved
Hide resolved
client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutMappingRequest.java
Outdated
Show resolved
Hide resolved
client/rest-high-level/src/main/java/org/elasticsearch/client/indices/PutMappingRequest.java
Show resolved
Hide resolved
...t/rest-high-level/src/test/java/org/elasticsearch/client/indices/PutMappingRequestTests.java
Show resolved
Hide resolved
| /** | ||
| * Creates a random mapping, with no mention of types. | ||
| */ | ||
| public static XContentBuilder randomMapping() throws IOException { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
|
@elasticmachine test this please |
hub-cap
left a comment
There was a problem hiding this 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.
| 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)) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
| */ | ||
| public static XContentBuilder randomMapping() throws IOException { | ||
| XContentBuilder builder = XContentFactory.jsonBuilder(); | ||
| XContentBuilder builder = XContentFactory.contentBuilder(randomFrom(XContentType.values())); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
cbuescher
left a comment
There was a problem hiding this 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.
| putMappingRequest.type("_doc"); | ||
| XContentBuilder mappingBuilder = JsonXContent.contentBuilder(); | ||
| mappingBuilder.startObject().startObject("properties").startObject("field"); | ||
| mappingBuilder.field("type", "text"); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
@elasticmachine test this please |
|
@elasticmachine run gradle build tests 1 |
|
@elasticmachine run gradle build tests 1 |
|
@elasticmachine run gradle build tests 1 |
|
@elasticmachine run gradle build tests 2 |
1 similar comment
|
@elasticmachine run gradle build tests 2 |
* 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 ...
From #29453 and #37285, the
include_type_nameparameter was already present and defaulted to false. This PR makes the following updates:RestPutMappingAction, plus tests inRestPutMappingActionTests.PutMappingRequestobject that differs from the existing server one.