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 use of type in reindex request body #36823

Merged
merged 3 commits into from
Jan 3, 2019

Conversation

cbuescher
Copy link
Member

Types can be used both in the source and dest section of the body which will
be translated to search and index requests respectively. Adding a deprecation warning
for those cases and removing examples using more than one type in reindex since
support for this is going to be removed.

@cbuescher cbuescher added :Search/Search Search-related issues that do not fall into other categories v7.0.0 labels Dec 19, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

Copy link
Contributor

@mayya-sharipova mayya-sharipova left a comment

Choose a reason for hiding this comment

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

Thanks @cbuescher, looks good overall.
The main question I have is about the interpretation of "Deprecate use of type". I imagined that for any reference to type, even though it is equal to _doc, we should issue a deprecation warning. @jtibshirani what do you think?

docs/reference/docs/reindex.asciidoc Outdated Show resolved Hide resolved
@cbuescher
Copy link
Member Author

I imagined that for any reference to type, even though it is equal to _doc, we should issue a deprecation warning.

I was going after something like I saw in RestGetAction where we check !type.equals(MapperService.SINGLE_MAPPING_NAME) before we log the deprecation. But maybe thats different there because "_doc" can still appear in the path. Here we can probably deprecate all uses because "type" is used in the request body.

@jtibshirani
Copy link
Contributor

jtibshirani commented Dec 19, 2018

I agree that we want to log a deprecation warning anytime that type appears in the request body. Even if type is set to _doc, we'll want to issue a warning because that key shouldn't be used at all.

I also wanted to note that you may be seeing search-related deprecation warnings when using type in the source section of a reindex request. This is because reindex can create a query on the _type field as part of its execution. I just merged #36802 to avoid issuing this search-related warning, so it might be good to pull in that commit.

@cbuescher
Copy link
Member Author

@jtibshirani @mayya-sharipova thanks for the feedback, I pushed an update.

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 @cbuescher, this is looking good to me! I think we'll also need to update ReindexIT to remove references to types.

Copy link
Contributor

@mayya-sharipova mayya-sharipova left a comment

Choose a reason for hiding this comment

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

Thanks @cbuescher, LGTM

@cbuescher
Copy link
Member Author

@jtibshirani I think I adressed you latest round of comments, running the test now but I think this should be good to go now?

Types can be used both in the source and dest section of the body which will
be translated to search and index requests respectively. Adding a deprecation warning
for those cases and removing examples using more than one type in reindex since
support for this is going to be removed.
@cbuescher
Copy link
Member Author

@elasticmachine test this please

1 similar comment
@cbuescher
Copy link
Member Author

@elasticmachine test this please

@Conky5
Copy link

Conky5 commented Jan 2, 2019

@elasticmachine test this please

@cbuescher
Copy link
Member Author

Even if type is set to _doc, we'll want to issue a warning because that key shouldn't be used at all.

@jtibshirani I just that now the IndexRequest (used for the reindex destination) always contains a non-null type ("_doc" by default, this might be a recent change, I haven't seen related tests failing before). Also the SearchRequest used in the source section always prints the "type" field to xContent even if no types are set, so we will alway see a warning when going e.g. through the High Level Rest Client. I think we need to change the ReindexRequest xContent output slightly so that the "type" fields are not printed when they are not set (e.g. when coming from HLRest)

@cbuescher
Copy link
Member Author

@jtibshirani thanks for the thumbs up but the last failures in the high level client tests uncovered what I think were some problems with the xContent output of the current ReindexRequest. Can you take a look at the recent commit and let me know if you agree with not outputting empty or default type fields in the ReindexRequest is serialized via toXContent? This would mean we still warn when empty/default types names are sent directly via REST, but we wouldn't send them outselves when using e.g. the HL client.

@@ -294,15 +295,19 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.field("remote", remoteInfo);
}
builder.array("index", getSearchRequest().indices());
builder.array("type", getSearchRequest().types());
String[] types = getSearchRequest().types();
if (types != null && types.length > 0) {
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 -- I don't think these null checks are necessary, since SearchRequest validates that the types array can't be null. Similarly, IndexRequest validates that the type is not null.

Copy link
Member Author

Choose a reason for hiding this comment

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

IndexRequest validates that the type is not null

Unfortunately this is done in validate() only, so its possible to set a null type via the ctors or the setter and then xContent serialization would break. For SearchRequest I think you are right and types cannot be null so I will remove the check there but leave it for IndexRequest.

@jtibshirani
Copy link
Contributor

@cbuescher thanks for double-checking, I agree with this approach to ReindexRequest#toXContent.

@cbuescher cbuescher merged commit 046f86f into elastic:master Jan 3, 2019
@jimczi jimczi added v7.0.0-beta1 and removed v7.0.0 labels Feb 7, 2019
@kcm
Copy link
Contributor

kcm commented Aug 9, 2019

This bit us on site today because the 7.x docs don't mention type, but it's still needed for reindexing from older multi-type indices into 7.x+. Even if the support for multiple types in dest is gone, won't we still want to keep the support for type in source? What's a workaround if not, for upgrading from pre-6 indices?

Can we at least re-document it for source for now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>deprecation :Search/Search Search-related issues that do not fall into other categories v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants