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 update_by_query and delete_by_query #36365

Conversation

mayya-sharipova
Copy link
Contributor

Relates to #35190

@mayya-sharipova mayya-sharipova added >deprecation v7.0.0 :Search Foundations/Mapping Index mappings, including merging and defining field types labels Dec 7, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

Copy link
Contributor

@jtibshirani jtibshirani left a comment

Choose a reason for hiding this comment

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

Thanks @mayya-sharipova, this looks good to me overall! I left some small comments, and also noted that it would be good to use the changes in #36328.

// checking here for a deprecation from its internal search request
assertWarnings(RestSearchAction.TYPES_DEPRECATION_MESSAGE);
}

public void testParseEmpty() throws IOException {
RestDeleteByQueryAction action = new RestDeleteByQueryAction(Settings.EMPTY, mock(RestController.class));
Copy link
Contributor

Choose a reason for hiding this comment

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

Small comment, but maybe we could refactor to use the same RestDeleteByQueryAction that we've created in setUp.

@@ -89,7 +89,9 @@ public DeleteByQueryRequest setQuery(QueryBuilder query) {

/**
* Set the document types for the delete
* @deprecated Types are in the process of being removed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Super small comment, but maybe we can mention 'Instead of using a type, prefer to filter on a field on the document' (as in https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/action/search/SearchRequest.java#L221)?

@@ -512,8 +512,9 @@ private static Request prepareReindexRequest(ReindexRequest reindexRequest, bool
}

static Request updateByQuery(UpdateByQueryRequest updateByQueryRequest) throws IOException {
String endpoint =
endpoint(updateByQueryRequest.indices(), updateByQueryRequest.getDocTypes(), "_update_by_query");
String endpoint = updateByQueryRequest.isNoTypeRequest()
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need a special check for no types here, because if the types array is empty, the logic in endpoint will just skip that path component. This is nice, because it lets us avoid introducing the additional isNoTypeRequest methods.


import java.io.IOException;
import java.util.Collections;

import static java.util.Collections.emptyList;
import static org.mockito.Mockito.mock;

public class RestDeleteByQueryActionTests extends ESTestCase {
Copy link
Contributor

Choose a reason for hiding this comment

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

I just noticed we don't have any REST test coverage for using delete- and update-by-query with types. It might be nice to add a test case here and in RestUpdateByQueryActionTests that checks the type in the URL is propagated correctly to the request object? That way we have some minimal coverage to be sure this doesn't break.

Also, I just merged #36328, which should help cut down on boilerplate in these tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jtibshirani Thanks Julie. What "request object" do you have in mind here? Is it RestRequest? Does this line introduced in my last commit is enough for testing:

assertEquals("some_type", request.param("type"));

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking we could have a separate test for request building where we call action.buildRequest(...) and check that the return value (like DeleteByQueryRequest) contains the right document types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jtibshirani got it, thanks Julie. I have addressed this in my last commit.

@mayya-sharipova
Copy link
Contributor Author

@elasticmachine test this please

@mayya-sharipova
Copy link
Contributor Author

@jtibshirani Thanks for the review. I have tried to address your comments. Can you please continue the review when you have time

Copy link
Contributor

@jtibshirani jtibshirani left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@mayya-sharipova mayya-sharipova merged commit 2f18325 into elastic:master Dec 11, 2018
@mayya-sharipova mayya-sharipova deleted the deprecate_types_delete_update_by_query branch December 11, 2018 22:10
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 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants