Deprecate types in index API#36575
Conversation
|
Pinging @elastic/es-search |
06a9045 to
5de4d1b
Compare
- deprecate type-based constructors of IndexRequest - update tests to use typeless IndexRequest constructors - no yaml tests as they have been already added in elastic#35790 Relates to elastic#35190
5de4d1b to
560315b
Compare
markharwood
left a comment
There was a problem hiding this comment.
Added a few minor comments but otherwise LGTM
There was a problem hiding this comment.
This message may be misleading if the user didn't supply an ID.
There was a problem hiding this comment.
For readability we prefer X==false rather than !X
| //tag::migration-request-ctor | ||
| IndexRequest request = new IndexRequest("index", "_doc", "id"); // <1> | ||
| IndexRequest request = new IndexRequest("index").id("id"); // <1> | ||
| request.source("{\"field\":\"value\"}", XContentType.JSON); |
There was a problem hiding this comment.
Related doc says Create an IndexRequest using its constructor -perhaps add comment on the use of id() setter too.
jtibshirani
left a comment
There was a problem hiding this comment.
Looks good to me too, just a few small questions!
| for (int i = 0; i < 10; i++) { | ||
| restHighLevelClient.index( | ||
| new IndexRequest("index", "doc", String.valueOf(i)).source("field", "value"), RequestOptions.DEFAULT); | ||
| new IndexRequest("index", "_doc", String.valueOf(i)).source("field", "value"), RequestOptions.DEFAULT); |
There was a problem hiding this comment.
For my knowledge, why didn't we remove the type altogether, as in new IndexRequest("index").id(...))?
| @@ -59,6 +60,7 @@ protected SecurityConfig securityConfig() { | |||
| protected void index(String index, CheckedConsumer<XContentBuilder, IOException> body) throws IOException { | |||
| Request request = new Request("PUT", "/" + index + "/doc/1"); | |||
There was a problem hiding this comment.
I'm wondering if we could we switch this to _doc instead of expecting a warning?
There was a problem hiding this comment.
@jtibshirani Thanks Julie. Changing this into a _doc in this file or in JdbcIntegrationTestCase.java now will lead to failures of many sql tests. I am planning to have a subsequent PR that can go through our xpack products and change them to use non-deprecated versions.
There was a problem hiding this comment.
Making these changes in a follow-up PR works for me. I'll add a note to the meta issue to track this. It could be that the individual teams should make these changes, as I think it may require more than just updating integration tests. For example, the security indices are still created using the old type name doc.
|
|
||
| public static void index(String index, String documentId, CheckedConsumer<XContentBuilder, IOException> body) throws IOException { | ||
| Request request = new Request("PUT", "/" + index + "/doc/" + documentId); | ||
| request.setOptions(expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE)); |
There was a problem hiding this comment.
Same question here around switching to _doc.
| } | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| public void testTypeGlobalAndPerRequest() throws IOException { |
There was a problem hiding this comment.
It might be nice to leave this in (with expectWarnings calls), as I don't see this functionality being tested elsewhere.
There was a problem hiding this comment.
@jtibshirani Thanks for the suggestion, Julie. But this test will not work anymore, as creating an IndexRequest without a type like new IndexRequest("index2").id("2") will assign a type of _doc to it. While the test here checks that that that the result type should be "global_type".
There was a problem hiding this comment.
I am going to temporary disable this test with AwaitsFix, and let @markharwood address this test through his bulk API change.
There was a problem hiding this comment.
Oh, I didn't realize this was actually broken. I now see it is also broken for update and delete. I would also be okay adding AwaitsFix, and we can work to fix the issue as soon as possible in another PR.
|
@elasticmachine run the gradle build tests 1 |
|
@elasticmachine run the default distro tests |
* elastic/master: (31 commits) enable bwc tests and switch transport serialization version to 6.6.0 for CAS features [DOCs] Adds ml-cpp PRs to alpha release notes (elastic#36790) Synchronize WriteReplicaResult callbacks (elastic#36770) Add CcrRestoreSourceService to track sessions (elastic#36578) [Painless] Add tests for boxed return types (elastic#36747) Internal: Remove originalSettings from Node (elastic#36569) [ILM][DOCS] Update ILM API authorization docs (elastic#36749) Core: Deprecate use of scientific notation in epoch time parsing (elastic#36691) [ML] Merge the Jindex master feature branch (elastic#36702) Tests: Mute SnapshotDisruptionIT.testDisruptionOnSnapshotInitialization Update versions in SearchSortValues transport serialization Update version in SearchHits transport serialization [Geo] Integrate Lucene's LatLonShape (BKD Backed GeoShapes) as default `geo_shape` indexing approach (elastic#36751) [Docs] Fix error in Common Grams Token Filter (elastic#36774) Fix rollup search statistics (elastic#36674) SQL: Fix wrong appliance of StackOverflow limit for IN (elastic#36724) [TEST] Added more logging Invalidate Token API enhancements - HLRC (elastic#36362) Deprecate types in index API (elastic#36575) Disable bwc tests until elastic#36555 backport is complete (elastic#36737) ...
_doc#35790Relates to #35190