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 types in index API #36575

Merged
merged 7 commits into from
Dec 18, 2018

Conversation

mayya-sharipova
Copy link
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 12, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@mayya-sharipova mayya-sharipova force-pushed the deprecate_types_index branch 3 times, most recently from 06a9045 to 5de4d1b Compare December 14, 2018 23:18
- 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
Copy link
Contributor

@markharwood markharwood left a comment

Choose a reason for hiding this comment

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

Added a few minor comments but otherwise LGTM

LogManager.getLogger(RestDeleteAction.class));
public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in " +
"document index requests is deprecated, use the /{index}/_doc/{id} endpoint instead.";

Copy link
Contributor

Choose a reason for hiding this comment

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

This message may be misleading if the user didn't supply an ID.

throw new IllegalArgumentException("You may only use the [include_type_name=false] option with the index APIs with the " +
"[{index}/_doc/{id}] and [{index}/_doc] endpoints.");
if (!type.equals(MapperService.SINGLE_MAPPING_NAME)) {
deprecationLogger.deprecatedAndMaybeLog("index_with_types", TYPES_DEPRECATION_MESSAGE);
Copy link
Contributor

Choose a reason for hiding this comment

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

For readability we prefer X==false rather than !X

@@ -82,7 +82,7 @@ public void testRequests() throws Exception {
RestHighLevelClient client = highLevelClient();
{
//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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Related doc says Create an IndexRequest using its constructor -perhaps add comment on the use of id() setter too.

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.

Looks good to me too, just a few small questions!

@@ -135,7 +135,7 @@ public void testSearchSkipUnavailable() throws IOException {

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

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");
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we could we switch this to _doc instead of expecting a warning?

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

Copy link
Contributor

Choose a reason for hiding this comment

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

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.

@@ -84,6 +85,7 @@ public static void index(String index, CheckedConsumer<XContentBuilder, IOExcept

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));
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question here around switching to _doc.

}

@SuppressWarnings("unchecked")
public void testTypeGlobalAndPerRequest() throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be nice to leave this in (with expectWarnings calls), as I don't see this functionality being tested elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@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".

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 am going to temporary disable this test with AwaitsFix, and let @markharwood address this test through his bulk API change.

Copy link
Contributor

Choose a reason for hiding this comment

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

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.

@mayya-sharipova
Copy link
Contributor Author

@elasticmachine run the gradle build tests 1

@mayya-sharipova
Copy link
Contributor Author

@elasticmachine run the default distro tests

@mayya-sharipova mayya-sharipova merged commit f884b2b into elastic:master Dec 18, 2018
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Dec 18, 2018
* 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)
  ...
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.

5 participants