-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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 update requests. #36181
Deprecate types in update requests. #36181
Conversation
Pinging @elastic/es-search |
71ce02f
to
faed06f
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.
Thanks Julie! Just a couple of small comments
import org.elasticsearch.search.fetch.subphase.FetchSourceContext; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.elasticsearch.rest.RestRequest.Method.POST; | ||
|
||
public class RestUpdateAction extends BaseRestHandler { | ||
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestSearchAction.class)); |
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.
Should it be here RestUpdateAction
instead of RestSearchAction
?
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, thanks! I have been doing a lot of copy-paste.
request.param("id")); | ||
UpdateRequest updateRequest; | ||
if (request.hasParam("type")) { | ||
deprecationLogger.deprecated(TYPES_DEPRECATION_MESSAGE); |
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.
Do we want to use deprecatedAndMaybeLog
instead of deprecated
not to log same deprecation warnings many times?
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.
Thanks a lot, I hadn't seen this method. I think we should use it more generally for types deprecation -- I will go over and update some of our other logging statements as well.
@@ -17,7 +17,6 @@ An +{request}+ requires the following arguments: | |||
include-tagged::{doc-tests-file}[{api}-request] | |||
-------------------------------------------------- | |||
<1> Index | |||
<2> Type | |||
<3> Document id | |||
|
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.
<2> Document id
instead of <3> Document id>
?
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.
👍
@@ -507,14 +507,14 @@ public void testUpdate() throws IOException { | |||
IndexResponse indexResponse = highLevelClient().index(indexRequest, RequestOptions.DEFAULT); | |||
assertEquals(RestStatus.CREATED, indexResponse.status()); | |||
|
|||
UpdateRequest updateRequest = new UpdateRequest("index", "_doc", "id"); | |||
UpdateRequest updateRequest = new UpdateRequest("index", "id"); |
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 it worth keeping a deprecated example usage in this test?
I think there's some work to be done to make ESRestTestCase support assertWarnings
checks first (currently have to use getStrictDeprecationMode=false to avoid test failures when making deprecated calls)
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.
Will do, this shouldn't be hard now that we are able to check warnings in REST integration tests.
@@ -358,7 +357,7 @@ public void testUpdate() throws Exception { | |||
} | |||
{ | |||
//tag::update-request-with-doc-as-string | |||
UpdateRequest request = new UpdateRequest("posts", "_doc", "1"); | |||
UpdateRequest request = new UpdateRequest("posts", "1"); | |||
String jsonString = "{" + | |||
"\"updated\":\"2017-01-01\"," + | |||
"\"reason\":\"daily update\"" + |
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.
Also remove String type = updateResponse.getType();
example from line 377?
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.
👍
@@ -46,7 +46,7 @@ public void testIndexWithoutId() 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.
^^ methods testCreate, testIndexWithId and testIndexWithoutId above still going with "test" doc type. Is this intentional?
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.
It wasn't intentional. I switched them to _doc
when deprecating get requests, so this should be fixed.
// use the deprecated path and disable strict deprecation checks. | ||
return 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.
I found I had to do this too and didn't like it. EsRestTestCase has a "fail or nothing" approach to testing responses.
Either the whole test fails (strictDeprecationMode is too strict) or in the alternative lax mode we blindly accept any warnings as ok - we can't check we got the expected warnings because ESRestTestCase does not work with the assertWarnings
feature declared in base class ESTestCase. I'm going to look into adding that support to ESRestTestCase. Opened #36251
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.
👍 thanks for this work, I'll avoid using getStrictDeprecationMode
.
.build(); | ||
performRequest(deprecatedRequest); | ||
assertWarnings(RestUpdateAction.TYPES_DEPRECATION_MESSAGE); | ||
} |
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.
Test the undeprecated form too?
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.
👍
Thanks @mayya-sharipova and @markharwood for the detailed reviews, and sorry I took so long to respond. I was juggling quite a few of these at once and decided it was best to focus on one at a time. I'm working on bringing the PR up to date and will try to address your comments. |
faed06f
to
23aeeff
Compare
This should now be ready for another look. |
@jtibshirani thanks Julie, I had another look. Everything looks good to me. |
The following updates were made:
RestUpdateAction
, plus a test inRestUpdateActionTests
.Because of an earlier PR, the REST yml tests were already updated (one version without types, and another legacy version that retains types).