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

Remove types from BulkRequest #46983

Merged

Conversation

romseygeek
Copy link
Contributor

This commit removes types entirely from BulkRequest, both as a global
parameter and as individual entries on update/index/delete lines.

Relates to #41059

@romseygeek romseygeek added :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. >breaking-java v8.0.0 labels Sep 23, 2019
@romseygeek romseygeek self-assigned this Sep 23, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

*/
BulkRequestBuilder prepareBulk(@Nullable String globalIndex, @Nullable String globalType);
BulkRequestBuilder prepareBulk(@Nullable String globalIndex);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

NB I will open a separate PR for 7x to deprecate the method that takes a global type here.

@Nullable String defaultPipeline, boolean allowExplicitIndex,
XContentType xContentType,
Consumer<IndexRequest> indexRequestConsumer,
BiConsumer<IndexRequest, String> indexRequestConsumer,
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 is a slightly hacky way of getting around the fact that the Monitoring Bulk action still uses the _type parameter in a bulk index line to set a type field. This action is slated for deprecation and removal at some point in the future; until then, seeing as the BulkParser no longer sets the type on its IndexRequest, we need to pass it separately to this consumer.

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 love that we need to maintain types in one place in the bulk action because of the monitoring bulk action. I'd like to try to find some way to avoid this whilst minimising the affect on the monitoring bulk actions API itself. This doesn't need to be solved in this PR but I'd like to try to solve it in the types removal for 8.0 work

Copy link
Contributor

@colings86 colings86 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 some comments

*/
public BulkRequestParser(boolean warnOnTypeUsage) {
this.warnOnTypeUsage = warnOnTypeUsage;
public BulkRequestParser(boolean errorOnType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have a zero arg constructor that defaults errorOnType to true? That way there should be less places to update when we remove this parameter?

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 is only actually called from two locations - BulkRequest and MonitoringBulkRequest - so I'm not sure a zero-arg constructor actually helps much here.

if (in.getVersion().before(Version.V_8_0_0)) {
in.readString();
// can't make an assertion about type names here because too many tests still set their own
// types bypassing various checks
Copy link
Contributor

Choose a reason for hiding this comment

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

How many tests do this? I'm wondering if we need to make a separate change to make all the tests use the typeless APIs and backport it to 7.x so we can have these checks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll re-add it in and change the relevant 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.

OK, so the reason that we can't assert the type here is indeed for backwards compatibility; it's a failure message, and there are certain circumstances in which a user can supply information which results in a different type being returned here: specifically, if a user tries to index documents with different type names, then we return an error message saying you can only have a single type, and the type field in this failure message will be set to one of those user-supplied names.

@Nullable String defaultPipeline, boolean allowExplicitIndex,
XContentType xContentType,
Consumer<IndexRequest> indexRequestConsumer,
BiConsumer<IndexRequest, String> indexRequestConsumer,
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 love that we need to maintain types in one place in the bulk action because of the monitoring bulk action. I'd like to try to find some way to avoid this whilst minimising the affect on the monitoring bulk actions API itself. This doesn't need to be solved in this PR but I'd like to try to solve it in the types removal for 8.0 work

@romseygeek
Copy link
Contributor Author

The changes to BulkRequestParser will become much simpler after #47213

@romseygeek
Copy link
Contributor Author

@elasticmachine update branch

@romseygeek
Copy link
Contributor Author

@elasticmachine update branch

@romseygeek romseygeek merged commit 7a622f0 into elastic:master Oct 7, 2019
@romseygeek romseygeek deleted the types-removal/bulk-request-action branch October 7, 2019 12:29
@jpountz jpountz mentioned this pull request Oct 8, 2019
66 tasks
@pgomulka pgomulka mentioned this pull request Mar 25, 2020
66 tasks
pgomulka added a commit to pgomulka/elasticsearch that referenced this pull request May 31, 2021
retrofits typed endpoint and type in request parsing
the original types removal commit
elastic#46983

relates elastic#51816
pgomulka added a commit that referenced this pull request Jun 7, 2021
retrofits typed endpoint and type in request parsing
the original types removal commit
#46983

relates #51816
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>breaking-java :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants