-
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 create index requests. #37134
Deprecate types in create index requests. #37134
Conversation
Pinging @elastic/es-search |
2788ffe
to
6041a84
Compare
@elasticmachine run gradle build tests 1 |
6041a84
to
647a732
Compare
647a732
to
aed279e
Compare
aed279e
to
c3cb3b2
Compare
c3cb3b2
to
457a69e
Compare
@elasticmachine run gradle build tests 1 |
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.
@jtibshirani I think the general approach to provide two variants, a typed and an un-typed call in the HLRC and to use other Request-Classes for the "new" calls is fine. In this case I'm wondering if we can avoid copying to much code from server, unless we really need it. I left some comments along those lines.
client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java
Show resolved
Hide resolved
client/rest-high-level/src/main/java/org/elasticsearch/client/indices/CreateIndexRequest.java
Show resolved
Hide resolved
client/rest-high-level/src/main/java/org/elasticsearch/client/indices/CreateIndexResponse.java
Show resolved
Hide resolved
import static org.elasticsearch.test.ESTestCase.randomBoolean; | ||
import static org.elasticsearch.test.ESTestCase.randomIntBetween; | ||
|
||
public final class RandomCreateIndexGenerator { |
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 understand that this helper creates the new "client-side" CreateIndexRequest, but I'm a bit reluctant to copy yet another full over from test.frameworks. Can you somehow create a simple converter from server-side CreateIndexRequest to client side ones instead? We could then reuse the existing RandomCreateIndexGenerator.
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.
This is a nice idea, I'll try it out. One note is that we'll have to swap out the mappings, since client-side CreateIndexRequest
expects typeless mappings, whereas the server-side one always expects typed mappings.
server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponse.java
Outdated
Show resolved
Hide resolved
@cbuescher this is ready for another look. |
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.
great work. I called out something that was brought over from server (all of the methods to set source
), but im not sure we should do anything about it. Im torn between cleaning these client side objects up now, or waiting till we can generate them, and trying to keep them as close to server side as possible, for now. I hate to see them diverge, but I also hate to add all this stuff to client that we will have to maintain. I think im still leaning toward removing whatever we dont think is useful to make the classes as lean as possible, and it means that people wont use methods that dont exist! Im also cool w/ extending a server side class if there is 0 tangible difference, for now. Making the package change is ++.
client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java
Show resolved
Hide resolved
client/rest-high-level/src/main/java/org/elasticsearch/client/indices/CreateIndexRequest.java
Outdated
Show resolved
Hide resolved
* | ||
* Note that the mapping definition should *not* be nested under a type name. | ||
*/ | ||
public CreateIndexRequest source(byte[] source, int offset, int length, XContentType xContentType) { |
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 need all these ways to set source
here?
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.
in general, i think we should try to clean up these classes if we can, so that people have less ways to set these values on the client side objects.
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'll take a stab at removing some of the less important setters on this class.
client/rest-high-level/src/main/java/org/elasticsearch/client/indices/CreateIndexResponse.java
Show resolved
Hide resolved
...level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java
Outdated
Show resolved
Hide resolved
Thanks @hub-cap for the review! I tried to address your comments.
I didn't have a great intuition as to how far to go with the clean-up. I ended up removing two |
@elasticmachine run elasticsearch-ci/1 |
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 would be ok with removing all but the source(BytesReference, ...
call, but its not that big of a deal. These will, hopefully, one day be replaced by concrete objects so we can leave them all for now.
client/rest-high-level/src/main/java/org/elasticsearch/client/indices/CreateIndexRequest.java
Show resolved
Hide resolved
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 @jtibshirani for adressing my comments as well. LGTM
From #29453 and #37285, the include_type_name parameter was already present and defaulted to false. This PR makes the following updates: * Add deprecation warnings to RestCreateIndexAction, plus tests in RestCreateIndexActionTests. * Add a typeless 'create index' method to the Java HLRC, and deprecate the old typed version. To do this cleanly, I created new CreateIndexRequest and CreateIndexResponse objects that differ from the existing server ones.
From #29453 and #37285, the
include_type_name
parameter was already present and defaulted to false. This PR makes the following updates:RestCreateIndexAction
, plus tests inRestCreateIndexActionTests
.CreateIndexRequest
andCreateIndexResponse
objects that differ from the existing server ones.