Skip to content

Deprecate types in update_by_query and delete_by_query#36365

Merged
mayya-sharipova merged 9 commits intoelastic:masterfrom
mayya-sharipova:deprecate_types_delete_update_by_query
Dec 11, 2018
Merged

Deprecate types in update_by_query and delete_by_query#36365
mayya-sharipova merged 9 commits intoelastic:masterfrom
mayya-sharipova:deprecate_types_delete_update_by_query

Conversation

@mayya-sharipova
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

Pinging @elastic/es-search

Copy link
Copy Markdown
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.

}

public void testParseEmpty() throws IOException {
RestDeleteByQueryAction action = new RestDeleteByQueryAction(Settings.EMPTY, mock(RestController.class));
Copy link
Copy Markdown
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.


/**
* Set the document types for the delete
* @deprecated Types are in the process of being removed.
Copy link
Copy Markdown
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)?

static Request updateByQuery(UpdateByQueryRequest updateByQueryRequest) throws IOException {
String endpoint =
endpoint(updateByQueryRequest.indices(), updateByQueryRequest.getDocTypes(), "_update_by_query");
String endpoint = updateByQueryRequest.isNoTypeRequest()
Copy link
Copy Markdown
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 static java.util.Collections.emptyList;
import static org.mockito.Mockito.mock;

public class RestDeleteByQueryActionTests extends ESTestCase {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

@elasticmachine test this please

@mayya-sharipova
Copy link
Copy Markdown
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
Copy Markdown
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.

4 participants