From 95c7e6ebff72fbd0638c37eb059ed5fb0704cfc8 Mon Sep 17 00:00:00 2001 From: lgypro <42293361+lgypro@users.noreply.github.com> Date: Tue, 29 Oct 2019 17:26:04 +0800 Subject: [PATCH 01/12] =?UTF-8?q?[Docs]=C2=A0Fix=20syntax=20error=20leadin?= =?UTF-8?q?g=20to=20wrong=20doc=20ID=20(#48554)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to index a document with id 2, the "&" should be replaced by "?" --- docs/reference/mapping/fields/id-field.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/mapping/fields/id-field.asciidoc b/docs/reference/mapping/fields/id-field.asciidoc index 9d93c60b39277..987f3729aa1fa 100644 --- a/docs/reference/mapping/fields/id-field.asciidoc +++ b/docs/reference/mapping/fields/id-field.asciidoc @@ -16,7 +16,7 @@ PUT my_index/_doc/1 "text": "Document with ID 1" } -PUT my_index/_doc/2&refresh=true +PUT my_index/_doc/2?refresh=true { "text": "Document with ID 2" } From 3acd32fbee95002f27d2199ea98a69ca4a1cc386 Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Tue, 29 Oct 2019 09:28:58 +0000 Subject: [PATCH 02/12] Improve resiliency to auto-formatting in client (#48447) Make a number of changes so that code in the `client` directory is more resilient to automatic formatting. This covers: * Literal JSON handling: * Reformatting multiline JSON to embed whitespace in the strings * Remove string concatenation where JSON fits on a single line * Use `String.format` for large documents with variable content * Remove some erroneous doc refs in `QueryDSLDocumentationTests` * Move some comments around to they aren't auto-formatted to a strange place --- .../elasticsearch/client/IndicesClientIT.java | 37 ++++++---- .../client/IngestRequestConvertersTests.java | 27 ++++++- .../org/elasticsearch/client/SearchIT.java | 36 +-------- .../org/elasticsearch/client/TasksIT.java | 12 ++- .../IndicesClientDocumentationIT.java | 35 +++------ .../QueryDSLDocumentationTests.java | 20 ++--- .../documentation/SearchDocumentationIT.java | 9 +-- .../StoredScriptsDocumentationIT.java | 4 +- .../GetIndexTemplatesResponseTests.java | 6 +- .../rollup/GetRollupCapsResponseTests.java | 9 ++- .../GetRollupIndexCapsResponseTests.java | 4 +- .../ClearRealmCacheResponseTests.java | 13 ++-- .../ClearRolesCacheResponseTests.java | 13 ++-- .../security/CreateTokenRequestTests.java | 25 +++---- .../security/InvalidateTokenRequestTests.java | 27 ++----- .../security/PutRoleMappingRequestTests.java | 73 +++++++++++++------ .../transforms/pivot/GroupConfigTests.java | 63 ++++++++-------- 17 files changed, 212 insertions(+), 201 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java index 50a5a5c29e4bf..a7400fcc872b4 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java @@ -1426,10 +1426,8 @@ public void testPutTemplate() throws Exception { .order(10) .create(randomBoolean()) .settings(Settings.builder().put("number_of_shards", "3").put("number_of_replicas", "0")) - .mapping("{ \"properties\":{" - + "\"host_name\": {\"type\":\"keyword\"}" - + "}" - + "}", XContentType.JSON) + .mapping("{ \"properties\": { \"host_name\": { \"type\": \"keyword\" } } }", XContentType.JSON) + .alias(new Alias("alias-1").indexRouting("abc")) .alias(new Alias("alias-1").indexRouting("abc")).alias(new Alias("{index}-write").searchRouting("xyz")); AcknowledgedResponse putTemplateResponse = execute(putTemplateRequest, @@ -1452,13 +1450,18 @@ public void testPutTemplateWithTypesUsingUntypedAPI() throws Exception { .order(10) .create(randomBoolean()) .settings(Settings.builder().put("number_of_shards", "3").put("number_of_replicas", "0")) - .mapping("{ " - + "\"my_doc_type\":{" - + "\"properties\":{" - + "\"host_name\": {\"type\":\"keyword\"}" - + "}" - + "}" - + "}", XContentType.JSON) + .mapping( + "{" + + " \"my_doc_type\": {" + + " \"properties\": {" + + " \"host_name\": {" + + " \"type\": \"keyword\"" + + " }" + + " }" + + " }" + + "}", + XContentType.JSON + ) .alias(new Alias("alias-1").indexRouting("abc")).alias(new Alias("{index}-write").searchRouting("xyz")); @@ -1553,8 +1556,16 @@ public void testInvalidValidateQuery() throws IOException{ createIndex(index, Settings.EMPTY); Request postDoc = new Request(HttpPost.METHOD_NAME, "/" + index + "/_doc"); postDoc.setJsonEntity( - "{\"type\":\"act\",\"line_id\":1,\"play_name\":\"Henry IV\", \"speech_number\":\"\"," + - "\"line_number\":\"\",\"speaker\":\"\",\"text_entry\":\"ACT I\"}"); + "{" + + " \"type\": \"act\"," + + " \"line_id\": 1," + + " \"play_name\": \"Henry IV\"," + + " \"speech_number\": \"\"," + + " \"line_number\": \"\"," + + " \"speaker\": \"\"," + + " \"text_entry\": \"ACT I\"" + + "}" + ); assertOK(client().performRequest(postDoc)); QueryBuilder builder = QueryBuilders diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IngestRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IngestRequestConvertersTests.java index a615757fa22a9..1af55d8a93c55 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IngestRequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IngestRequestConvertersTests.java @@ -93,10 +93,29 @@ public void testDeletePipeline() { public void testSimulatePipeline() throws IOException { String pipelineId = ESTestCase.randomBoolean() ? "some_pipeline_id" : null; boolean verbose = ESTestCase.randomBoolean(); - String json = "{\"pipeline\":{" + - "\"description\":\"_description\"," + - "\"processors\":[{\"set\":{\"field\":\"field2\",\"value\":\"_value\"}}]}," + - "\"docs\":[{\"_index\":\"index\",\"_type\":\"_doc\",\"_id\":\"id\",\"_source\":{\"foo\":\"rab\"}}]}"; + String json = "{" + + " \"pipeline\": {" + + " \"description\": \"_description\"," + + " \"processors\": [" + + " {" + + " \"set\": {" + + " \"field\": \"field2\"," + + " \"value\": \"_value\"" + + " }" + + " }" + + " ]" + + " }," + + " \"docs\": [" + + " {" + + " \"_index\": \"index\"," + + " \"_type\": \"_doc\"," + + " \"_id\": \"id\"," + + " \"_source\": {" + + " \"foo\": \"rab\"" + + " }" + + " }" + + " ]" + + "}"; SimulatePipelineRequest request = new SimulatePipelineRequest( new BytesArray(json.getBytes(StandardCharsets.UTF_8)), XContentType.JSON diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java index 0760a13ca87d9..5618e18742267 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java @@ -886,14 +886,7 @@ public void testSearchTemplate() throws IOException { searchTemplateRequest.setRequest(new SearchRequest("index")); searchTemplateRequest.setScriptType(ScriptType.INLINE); - searchTemplateRequest.setScript( - "{" + - " \"query\": {" + - " \"match\": {" + - " \"num\": {{number}}" + - " }" + - " }" + - "}"); + searchTemplateRequest.setScript("{ \"query\": { \"match\": { \"num\": {{number}} } } }"); Map scriptParams = new HashMap<>(); scriptParams.put("number", 10); @@ -941,14 +934,7 @@ public void testRenderSearchTemplate() throws IOException { SearchTemplateRequest searchTemplateRequest = new SearchTemplateRequest(); searchTemplateRequest.setScriptType(ScriptType.INLINE); - searchTemplateRequest.setScript( - "{" + - " \"query\": {" + - " \"match\": {" + - " \"num\": {{number}}" + - " }" + - " }" + - "}"); + searchTemplateRequest.setScript("{ \"query\": { \"match\": { \"num\": {{number}} } } }"); Map scriptParams = new HashMap<>(); scriptParams.put("number", 10); @@ -985,14 +971,7 @@ public void testMultiSearchTemplate() throws Exception { SearchTemplateRequest goodRequest = new SearchTemplateRequest(); goodRequest.setRequest(new SearchRequest("index")); goodRequest.setScriptType(ScriptType.INLINE); - goodRequest.setScript( - "{" + - " \"query\": {" + - " \"match\": {" + - " \"num\": {{number}}" + - " }" + - " }" + - "}"); + goodRequest.setScript("{ \"query\": { \"match\": { \"num\": {{number}} } } }"); Map scriptParams = new HashMap<>(); scriptParams.put("number", 10); goodRequest.setScriptParams(scriptParams); @@ -1044,14 +1023,7 @@ public void testMultiSearchTemplateAllBad() throws Exception { SearchTemplateRequest badRequest1 = new SearchTemplateRequest(); badRequest1.setRequest(new SearchRequest("index")); badRequest1.setScriptType(ScriptType.INLINE); - badRequest1.setScript( - "{" + - " \"query\": {" + - " \"match\": {" + - " \"num\": {{number}}" + - " }" + - " }" + - "}"); + badRequest1.setScript("{ \"query\": { \"match\": { \"num\": {{number}} } } }"); Map scriptParams = new HashMap<>(); scriptParams.put("number", "BAD NUMBER"); badRequest1.setScriptParams(scriptParams); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/TasksIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/TasksIT.java index f0515c0d9e2d1..8f2b6cc1d1849 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/TasksIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/TasksIT.java @@ -93,8 +93,16 @@ public void testGetValidTask() throws Exception { RestClient lowClient = highLevelClient().getLowLevelClient(); Request request = new Request("POST", "_reindex"); request.addParameter("wait_for_completion", "false"); - request.setJsonEntity("{" + " \"source\": {\n" + " \"index\": \"source1\"\n" + " },\n" + " \"dest\": {\n" - + " \"index\": \"dest\"\n" + " }" + "}"); + request.setJsonEntity( + "{" + + " \"source\": {\n" + + " \"index\": \"source1\"\n" + + " },\n" + + " \"dest\": {\n" + + " \"index\": \"dest\"\n" + + " }" + + "}" + ); Response response = lowClient.performRequest(request); Map map = entityAsMap(response); Object taskId = map.get("task"); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java index 601ff20030de0..8bc33f9d00eef 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java @@ -564,15 +564,9 @@ public void testGetMapping() throws IOException { CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); PutMappingRequest request = new PutMappingRequest("twitter"); - request.source( - "{\n" + - " \"properties\": {\n" + - " \"message\": {\n" + - " \"type\": \"text\"\n" + - " }\n" + - " }\n" + - "}", // <1> - XContentType.JSON); + request.source("{ \"properties\": { \"message\": { \"type\": \"text\" } } }", + XContentType.JSON + ); AcknowledgedResponse putMappingResponse = client.indices().putMapping(request, RequestOptions.DEFAULT); assertTrue(putMappingResponse.isAcknowledged()); } @@ -618,15 +612,9 @@ public void testGetMappingAsync() throws Exception { CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"), RequestOptions.DEFAULT); assertTrue(createIndexResponse.isAcknowledged()); PutMappingRequest request = new PutMappingRequest("twitter"); - request.source( - "{\n" + - " \"properties\": {\n" + - " \"message\": {\n" + - " \"type\": \"text\"\n" + - " }\n" + - " }\n" + - "}", // <1> - XContentType.JSON); + request.source("{ \"properties\": { \"message\": { \"type\": \"text\" } } }", + XContentType.JSON + ); AcknowledgedResponse putMappingResponse = client.indices().putMapping(request, RequestOptions.DEFAULT); assertTrue(putMappingResponse.isAcknowledged()); } @@ -2296,14 +2284,9 @@ public void testGetTemplates() throws Exception { PutIndexTemplateRequest putRequest = new PutIndexTemplateRequest("my-template", List.of("pattern-1", "log-*")); putRequest.settings(Settings.builder().put("index.number_of_shards", 3).put("index.number_of_replicas", 1)); - putRequest.mapping( - "{\n" + - " \"properties\": {\n" + - " \"message\": {\n" + - " \"type\": \"text\"\n" + - " }\n" + - " }\n" + - "}", XContentType.JSON); + putRequest.mapping("{ \"properties\": { \"message\": { \"type\": \"text\" } } }", + XContentType.JSON + ); assertTrue(client.indices().putTemplate(putRequest, RequestOptions.DEFAULT).isAcknowledged()); } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/QueryDSLDocumentationTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/QueryDSLDocumentationTests.java index 08d13dfc14e01..60e6248fede07 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/QueryDSLDocumentationTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/QueryDSLDocumentationTests.java @@ -441,26 +441,28 @@ public void testWrapper() { } public void testRankFeatureSaturation() { - RankFeatureQueryBuilders.saturation( - "pagerank"); // <1> + RankFeatureQueryBuilders.saturation("pagerank"); } public void testRankFeatureSaturationPivot() { RankFeatureQueryBuilders.saturation( - "pagerank", // <1> - 8); // <2> + "pagerank", + 8 + ); } public void testRankFeatureLog() { RankFeatureQueryBuilders.log( - "pagerank", // <1> - 4f); // <2> + "pagerank", + 4f + ); } public void testRankFeatureSigmoid() { RankFeatureQueryBuilders.sigmoid( - "pagerank", // <1> - 7, // <2> - 0.6f); // <3> + "pagerank", + 7, + 0.6f + ); } } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java index ff5deb5cbdfcc..47ae97fe3573f 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java @@ -773,11 +773,10 @@ public void testSearchTemplateWithInlineScript() throws Exception { // end::render-search-template-response assertNotNull(source); - assertEquals(( - "{" + - " \"size\" : \"5\"," + - " \"query\": { \"match\" : { \"title\" : \"elasticsearch\" } }" + - "}").replaceAll("\\s+", ""), source.utf8ToString()); + assertEquals( + ("{ \"size\" : \"5\", \"query\": { \"match\" : { \"title\" : \"elasticsearch\" } }}").replaceAll("\\s+", ""), + source.utf8ToString() + ); } public void testSearchTemplateWithStoredScript() throws Exception { diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/StoredScriptsDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/StoredScriptsDocumentationIT.java index ac4f2269f9c79..fdaf92c00d19c 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/StoredScriptsDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/StoredScriptsDocumentationIT.java @@ -1,4 +1,6 @@ -package org.elasticsearch.client.documentation;/* +package org.elasticsearch.client.documentation; + +/* * Licensed to Elasticsearch under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/indices/GetIndexTemplatesResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/indices/GetIndexTemplatesResponseTests.java index be063c500305d..5470736790106 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/indices/GetIndexTemplatesResponseTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/indices/GetIndexTemplatesResponseTests.java @@ -55,11 +55,7 @@ public class GetIndexTemplatesResponseTests extends ESTestCase { - static final String mappingString = "{\"properties\":{" - + "\"f1\": {\"type\":\"text\"}," - + "\"f2\": {\"type\":\"keyword\"}" - + "}}"; - + static final String mappingString = "{\"properties\":{\"f1\": {\"type\":\"text\"},\"f2\": {\"type\":\"keyword\"}}}"; public void testFromXContent() throws IOException { xContentTester(this::createParser, diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/rollup/GetRollupCapsResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/rollup/GetRollupCapsResponseTests.java index a9c3a59faf5ae..f49b273a971b4 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/rollup/GetRollupCapsResponseTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/rollup/GetRollupCapsResponseTests.java @@ -43,11 +43,12 @@ protected void toXContent(GetRollupCapsResponse response, XContentBuilder builde @Override protected Predicate randomFieldsExcludeFilter() { - return (field) -> + return (field) -> { // base cannot have extra things in it - "".equals(field) - // the field list expects to be a nested object of a certain type - || field.contains("fields"); + return "".equals(field) + // the field list expects to be a nested object of a certain type + || field.contains("fields"); + }; } @Override diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/rollup/GetRollupIndexCapsResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/rollup/GetRollupIndexCapsResponseTests.java index 20e29aef0df64..ac138719bd0ce 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/rollup/GetRollupIndexCapsResponseTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/rollup/GetRollupIndexCapsResponseTests.java @@ -44,10 +44,12 @@ protected void toXContent(GetRollupIndexCapsResponse response, XContentBuilder b @Override protected Predicate randomFieldsExcludeFilter() { return (field) -> + { // base cannot have extra things in it - "".equals(field) + return "".equals(field) // the field list expects to be a nested object of a certain type || field.contains("fields"); + }; } @Override diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/security/ClearRealmCacheResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/security/ClearRealmCacheResponseTests.java index d21ed1a71a0c4..4909ae804ef68 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/security/ClearRealmCacheResponseTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/security/ClearRealmCacheResponseTests.java @@ -55,12 +55,13 @@ public void testParseFromXContent() throws IOException { assertThat(response.getHeader().getFailures().get(0).getMessage(), containsString("reason=test")); } - try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, - DeprecationHandler.THROW_UNSUPPORTED_OPERATION, - "{" + nodesHeader + clusterName + "\"nodes\" : { " + - "\"id1\": { \"name\": \"a\"}, " + - "\"id2\": { \"name\": \"b\"}" + - "}}")) { + try ( + XContentParser parser = JsonXContent.jsonXContent.createParser( + NamedXContentRegistry.EMPTY, + DeprecationHandler.THROW_UNSUPPORTED_OPERATION, + "{" + nodesHeader + clusterName + "\"nodes\" : { \"id1\": { \"name\": \"a\"}, \"id2\": { \"name\": \"b\"}}}" + ) + ) { ClearRealmCacheResponse response = ClearRealmCacheResponse.fromXContent(parser); assertNotNull(response); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/security/ClearRolesCacheResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/security/ClearRolesCacheResponseTests.java index 068b6ec452908..b8ce5f203a6cf 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/security/ClearRolesCacheResponseTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/security/ClearRolesCacheResponseTests.java @@ -55,12 +55,13 @@ public void testParseFromXContent() throws IOException { assertThat(response.getHeader().getFailures().get(0).getMessage(), containsString("reason=test")); } - try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY, - DeprecationHandler.THROW_UNSUPPORTED_OPERATION, - "{" + nodesHeader + clusterName + "\"nodes\" : { " + - "\"id1\": { \"name\": \"a\"}, " + - "\"id2\": { \"name\": \"b\"}" + - "}}")) { + try ( + XContentParser parser = JsonXContent.jsonXContent.createParser( + NamedXContentRegistry.EMPTY, + DeprecationHandler.THROW_UNSUPPORTED_OPERATION, + "{" + nodesHeader + clusterName + "\"nodes\" : { \"id1\": { \"name\": \"a\"}, \"id2\": { \"name\": \"b\"}}}" + ) + ) { ClearRolesCacheResponse response = ClearRolesCacheResponse.fromXContent(parser); assertNotNull(response); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/security/CreateTokenRequestTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/security/CreateTokenRequestTests.java index 760d5e52cb38f..02e420dd39301 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/security/CreateTokenRequestTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/security/CreateTokenRequestTests.java @@ -34,12 +34,10 @@ public void testCreateTokenFromPassword() { assertThat(new String(request.getPassword()), equalTo("top secret password")); assertThat(request.getScope(), nullValue()); assertThat(request.getRefreshToken(), nullValue()); - assertThat(Strings.toString(request), equalTo("{" + - "\"grant_type\":\"password\"," + - "\"username\":\"jsmith\"," + - "\"password\":\"top secret password\"" + - "}" - )); + assertThat( + Strings.toString(request), + equalTo("{\"grant_type\":\"password\",\"username\":\"jsmith\",\"password\":\"top secret password\"}") + ); } public void testCreateTokenFromRefreshToken() { @@ -49,11 +47,10 @@ public void testCreateTokenFromRefreshToken() { assertThat(request.getScope(), nullValue()); assertThat(request.getUsername(), nullValue()); assertThat(request.getPassword(), nullValue()); - assertThat(Strings.toString(request), equalTo("{" + - "\"grant_type\":\"refresh_token\"," + - "\"refresh_token\":\"9a7f41cf-9918-4d1f-bfaa-ad3f8f9f02b9\"" + - "}" - )); + assertThat( + Strings.toString(request), + equalTo("{\"grant_type\":\"refresh_token\",\"refresh_token\":\"9a7f41cf-9918-4d1f-bfaa-ad3f8f9f02b9\"}") + ); } public void testCreateTokenFromClientCredentials() { @@ -74,8 +71,10 @@ public void testCreateTokenFromKerberosTicket() { assertThat(request.getPassword(), nullValue()); assertThat(request.getRefreshToken(), nullValue()); assertThat(new String(request.getKerberosTicket()), equalTo("top secret kerberos ticket")); - assertThat(Strings.toString(request), equalTo("{\"grant_type\":\"_kerberos\"," + - "\"kerberos_ticket\":\"top secret kerberos ticket\"}")); + assertThat( + Strings.toString(request), + equalTo("{\"grant_type\":\"_kerberos\",\"kerberos_ticket\":\"top secret kerberos ticket\"}") + ); } public void testEqualsAndHashCode() { diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/security/InvalidateTokenRequestTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/security/InvalidateTokenRequestTests.java index 0fa7ce2792ba5..e26c9c03d5ad4 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/security/InvalidateTokenRequestTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/security/InvalidateTokenRequestTests.java @@ -32,10 +32,7 @@ public void testInvalidateAccessToken() { final InvalidateTokenRequest request = InvalidateTokenRequest.accessToken(token); assertThat(request.getAccessToken(), equalTo(token)); assertThat(request.getRefreshToken(), nullValue()); - assertThat(Strings.toString(request), equalTo("{" + - "\"token\":\"Tf01rrAymdUjxMY4VlG3gV3gsFFUWxVVPrztX+4uhe0=\"" + - "}" - )); + assertThat(Strings.toString(request), equalTo("{\"token\":\"Tf01rrAymdUjxMY4VlG3gV3gsFFUWxVVPrztX+4uhe0=\"}")); } public void testInvalidateRefreshToken() { @@ -43,10 +40,7 @@ public void testInvalidateRefreshToken() { final InvalidateTokenRequest request = InvalidateTokenRequest.refreshToken(token); assertThat(request.getAccessToken(), nullValue()); assertThat(request.getRefreshToken(), equalTo(token)); - assertThat(Strings.toString(request), equalTo("{" + - "\"refresh_token\":\"4rE0YPT/oHODS83TbTtYmuh8\"" + - "}" - )); + assertThat(Strings.toString(request), equalTo("{\"refresh_token\":\"4rE0YPT/oHODS83TbTtYmuh8\"}")); } public void testInvalidateRealmTokens() { @@ -56,10 +50,7 @@ public void testInvalidateRealmTokens() { assertThat(request.getRefreshToken(), nullValue()); assertThat(request.getRealmName(), equalTo(realmName)); assertThat(request.getUsername(), nullValue()); - assertThat(Strings.toString(request), equalTo("{" + - "\"realm_name\":\"native\"" + - "}" - )); + assertThat(Strings.toString(request), equalTo("{\"realm_name\":\"native\"}")); } public void testInvalidateUserTokens() { @@ -69,10 +60,7 @@ public void testInvalidateUserTokens() { assertThat(request.getRefreshToken(), nullValue()); assertThat(request.getRealmName(), nullValue()); assertThat(request.getUsername(), equalTo(username)); - assertThat(Strings.toString(request), equalTo("{" + - "\"username\":\"user\"" + - "}" - )); + assertThat(Strings.toString(request), equalTo("{\"username\":\"user\"}")); } public void testInvalidateUserTokensInRealm() { @@ -83,12 +71,7 @@ public void testInvalidateUserTokensInRealm() { assertThat(request.getRefreshToken(), nullValue()); assertThat(request.getRealmName(), equalTo(realmName)); assertThat(request.getUsername(), equalTo(username)); - assertThat(Strings.toString(request), equalTo("{" + - "\"realm_name\":\"native\"," + - "\"username\":\"user\"" + - - "}" - )); + assertThat(Strings.toString(request), equalTo("{\"realm_name\":\"native\",\"username\":\"user\"}")); } public void testEqualsAndHashCode() { diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/security/PutRoleMappingRequestTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/security/PutRoleMappingRequestTests.java index bf5ba34bffc5c..3f0b72cff772c 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/security/PutRoleMappingRequestTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/security/PutRoleMappingRequestTests.java @@ -34,6 +34,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import static org.hamcrest.Matchers.equalTo; @@ -132,16 +133,27 @@ public void testPutRoleMappingRequestToXContent() throws IOException { final XContentBuilder builder = XContentFactory.jsonBuilder(); putRoleMappingRequest.toXContent(builder, ToXContent.EMPTY_PARAMS); final String output = Strings.toString(builder); - final String expected = - "{"+ - "\"enabled\":" + enabled + "," + - "\"roles\":[\"superuser\"]," + - "\"role_templates\":[]," + - "\"rules\":{" + - "\"field\":{\"username\":[\"user\"]}" + - "}," + - "\"metadata\":{\"k1\":\"v1\"}" + - "}"; + final String expected = String.format( + Locale.ROOT, + "{" + + " \"enabled\": %s," + + " \"roles\": [" + + " \"superuser\"" + + " ]," + + "\"role_templates\":[]," + + "\"rules\":{" + + " \"field\": {" + + " \"username\": [" + + " \"user\"" + + " ]" + + " }" + + "}," + + " \"metadata\": {" + + " \"k1\": \"v1\"" + + " }" + + "}", + enabled + ).replaceAll("\\s+", ""); assertThat(output, equalTo(expected)); } @@ -164,19 +176,34 @@ public void testPutRoleMappingRequestWithTemplateToXContent() throws IOException final XContentBuilder builder = XContentFactory.jsonBuilder(); putRoleMappingRequest.toXContent(builder, ToXContent.EMPTY_PARAMS); final String output = Strings.toString(builder); - final String expected = - "{"+ - "\"enabled\":" + enabled + "," + - "\"roles\":[]," + - "\"role_templates\":[" + - "{\"template\":\"{\\\"source\\\":\\\"_realm_{{realm.name}}\\\"}\",\"format\":\"string\"}," + - "{\"template\":\"{\\\"source\\\":\\\"some_role\\\"}\",\"format\":\"string\"}" + - "]," + - "\"rules\":{" + - "\"field\":{\"username\":[\"user\"]}" + - "}," + - "\"metadata\":{\"k1\":\"v1\"}" + - "}"; + final String expected = String.format( + Locale.ROOT, + "{" + + " \"enabled\": %s," + + "\"roles\":[]," + + "\"role_templates\":[" + + " {" + + " \"template\": \"{\\\"source\\\":\\\"_realm_{{realm.name}}\\\"}\"," + + " \"format\": \"string\"" + + " }," + + " {" + + " \"template\": \"{\\\"source\\\":\\\"some_role\\\"}\"," + + " \"format\": \"string\"" + + " }" + + "]," + + "\"rules\":{" + + " \"field\": {" + + " \"username\": [" + + " \"user\"" + + " ]" + + " }" + + "}," + + " \"metadata\": {" + + " \"k1\": \"v1\"" + + " }" + + "}", + enabled + ).replaceAll("\\s+", ""); assertThat(output, equalTo(expected)); } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/transform/transforms/pivot/GroupConfigTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/transform/transforms/pivot/GroupConfigTests.java index f20fe098ecbca..1749c390994e6 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/transform/transforms/pivot/GroupConfigTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/transform/transforms/pivot/GroupConfigTests.java @@ -87,21 +87,25 @@ protected Predicate getRandomFieldsExcludeFilter() { public void testLenientParsing() throws IOException { BytesArray json = new BytesArray( - "{ " + - "\"unknown-field\":\"foo\", " + - "\"destination-field\": {" + - "\"terms\": {" + - "\"field\": \"term-field\"" + - "}" + - "}," + - "\"unknown-field-2\":\"bar\"," + - "\"destination-field2\": {" + - "\"terms\": {" + - "\"field\": \"term-field2\"" + - "}" + - "}," + - "\"array-field\" : [1.0, 2.0]" + - "}"); + "{" + + " \"unknown-field\": \"foo\"," + + " \"destination-field\": {" + + " \"terms\": {" + + " \"field\": \"term-field\"" + + " }" + + " }," + + " \"unknown-field-2\": \"bar\"," + + " \"destination-field2\": {" + + " \"terms\": {" + + " \"field\": \"term-field2\"" + + " }" + + " }," + + " \"array-field\": [" + + " 1," + + " 2" + + " ]" + + "}" + ); XContentParser parser = JsonXContent.jsonXContent .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, json.streamInput()); @@ -116,20 +120,21 @@ public void testLenientParsing() throws IOException { public void testLenientParsingUnknowGroupType() throws IOException { BytesArray json = new BytesArray( - "{ " + - "\"destination-field1\": {" + - "\"newgroup\": {" + - "\"field1\": \"bar\"," + - "\"field2\": \"foo\"" + - "}" + - "}," + - "\"unknown-field\":\"bar\"," + - "\"destination-field2\": {" + - "\"terms\": {" + - "\"field\": \"term-field\"" + - "}" + - "}" + - "}"); + "{" + + " \"destination-field1\": {" + + " \"newgroup\": {" + + " \"field1\": \"bar\"," + + " \"field2\": \"foo\"" + + " }" + + " }," + + " \"unknown-field\": \"bar\"," + + " \"destination-field2\": {" + + " \"terms\": {" + + " \"field\": \"term-field\"" + + " }" + + " }" + + "}" + ); XContentParser parser = JsonXContent.jsonXContent .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, json.streamInput()); From d5ed817b0f73d26271d4391a1b580a8222eadfd1 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Tue, 29 Oct 2019 09:32:20 +0000 Subject: [PATCH 03/12] Remove deprecated include-type methods from HLRC indices client (#48471) We have a number of deprecated methods on the high-level Rest client's IndicesClient that take server-side object classes and allow users to pass the include_type_name parameter. These all have equivalent methods that use HLRC classes instead, the only difference being the lack of the types parameter. This commit removes these deprecated methods. --- .../elasticsearch/client/IndicesClient.java | 302 ------------------ .../client/IndicesRequestConverters.java | 161 ---------- .../elasticsearch/client/IndicesClientIT.java | 261 --------------- .../client/IndicesRequestConvertersTests.java | 262 +-------------- 4 files changed, 1 insertion(+), 985 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java index 418623931aacb..df8fd6afb421b 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesClient.java @@ -148,50 +148,6 @@ public Cancellable createAsync(CreateIndexRequest createIndexRequest, CreateIndexResponse::fromXContent, listener, emptySet()); } - /** - * Creates an index using the Create Index API. - * See - * Create Index API on elastic.co - * @param createIndexRequest the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @return the response - * @throws IOException in case there is a problem sending the request or parsing back the response - * - * @deprecated This method uses an old request object which still refers to types, a deprecated feature. The - * method {@link #create(CreateIndexRequest, RequestOptions)} should be used instead, which accepts a new - * request object. - */ - @Deprecated - public org.elasticsearch.action.admin.indices.create.CreateIndexResponse create( - org.elasticsearch.action.admin.indices.create.CreateIndexRequest createIndexRequest, - RequestOptions options) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(createIndexRequest, - IndicesRequestConverters::createIndex, options, - org.elasticsearch.action.admin.indices.create.CreateIndexResponse::fromXContent, emptySet()); - } - - /** - * Asynchronously creates an index using the Create Index API. - * See - * Create Index API on elastic.co - * @param createIndexRequest the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @param listener the listener to be notified upon request completion - * - * @deprecated This method uses an old request object which still refers to types, a deprecated feature. The - * method {@link #createAsync(CreateIndexRequest, RequestOptions, ActionListener)} should be used instead, - * which accepts a new request object. - * @return cancellable that may be used to cancel the request - */ - @Deprecated - public Cancellable createAsync(org.elasticsearch.action.admin.indices.create.CreateIndexRequest createIndexRequest, - RequestOptions options, - ActionListener listener) { - return restHighLevelClient.performRequestAsyncAndParseEntity(createIndexRequest, - IndicesRequestConverters::createIndex, options, - org.elasticsearch.action.admin.indices.create.CreateIndexResponse::fromXContent, listener, emptySet()); - } - /** * Updates the mappings on an index using the Put Mapping API. * See @@ -221,46 +177,6 @@ public Cancellable putMappingAsync(PutMappingRequest putMappingRequest, RequestO AcknowledgedResponse::fromXContent, listener, emptySet()); } - /** - * Updates the mappings on an index using the Put Mapping API. - * See - * Put Mapping API on elastic.co - * @param putMappingRequest the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @return the response - * @throws IOException in case there is a problem sending the request or parsing back the response - * - * @deprecated This method uses an old request object which still refers to types, a deprecated feature. The method - * {@link #putMapping(PutMappingRequest, RequestOptions)} should be used instead, which accepts a new request object. - */ - @Deprecated - public AcknowledgedResponse putMapping(org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest, - RequestOptions options) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(putMappingRequest, IndicesRequestConverters::putMapping, options, - AcknowledgedResponse::fromXContent, emptySet()); - } - - /** - * Asynchronously updates the mappings on an index using the Put Mapping API. - * See - * Put Mapping API on elastic.co - * @param putMappingRequest the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @param listener the listener to be notified upon request completion - * - * @deprecated This method uses an old request object which still refers to types, a deprecated feature. The - * method {@link #putMappingAsync(PutMappingRequest, RequestOptions, ActionListener)} should be used instead, - * which accepts a new request object. - * @return cancellable that may be used to cancel the request - */ - @Deprecated - public Cancellable putMappingAsync(org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest, - RequestOptions options, - ActionListener listener) { - return restHighLevelClient.performRequestAsyncAndParseEntity(putMappingRequest, IndicesRequestConverters::putMapping, options, - AcknowledgedResponse::fromXContent, listener, emptySet()); - } - /** * Retrieves the mappings on an index or indices using the Get Mapping API. * See @@ -297,51 +213,6 @@ public Cancellable getMappingAsync(GetMappingsRequest getMappingsRequest, Reques emptySet()); } - /** - * Retrieves the field mappings on an index or indices using the Get Field Mapping API. - * See - * Get Field Mapping API on elastic.co - * @param getFieldMappingsRequest the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @return the response - * @throws IOException in case there is a problem sending the request or parsing back the response - * - * @deprecated This method uses old request and response objects which still refer to types, a deprecated feature. - * The method {@link #getFieldMapping(GetFieldMappingsRequest, RequestOptions)} should be used instead, which - * accepts a new request object. - */ - @Deprecated - public org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse getFieldMapping( - org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest getFieldMappingsRequest, - RequestOptions options) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(getFieldMappingsRequest, IndicesRequestConverters::getFieldMapping, - options, org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse::fromXContent, emptySet()); - } - - /** - * Asynchronously retrieves the field mappings on an index on indices using the Get Field Mapping API. - * See - * Get Field Mapping API on elastic.co - * @param getFieldMappingsRequest the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @param listener the listener to be notified upon request completion - * - * @deprecated This method uses old request and response objects which still refer to types, a deprecated feature. - * The method {@link #getFieldMappingAsync(GetFieldMappingsRequest, RequestOptions, ActionListener)} should be - * used instead, which accepts a new request object. - * @return cancellable that may be used to cancel the request - */ - @Deprecated - public Cancellable getFieldMappingAsync( - org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest getFieldMappingsRequest, - RequestOptions options, - ActionListener listener) { - return restHighLevelClient.performRequestAsyncAndParseEntity(getFieldMappingsRequest, - IndicesRequestConverters::getFieldMapping, options, - org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse::fromXContent, - listener, emptySet()); - } - /** * Retrieves the field mappings on an index or indices using the Get Field Mapping API. * See @@ -761,52 +632,6 @@ public Cancellable existsAsync(GetIndexRequest request, RequestOptions options, ); } - /** - * Checks if the index (indices) exists or not. - * See - * Indices Exists API on elastic.co - * @param request the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @return the response - * @throws IOException in case there is a problem sending the request - * @deprecated This method uses an old request object which still refers to types, a deprecated feature. The method - * {@link #exists(GetIndexRequest, RequestOptions)} should be used instead, which accepts a new request object. - */ - @Deprecated - public boolean exists(org.elasticsearch.action.admin.indices.get.GetIndexRequest request, RequestOptions options) throws IOException { - return restHighLevelClient.performRequest( - request, - IndicesRequestConverters::indicesExist, - options, - RestHighLevelClient::convertExistsResponse, - Collections.emptySet() - ); - } - - /** - * Asynchronously checks if the index (indices) exists or not. - * See - * Indices Exists API on elastic.co - * @param request the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @param listener the listener to be notified upon request completion - * @deprecated This method uses an old request object which still refers to types, a deprecated feature. The method - * {@link #existsAsync(GetIndexRequest, RequestOptions, ActionListener)} should be used instead, which accepts a new request object. - * @return cancellable that may be used to cancel the request - */ - @Deprecated - public Cancellable existsAsync(org.elasticsearch.action.admin.indices.get.GetIndexRequest request, RequestOptions options, - ActionListener listener) { - return restHighLevelClient.performRequestAsync( - request, - IndicesRequestConverters::indicesExist, - options, - RestHighLevelClient::convertExistsResponse, - listener, - Collections.emptySet() - ); - } - /** * Shrinks an index using the Shrink Index API. * See @@ -919,48 +744,6 @@ public Cancellable rolloverAsync(RolloverRequest rolloverRequest, RequestOptions RolloverResponse::fromXContent, listener, emptySet()); } - - /** - * Rolls over an index using the Rollover Index API. - * See - * Rollover Index API on elastic.co - * @param rolloverRequest the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @return the response - * @throws IOException in case there is a problem sending the request or parsing back the response - * - * @deprecated This method uses deprecated request and response objects. - * The method {@link #rollover(RolloverRequest, RequestOptions)} should be used instead, which accepts a new request object. - */ - @Deprecated - public org.elasticsearch.action.admin.indices.rollover.RolloverResponse rollover( - org.elasticsearch.action.admin.indices.rollover.RolloverRequest rolloverRequest, - RequestOptions options) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(rolloverRequest, IndicesRequestConverters::rollover, options, - org.elasticsearch.action.admin.indices.rollover.RolloverResponse::fromXContent, emptySet()); - } - - /** - * Asynchronously rolls over an index using the Rollover Index API. - * See - * Rollover Index API on elastic.co - * @param rolloverRequest the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @param listener the listener to be notified upon request completion - * - * @deprecated This method uses deprecated request and response objects. - * The method {@link #rolloverAsync(RolloverRequest, RequestOptions, ActionListener)} should be used instead, which - * accepts a new request object. - * @return cancellable that may be used to cancel the request - */ - @Deprecated - public Cancellable rolloverAsync(org.elasticsearch.action.admin.indices.rollover.RolloverRequest rolloverRequest, - RequestOptions options, - ActionListener listener) { - return restHighLevelClient.performRequestAsyncAndParseEntity(rolloverRequest, IndicesRequestConverters::rollover, options, - org.elasticsearch.action.admin.indices.rollover.RolloverResponse::fromXContent, listener, emptySet()); - } - /** * Gets one or more aliases using the Get Index Aliases API. * See Indices Aliases API on @@ -1021,48 +804,6 @@ public Cancellable putSettingsAsync(UpdateSettingsRequest updateSettingsRequest, AcknowledgedResponse::fromXContent, listener, emptySet()); } - - /** - * Puts an index template using the Index Templates API. - * See Index Templates API - * on elastic.co - * @param putIndexTemplateRequest the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @return the response - * @throws IOException in case there is a problem sending the request or parsing back the response - * @deprecated This old form of request allows types in mappings. Use {@link #putTemplate(PutIndexTemplateRequest, RequestOptions)} - * instead which introduces a new request object without types. - */ - @Deprecated - public AcknowledgedResponse putTemplate( - org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest putIndexTemplateRequest, - RequestOptions options) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(putIndexTemplateRequest, IndicesRequestConverters::putTemplate, options, - AcknowledgedResponse::fromXContent, emptySet()); - } - - /** - * Asynchronously puts an index template using the Index Templates API. - * See Index Templates API - * on elastic.co - * @param putIndexTemplateRequest the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @param listener the listener to be notified upon request completion - * @deprecated This old form of request allows types in mappings. - * Use {@link #putTemplateAsync(PutIndexTemplateRequest, RequestOptions, ActionListener)} - * instead which introduces a new request object without types. - * @return cancellable that may be used to cancel the request - */ - @Deprecated - public Cancellable putTemplateAsync( - org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest putIndexTemplateRequest, - RequestOptions options, ActionListener listener) { - return restHighLevelClient.performRequestAsyncAndParseEntity(putIndexTemplateRequest, - IndicesRequestConverters::putTemplate, options, - AcknowledgedResponse::fromXContent, listener, emptySet()); - } - - /** * Puts an index template using the Index Templates API. * See Index Templates API @@ -1129,27 +870,6 @@ public Cancellable validateQueryAsync(ValidateQueryRequest validateQueryRequest, ValidateQueryResponse::fromXContent, listener, emptySet()); } - /** - * Gets index templates using the Index Templates API. The mappings will be returned in a legacy deprecated format, where the - * mapping definition is nested under the type name. - * See Index Templates API - * on elastic.co - * @param getIndexTemplatesRequest the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @return the response - * @throws IOException in case there is a problem sending the request or parsing back the response - * @deprecated This method uses an old response object which still refers to types, a deprecated feature. Use - * {@link #getIndexTemplate(GetIndexTemplatesRequest, RequestOptions)} instead which returns a new response object - */ - @Deprecated - public org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse getTemplate( - GetIndexTemplatesRequest getIndexTemplatesRequest, RequestOptions options) throws IOException { - return restHighLevelClient.performRequestAndParseEntity(getIndexTemplatesRequest, - IndicesRequestConverters::getTemplatesWithDocumentTypes, - options, - org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse::fromXContent, emptySet()); - } - /** * Gets index templates using the Index Templates API * See Index Templates API @@ -1166,28 +886,6 @@ public GetIndexTemplatesResponse getIndexTemplate(GetIndexTemplatesRequest getIn options, GetIndexTemplatesResponse::fromXContent, emptySet()); } - /** - * Asynchronously gets index templates using the Index Templates API. The mappings will be returned in a legacy deprecated format, - * where the mapping definition is nested under the type name. - * See Index Templates API - * on elastic.co - * @param getIndexTemplatesRequest the request - * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized - * @param listener the listener to be notified upon request completion - * @deprecated This method uses an old response object which still refers to types, a deprecated feature. Use - * {@link #getIndexTemplateAsync(GetIndexTemplatesRequest, RequestOptions, ActionListener)} instead which returns a new response object - * @return cancellable that may be used to cancel the request - */ - @Deprecated - public Cancellable getTemplateAsync(GetIndexTemplatesRequest getIndexTemplatesRequest, RequestOptions options, - ActionListener listener) { - return restHighLevelClient.performRequestAsyncAndParseEntity(getIndexTemplatesRequest, - IndicesRequestConverters::getTemplatesWithDocumentTypes, - options, - org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse::fromXContent, - listener, emptySet()); - } - /** * Asynchronously gets index templates using the Index Templates API * See Index Templates API diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java index 96f56afe4d1ca..ce392111cd471 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java @@ -58,8 +58,6 @@ import java.io.IOException; import java.util.Locale; -import static org.elasticsearch.rest.BaseRestHandler.INCLUDE_TYPE_NAME_PARAMETER; - final class IndicesRequestConverters { private IndicesRequestConverters() {} @@ -115,21 +113,6 @@ static Request createIndex(CreateIndexRequest createIndexRequest) throws IOExcep return request; } - static Request createIndex(org.elasticsearch.action.admin.indices.create.CreateIndexRequest createIndexRequest) - throws IOException { - String endpoint = RequestConverters.endpoint(createIndexRequest.indices()); - Request request = new Request(HttpPut.METHOD_NAME, endpoint); - - RequestConverters.Params parameters = new RequestConverters.Params(); - parameters.withTimeout(createIndexRequest.timeout()); - parameters.withMasterTimeout(createIndexRequest.masterNodeTimeout()); - parameters.withWaitForActiveShards(createIndexRequest.waitForActiveShards()); - parameters.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true"); - request.addParameters(parameters.asMap()); - request.setEntity(RequestConverters.createEntity(createIndexRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE)); - return request; - } - static Request updateAliases(IndicesAliasesRequest indicesAliasesRequest) throws IOException { Request request = new Request(HttpPost.METHOD_NAME, "/_aliases"); @@ -153,29 +136,6 @@ static Request putMapping(PutMappingRequest putMappingRequest) throws IOExceptio return request; } - /** - * converter for the legacy server-side {@link org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest} that still supports - * types - */ - @Deprecated - static Request putMapping(org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest) throws IOException { - // The concreteIndex is an internal concept, not applicable to requests made over the REST API. - if (putMappingRequest.getConcreteIndex() != null) { - throw new IllegalArgumentException("concreteIndex cannot be set on PutMapping requests made over the REST API"); - } - - Request request = new Request(HttpPut.METHOD_NAME, RequestConverters.endpoint(putMappingRequest.indices(), - "_mapping", putMappingRequest.type())); - - RequestConverters.Params parameters = new RequestConverters.Params(); - parameters.withTimeout(putMappingRequest.timeout()); - parameters.withMasterTimeout(putMappingRequest.masterNodeTimeout()); - parameters.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true"); - request.addParameters(parameters.asMap()); - request.setEntity(RequestConverters.createEntity(putMappingRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE)); - return request; - } - static Request getMappings(GetMappingsRequest getMappingsRequest) { String[] indices = getMappingsRequest.indices() == null ? Strings.EMPTY_ARRAY : getMappingsRequest.indices(); @@ -210,28 +170,6 @@ static Request getFieldMapping(GetFieldMappingsRequest getFieldMappingsRequest) return request; } - @Deprecated - static Request getFieldMapping(org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest getFieldMappingsRequest) { - String[] indices = getFieldMappingsRequest.indices() == null ? Strings.EMPTY_ARRAY : getFieldMappingsRequest.indices(); - String[] types = getFieldMappingsRequest.types() == null ? Strings.EMPTY_ARRAY : getFieldMappingsRequest.types(); - String[] fields = getFieldMappingsRequest.fields() == null ? Strings.EMPTY_ARRAY : getFieldMappingsRequest.fields(); - - String endpoint = new RequestConverters.EndpointBuilder().addCommaSeparatedPathParts(indices) - .addPathPartAsIs("_mapping").addCommaSeparatedPathParts(types) - .addPathPartAsIs("field").addCommaSeparatedPathParts(fields) - .build(); - - Request request = new Request(HttpGet.METHOD_NAME, endpoint); - - RequestConverters.Params parameters = new RequestConverters.Params(); - parameters.withIndicesOptions(getFieldMappingsRequest.indicesOptions()); - parameters.withIncludeDefaults(getFieldMappingsRequest.includeDefaults()); - parameters.withLocal(getFieldMappingsRequest.local()); - parameters.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true"); - request.addParameters(parameters.asMap()); - return request; - } - static Request refresh(RefreshRequest refreshRequest) { String[] indices = refreshRequest.indices() == null ? Strings.EMPTY_ARRAY : refreshRequest.indices(); Request request = new Request(HttpPost.METHOD_NAME, RequestConverters.endpoint(indices, "_refresh")); @@ -360,25 +298,6 @@ static Request rollover(RolloverRequest rolloverRequest) throws IOException { return request; } - @Deprecated - static Request rollover(org.elasticsearch.action.admin.indices.rollover.RolloverRequest rolloverRequest) throws IOException { - String endpoint = new RequestConverters.EndpointBuilder().addPathPart(rolloverRequest.getAlias()).addPathPartAsIs("_rollover") - .addPathPart(rolloverRequest.getNewIndexName()).build(); - Request request = new Request(HttpPost.METHOD_NAME, endpoint); - - RequestConverters.Params params = new RequestConverters.Params(); - params.withTimeout(rolloverRequest.timeout()); - params.withMasterTimeout(rolloverRequest.masterNodeTimeout()); - params.withWaitForActiveShards(rolloverRequest.getCreateIndexRequest().waitForActiveShards()); - if (rolloverRequest.isDryRun()) { - params.putParam("dry_run", Boolean.TRUE.toString()); - } - params.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true"); - request.setEntity(RequestConverters.createEntity(rolloverRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE)); - request.addParameters(params.asMap()); - return request; - } - static Request getSettings(GetSettingsRequest getSettingsRequest) { String[] indices = getSettingsRequest.indices() == null ? Strings.EMPTY_ARRAY : getSettingsRequest.indices(); String[] names = getSettingsRequest.names() == null ? Strings.EMPTY_ARRAY : getSettingsRequest.names(); @@ -395,28 +314,6 @@ static Request getSettings(GetSettingsRequest getSettingsRequest) { return request; } - /** - * converter for the legacy server-side {@link org.elasticsearch.action.admin.indices.get.GetIndexRequest} that - * still supports types - */ - @Deprecated - static Request getIndex(org.elasticsearch.action.admin.indices.get.GetIndexRequest getIndexRequest) { - String[] indices = getIndexRequest.indices() == null ? Strings.EMPTY_ARRAY : getIndexRequest.indices(); - - String endpoint = RequestConverters.endpoint(indices); - Request request = new Request(HttpGet.METHOD_NAME, endpoint); - - RequestConverters.Params params = new RequestConverters.Params(); - params.withIndicesOptions(getIndexRequest.indicesOptions()); - params.withLocal(getIndexRequest.local()); - params.withIncludeDefaults(getIndexRequest.includeDefaults()); - params.withHuman(getIndexRequest.humanReadable()); - params.withMasterTimeout(getIndexRequest.masterNodeTimeout()); - params.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true"); - request.addParameters(params.asMap()); - return request; - } - static Request getIndex(GetIndexRequest getIndexRequest) { String[] indices = getIndexRequest.indices() == null ? Strings.EMPTY_ARRAY : getIndexRequest.indices(); @@ -433,28 +330,6 @@ static Request getIndex(GetIndexRequest getIndexRequest) { return request; } - /** - * converter for the legacy server-side {@link org.elasticsearch.action.admin.indices.get.GetIndexRequest} that - * still supports types - */ - @Deprecated - static Request indicesExist(org.elasticsearch.action.admin.indices.get.GetIndexRequest getIndexRequest) { - if (getIndexRequest.indices() == null || getIndexRequest.indices().length == 0) { - throw new IllegalArgumentException("indices are mandatory"); - } - String endpoint = RequestConverters.endpoint(getIndexRequest.indices(), ""); - Request request = new Request(HttpHead.METHOD_NAME, endpoint); - - RequestConverters.Params params = new RequestConverters.Params(); - params.withLocal(getIndexRequest.local()); - params.withHuman(getIndexRequest.humanReadable()); - params.withIndicesOptions(getIndexRequest.indicesOptions()); - params.withIncludeDefaults(getIndexRequest.includeDefaults()); - params.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true"); - request.addParameters(params.asMap()); - return request; - } - static Request indicesExist(GetIndexRequest getIndexRequest) { if (getIndexRequest.indices() == null || getIndexRequest.indices().length == 0) { throw new IllegalArgumentException("indices are mandatory"); @@ -485,30 +360,6 @@ static Request indexPutSettings(UpdateSettingsRequest updateSettingsRequest) thr return request; } - /** - * @deprecated This uses the old form of PutIndexTemplateRequest which uses types. - * Use (@link {@link #putTemplate(PutIndexTemplateRequest)} instead - */ - @Deprecated - static Request putTemplate(org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest putIndexTemplateRequest) - throws IOException { - String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_template") - .addPathPart(putIndexTemplateRequest.name()).build(); - Request request = new Request(HttpPut.METHOD_NAME, endpoint); - RequestConverters.Params params = new RequestConverters.Params(); - params.withMasterTimeout(putIndexTemplateRequest.masterNodeTimeout()); - if (putIndexTemplateRequest.create()) { - params.putParam("create", Boolean.TRUE.toString()); - } - if (Strings.hasText(putIndexTemplateRequest.cause())) { - params.putParam("cause", putIndexTemplateRequest.cause()); - } - params.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true"); - request.addParameters(params.asMap()); - request.setEntity(RequestConverters.createEntity(putIndexTemplateRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE)); - return request; - } - static Request putTemplate(PutIndexTemplateRequest putIndexTemplateRequest) throws IOException { String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_template") .addPathPart(putIndexTemplateRequest.name()).build(); @@ -552,16 +403,7 @@ static Request getAlias(GetAliasesRequest getAliasesRequest) { return request; } - @Deprecated - static Request getTemplatesWithDocumentTypes(GetIndexTemplatesRequest getIndexTemplatesRequest) { - return getTemplates(getIndexTemplatesRequest, true); - } - static Request getTemplates(GetIndexTemplatesRequest getIndexTemplatesRequest) { - return getTemplates(getIndexTemplatesRequest, false); - } - - private static Request getTemplates(GetIndexTemplatesRequest getIndexTemplatesRequest, boolean includeTypeName) { final String endpoint = new RequestConverters.EndpointBuilder() .addPathPartAsIs("_template") .addCommaSeparatedPathParts(getIndexTemplatesRequest.names()) @@ -570,9 +412,6 @@ private static Request getTemplates(GetIndexTemplatesRequest getIndexTemplatesRe final RequestConverters.Params params = new RequestConverters.Params(); params.withLocal(getIndexTemplatesRequest.isLocal()); params.withMasterTimeout(getIndexTemplatesRequest.getMasterNodeTimeout()); - if (includeTypeName) { - params.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true"); - } request.addParameters(params.asMap()); return request; } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java index a7400fcc872b4..8244138b0bc6e 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java @@ -94,14 +94,9 @@ import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction; -import org.elasticsearch.rest.action.admin.indices.RestGetIndexTemplateAction; -import org.elasticsearch.rest.action.admin.indices.RestPutIndexTemplateAction; -import org.elasticsearch.rest.action.admin.indices.RestRolloverIndexAction; import java.io.IOException; import java.util.Arrays; @@ -181,19 +176,6 @@ public void testIndicesExists() throws IOException { } } - public void testIndicesExistsWithTypes() throws IOException { - // Index present - String indexName = "test_index_exists_index_present"; - createIndex(indexName, Settings.EMPTY); - - org.elasticsearch.action.admin.indices.get.GetIndexRequest request - = new org.elasticsearch.action.admin.indices.get.GetIndexRequest(); - request.indices(indexName); - - boolean response = execute(request, highLevelClient().indices()::exists, highLevelClient().indices()::existsAsync); - assertTrue(response); - } - @SuppressWarnings({"unchecked", "rawtypes"}) public void testCreateIndex() throws IOException { { @@ -250,70 +232,6 @@ public void testCreateIndex() throws IOException { } } - @SuppressWarnings({"unchecked", "rawtypes"}) - public void testCreateIndexWithTypes() throws IOException { - { - // Create index - String indexName = "plain_index"; - assertFalse(indexExists(indexName)); - - org.elasticsearch.action.admin.indices.create.CreateIndexRequest createIndexRequest = - new org.elasticsearch.action.admin.indices.create.CreateIndexRequest(indexName); - - org.elasticsearch.action.admin.indices.create.CreateIndexResponse createIndexResponse = execute( - createIndexRequest, - highLevelClient().indices()::create, - highLevelClient().indices()::createAsync, - expectWarnings(RestCreateIndexAction.TYPES_DEPRECATION_MESSAGE)); - assertTrue(createIndexResponse.isAcknowledged()); - - assertTrue(indexExists(indexName)); - } - { - // Create index with mappings, aliases and settings - String indexName = "rich_index"; - assertFalse(indexExists(indexName)); - - org.elasticsearch.action.admin.indices.create.CreateIndexRequest createIndexRequest = - new org.elasticsearch.action.admin.indices.create.CreateIndexRequest(indexName); - - Alias alias = new Alias("alias_name"); - alias.filter("{\"term\":{\"year\":2016}}"); - alias.routing("1"); - createIndexRequest.alias(alias); - - Settings.Builder settings = Settings.builder(); - settings.put(SETTING_NUMBER_OF_REPLICAS, 2); - createIndexRequest.settings(settings); - - XContentBuilder mappingBuilder = JsonXContent.contentBuilder(); - mappingBuilder.startObject().startObject("properties").startObject("field"); - mappingBuilder.field("type", "text"); - mappingBuilder.endObject().endObject().endObject(); - createIndexRequest.mapping(MapperService.SINGLE_MAPPING_NAME, mappingBuilder); - - org.elasticsearch.action.admin.indices.create.CreateIndexResponse createIndexResponse = execute( - createIndexRequest, - highLevelClient().indices()::create, - highLevelClient().indices()::createAsync, - expectWarnings(RestCreateIndexAction.TYPES_DEPRECATION_MESSAGE)); - assertTrue(createIndexResponse.isAcknowledged()); - - Map getIndexResponse = getAsMap(indexName); - assertEquals("2", XContentMapValues.extractValue(indexName + ".settings.index.number_of_replicas", getIndexResponse)); - - Map aliasData = - (Map)XContentMapValues.extractValue(indexName + ".aliases.alias_name", getIndexResponse); - assertNotNull(aliasData); - assertEquals("1", aliasData.get("index_routing")); - Map filter = (Map) aliasData.get("filter"); - Map term = (Map) filter.get("term"); - assertEquals(2016, term.get("year")); - - assertEquals("text", XContentMapValues.extractValue(indexName + ".mappings.properties.field.type", getIndexResponse)); - } - } - public void testGetSettings() throws IOException { String indexName = "get_settings_index"; Settings basicSettings = Settings.builder() @@ -1080,31 +998,6 @@ public void testRollover() throws IOException { } } - public void testRolloverWithTypes() throws IOException { - highLevelClient().indices().create(new CreateIndexRequest("test").alias(new Alias("alias")), RequestOptions.DEFAULT); - highLevelClient().index(new IndexRequest("test").id("1").source("field", "value"), RequestOptions.DEFAULT); - highLevelClient().index(new IndexRequest("test").id("2").source("field", "value") - .setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL), RequestOptions.DEFAULT); - - org.elasticsearch.action.admin.indices.rollover.RolloverRequest rolloverRequest = - new org.elasticsearch.action.admin.indices.rollover.RolloverRequest("alias", "test_new"); - rolloverRequest.addMaxIndexDocsCondition(1); - rolloverRequest.getCreateIndexRequest().mapping("_doc", "field2", "type=keyword"); - - org.elasticsearch.action.admin.indices.rollover.RolloverResponse rolloverResponse = execute( - rolloverRequest, - highLevelClient().indices()::rollover, - highLevelClient().indices()::rolloverAsync, - expectWarnings(RestRolloverIndexAction.TYPES_DEPRECATION_MESSAGE) - ); - assertTrue(rolloverResponse.isRolledOver()); - assertFalse(rolloverResponse.isDryRun()); - Map conditionStatus = rolloverResponse.getConditionStatus(); - assertTrue(conditionStatus.get("[max_docs: 1]")); - assertEquals("test", rolloverResponse.getOldIndex()); - assertEquals("test_new", rolloverResponse.getNewIndex()); - } - public void testGetAlias() throws IOException { { createIndex("index1", Settings.EMPTY); @@ -1390,36 +1283,6 @@ public void testIndexPutSettingNonExistent() throws IOException { + "or check the breaking changes documentation for removed settings]")); } - @SuppressWarnings("unchecked") - public void testPutTemplateWithTypes() throws Exception { - org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest putTemplateRequest = - new org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest() - .name("my-template") - .patterns(Arrays.asList("pattern-1", "name-*")) - .order(10) - .create(randomBoolean()) - .settings(Settings.builder().put("number_of_shards", "3").put("number_of_replicas", "0")) - .mapping("doc", "host_name", "type=keyword", "description", "type=text") - .alias(new Alias("alias-1").indexRouting("abc")).alias(new Alias("{index}-write").searchRouting("xyz")); - - AcknowledgedResponse putTemplateResponse = execute(putTemplateRequest, - highLevelClient().indices()::putTemplate, highLevelClient().indices()::putTemplateAsync, - expectWarnings(RestPutIndexTemplateAction.TYPES_DEPRECATION_MESSAGE) - ); - assertThat(putTemplateResponse.isAcknowledged(), equalTo(true)); - - Map templates = getAsMap("/_template/my-template"); - assertThat(templates.keySet(), hasSize(1)); - assertThat(extractValue("my-template.order", templates), equalTo(10)); - assertThat(extractRawValues("my-template.index_patterns", templates), contains("pattern-1", "name-*")); - assertThat(extractValue("my-template.settings.index.number_of_shards", templates), equalTo("3")); - assertThat(extractValue("my-template.settings.index.number_of_replicas", templates), equalTo("0")); - assertThat(extractValue("my-template.mappings.properties.host_name.type", templates), equalTo("keyword")); - assertThat(extractValue("my-template.mappings.properties.description.type", templates), equalTo("text")); - assertThat((Map) extractValue("my-template.aliases.alias-1", templates), hasEntry("index_routing", "abc")); - assertThat((Map) extractValue("my-template.aliases.{index}-write", templates), hasEntry("search_routing", "xyz")); - } - @SuppressWarnings("unchecked") public void testPutTemplate() throws Exception { PutIndexTemplateRequest putTemplateRequest = new PutIndexTemplateRequest("my-template", List.of("pattern-1", "name-*")) @@ -1472,43 +1335,6 @@ public void testPutTemplateWithTypesUsingUntypedAPI() throws Exception { containsString("Root mapping definition has unsupported parameters: [my_doc_type")); } - @SuppressWarnings("unchecked") - public void testPutTemplateWithNoTypesUsingTypedApi() throws Exception { - org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest putTemplateRequest = - new org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest() - .name("my-template") - .patterns(Arrays.asList("pattern-1", "name-*")) - .order(10) - .create(randomBoolean()) - .settings(Settings.builder().put("number_of_shards", "3").put("number_of_replicas", "0")) - .mapping("my_doc_type", - // Note that the declared type is missing from the mapping - "{ " - + "\"properties\":{" - + "\"host_name\": {\"type\":\"keyword\"}," - + "\"description\": {\"type\":\"text\"}" - + "}" - + "}", XContentType.JSON) - .alias(new Alias("alias-1").indexRouting("abc")).alias(new Alias("{index}-write").searchRouting("xyz")); - - AcknowledgedResponse putTemplateResponse = execute(putTemplateRequest, - highLevelClient().indices()::putTemplate, highLevelClient().indices()::putTemplateAsync, - expectWarnings(RestPutIndexTemplateAction.TYPES_DEPRECATION_MESSAGE) - ); - assertThat(putTemplateResponse.isAcknowledged(), equalTo(true)); - - Map templates = getAsMap("/_template/my-template"); - assertThat(templates.keySet(), hasSize(1)); - assertThat(extractValue("my-template.order", templates), equalTo(10)); - assertThat(extractRawValues("my-template.index_patterns", templates), contains("pattern-1", "name-*")); - assertThat(extractValue("my-template.settings.index.number_of_shards", templates), equalTo("3")); - assertThat(extractValue("my-template.settings.index.number_of_replicas", templates), equalTo("0")); - assertThat(extractValue("my-template.mappings.properties.host_name.type", templates), equalTo("keyword")); - assertThat(extractValue("my-template.mappings.properties.description.type", templates), equalTo("text")); - assertThat((Map) extractValue("my-template.aliases.alias-1", templates), hasEntry("index_routing", "abc")); - assertThat((Map) extractValue("my-template.aliases.{index}-write", templates), hasEntry("search_routing", "xyz")); - } - public void testPutTemplateBadRequests() throws Exception { RestHighLevelClient client = highLevelClient(); @@ -1578,93 +1404,6 @@ public void testInvalidValidateQuery() throws IOException{ assertFalse(response.isValid()); } - // Tests the deprecated form of the API that returns templates with doc types (using the server-side's GetIndexTemplateResponse) - public void testCRUDIndexTemplateWithTypes() throws Exception { - RestHighLevelClient client = highLevelClient(); - - org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest putTemplate1 = - new org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest().name("template-1") - .patterns(Arrays.asList("pattern-1", "name-1")).alias(new Alias("alias-1")); - assertThat(execute(putTemplate1, client.indices()::putTemplate, client.indices()::putTemplateAsync - , expectWarnings(RestPutIndexTemplateAction.TYPES_DEPRECATION_MESSAGE)) - .isAcknowledged(), equalTo(true)); - org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest putTemplate2 = - new org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest().name("template-2") - .patterns(Arrays.asList("pattern-2", "name-2")) - .mapping("custom_doc_type", "name", "type=text") - .settings(Settings.builder().put("number_of_shards", "2").put("number_of_replicas", "0")); - assertThat(execute(putTemplate2, client.indices()::putTemplate, client.indices()::putTemplateAsync, - expectWarnings(RestPutIndexTemplateAction.TYPES_DEPRECATION_MESSAGE)) - .isAcknowledged(), equalTo(true)); - - org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse getTemplate1 = execute( - new GetIndexTemplatesRequest("template-1"), - client.indices()::getTemplate, client.indices()::getTemplateAsync, - expectWarnings(RestGetIndexTemplateAction.TYPES_DEPRECATION_MESSAGE)); - assertThat(getTemplate1.getIndexTemplates(), hasSize(1)); - org.elasticsearch.cluster.metadata.IndexTemplateMetaData template1 = getTemplate1.getIndexTemplates().get(0); - assertThat(template1.name(), equalTo("template-1")); - assertThat(template1.patterns(), contains("pattern-1", "name-1")); - assertTrue(template1.aliases().containsKey("alias-1")); - - //Check the typed version of the call - org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse getTemplate2 = - execute(new GetIndexTemplatesRequest("template-2"), - client.indices()::getTemplate, client.indices()::getTemplateAsync, - expectWarnings(RestGetIndexTemplateAction.TYPES_DEPRECATION_MESSAGE)); - assertThat(getTemplate2.getIndexTemplates(), hasSize(1)); - org.elasticsearch.cluster.metadata.IndexTemplateMetaData template2 = getTemplate2.getIndexTemplates().get(0); - assertThat(template2.name(), equalTo("template-2")); - assertThat(template2.patterns(), contains("pattern-2", "name-2")); - assertTrue(template2.aliases().isEmpty()); - assertThat(template2.settings().get("index.number_of_shards"), equalTo("2")); - assertThat(template2.settings().get("index.number_of_replicas"), equalTo("0")); - // Ugly deprecated form of API requires use of doc type to get at mapping object which is CompressedXContent - assertTrue(template2.mappings().containsKey("custom_doc_type")); - - List names = randomBoolean() - ? Arrays.asList("*plate-1", "template-2") - : Arrays.asList("template-*"); - GetIndexTemplatesRequest getBothRequest = new GetIndexTemplatesRequest(names); - org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse getBoth = execute( - getBothRequest, client.indices()::getTemplate, client.indices()::getTemplateAsync, - expectWarnings(RestGetIndexTemplateAction.TYPES_DEPRECATION_MESSAGE)); - assertThat(getBoth.getIndexTemplates(), hasSize(2)); - assertThat(getBoth.getIndexTemplates().stream().map(org.elasticsearch.cluster.metadata.IndexTemplateMetaData::getName).toArray(), - arrayContainingInAnyOrder("template-1", "template-2")); - - GetIndexTemplatesRequest getAllRequest = new GetIndexTemplatesRequest(); - org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse getAll = execute( - getAllRequest, client.indices()::getTemplate, client.indices()::getTemplateAsync, - expectWarnings(RestGetIndexTemplateAction.TYPES_DEPRECATION_MESSAGE)); - assertThat(getAll.getIndexTemplates().size(), greaterThanOrEqualTo(2)); - assertThat(getAll.getIndexTemplates().stream().map(org.elasticsearch.cluster.metadata.IndexTemplateMetaData::getName) - .collect(Collectors.toList()), - hasItems("template-1", "template-2")); - - assertTrue(execute(new DeleteIndexTemplateRequest("template-1"), - client.indices()::deleteTemplate, client.indices()::deleteTemplateAsync).isAcknowledged()); - assertThat(expectThrows(ElasticsearchException.class, () -> execute(new GetIndexTemplatesRequest("template-1"), - client.indices()::getTemplate, client.indices()::getTemplateAsync)).status(), equalTo(RestStatus.NOT_FOUND)); - assertThat(expectThrows(ElasticsearchException.class, () -> execute(new DeleteIndexTemplateRequest("template-1"), - client.indices()::deleteTemplate, client.indices()::deleteTemplateAsync)).status(), equalTo(RestStatus.NOT_FOUND)); - - assertThat(execute(new GetIndexTemplatesRequest("template-*"), - client.indices()::getTemplate, client.indices()::getTemplateAsync, - expectWarnings(RestGetIndexTemplateAction.TYPES_DEPRECATION_MESSAGE)).getIndexTemplates(), hasSize(1)); - assertThat(execute(new GetIndexTemplatesRequest("template-*"), - client.indices()::getTemplate, client.indices()::getTemplateAsync, - expectWarnings(RestGetIndexTemplateAction.TYPES_DEPRECATION_MESSAGE)).getIndexTemplates() - .get(0).name(), equalTo("template-2")); - - assertTrue(execute(new DeleteIndexTemplateRequest("template-*"), - client.indices()::deleteTemplate, client.indices()::deleteTemplateAsync).isAcknowledged()); - assertThat(expectThrows(ElasticsearchException.class, () -> execute(new GetIndexTemplatesRequest("template-*"), - client.indices()::getTemplate, client.indices()::getTemplateAsync, - expectWarnings(RestGetIndexTemplateAction.TYPES_DEPRECATION_MESSAGE))).status(), equalTo(RestStatus.NOT_FOUND)); - } - - public void testCRUDIndexTemplate() throws Exception { RestHighLevelClient client = highLevelClient(); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesRequestConvertersTests.java index 115dabe4b049a..b73fa0e897972 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesRequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesRequestConvertersTests.java @@ -80,7 +80,6 @@ import static org.elasticsearch.client.indices.RandomCreateIndexGenerator.randomMapping; import static org.elasticsearch.index.RandomCreateIndexGenerator.randomIndexSettings; import static org.elasticsearch.index.alias.RandomAliasActionsGenerator.randomAliasAction; -import static org.elasticsearch.rest.BaseRestHandler.INCLUDE_TYPE_NAME_PARAMETER; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.Matchers.nullValue; @@ -124,34 +123,6 @@ public void testIndicesExistEmptyIndices() { -> IndicesRequestConverters.indicesExist(new GetIndexRequest((String[]) null))); } - public void testIndicesExistEmptyIndicesWithTypes() { - LuceneTestCase.expectThrows(IllegalArgumentException.class, - () -> IndicesRequestConverters.indicesExist(new org.elasticsearch.action.admin.indices.get.GetIndexRequest())); - LuceneTestCase.expectThrows(IllegalArgumentException.class, () -> IndicesRequestConverters - .indicesExist(new org.elasticsearch.action.admin.indices.get.GetIndexRequest().indices((String[]) null))); - } - - public void testIndicesExistWithTypes() { - String[] indices = RequestConvertersTests.randomIndicesNames(1, 10); - - org.elasticsearch.action.admin.indices.get.GetIndexRequest getIndexRequest = - new org.elasticsearch.action.admin.indices.get.GetIndexRequest().indices(indices); - - Map expectedParams = new HashMap<>(); - RequestConvertersTests.setRandomIndicesOptions(getIndexRequest::indicesOptions, getIndexRequest::indicesOptions, expectedParams); - RequestConvertersTests.setRandomLocal(getIndexRequest::local, expectedParams); - RequestConvertersTests.setRandomHumanReadable(getIndexRequest::humanReadable, expectedParams); - RequestConvertersTests.setRandomIncludeDefaults(getIndexRequest::includeDefaults, expectedParams); - expectedParams.put(INCLUDE_TYPE_NAME_PARAMETER, "true"); - - final Request request = IndicesRequestConverters.indicesExist(getIndexRequest); - - Assert.assertEquals(HttpHead.METHOD_NAME, request.getMethod()); - Assert.assertEquals("/" + String.join(",", indices), request.getEndpoint()); - Assert.assertThat(expectedParams, equalTo(request.getParameters())); - Assert.assertNull(request.getEntity()); - } - public void testCreateIndex() throws IOException { CreateIndexRequest createIndexRequest = RandomCreateIndexGenerator.randomCreateIndexRequest(); @@ -167,23 +138,6 @@ public void testCreateIndex() throws IOException { RequestConvertersTests.assertToXContentBody(createIndexRequest, request.getEntity()); } - public void testCreateIndexWithTypes() throws IOException { - org.elasticsearch.action.admin.indices.create.CreateIndexRequest createIndexRequest = - org.elasticsearch.index.RandomCreateIndexGenerator.randomCreateIndexRequest(); - - Map expectedParams = new HashMap<>(); - RequestConvertersTests.setRandomTimeout(createIndexRequest::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams); - RequestConvertersTests.setRandomMasterTimeout(createIndexRequest, expectedParams); - RequestConvertersTests.setRandomWaitForActiveShards(createIndexRequest::waitForActiveShards, expectedParams); - expectedParams.put(INCLUDE_TYPE_NAME_PARAMETER, "true"); - - Request request = IndicesRequestConverters.createIndex(createIndexRequest); - Assert.assertEquals("/" + createIndexRequest.index(), request.getEndpoint()); - Assert.assertEquals(expectedParams, request.getParameters()); - Assert.assertEquals(HttpPut.METHOD_NAME, request.getMethod()); - RequestConvertersTests.assertToXContentBody(createIndexRequest, request.getEntity()); - } - public void testCreateIndexNullIndex() { IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> new CreateIndexRequest(null)); assertEquals(e.getMessage(), "The index name cannot be null."); @@ -227,37 +181,6 @@ public void testPutMapping() throws IOException { RequestConvertersTests.assertToXContentBody(putMappingRequest, request.getEntity()); } - public void testPutMappingWithTypes() throws IOException { - org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest = - new org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest(); - - String[] indices = RequestConvertersTests.randomIndicesNames(0, 5); - putMappingRequest.indices(indices); - - String type = ESTestCase.randomAlphaOfLengthBetween(3, 10); - putMappingRequest.type(type); - - Map expectedParams = new HashMap<>(); - - RequestConvertersTests.setRandomTimeout(putMappingRequest::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams); - RequestConvertersTests.setRandomMasterTimeout(putMappingRequest, expectedParams); - expectedParams.put(INCLUDE_TYPE_NAME_PARAMETER, "true"); - - Request request = IndicesRequestConverters.putMapping(putMappingRequest); - StringJoiner endpoint = new StringJoiner("/", "/", ""); - String index = String.join(",", indices); - if (Strings.hasLength(index)) { - endpoint.add(index); - } - endpoint.add("_mapping"); - endpoint.add(type); - Assert.assertEquals(endpoint.toString(), request.getEndpoint()); - - Assert.assertEquals(expectedParams, request.getParameters()); - Assert.assertEquals(HttpPut.METHOD_NAME, request.getMethod()); - RequestConvertersTests.assertToXContentBody(putMappingRequest, request.getEntity()); - } - public void testGetMapping() { GetMappingsRequest getMappingRequest = new GetMappingsRequest(); @@ -331,64 +254,6 @@ public void testGetFieldMapping() { Assert.assertThat(HttpGet.METHOD_NAME, equalTo(request.getMethod())); } - public void testGetFieldMappingWithTypes() { - org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest getFieldMappingsRequest = - new org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest(); - - String[] indices = Strings.EMPTY_ARRAY; - if (randomBoolean()) { - indices = RequestConvertersTests.randomIndicesNames(0, 5); - getFieldMappingsRequest.indices(indices); - } else if (randomBoolean()) { - getFieldMappingsRequest.indices((String[]) null); - } - - String type = null; - if (randomBoolean()) { - type = randomAlphaOfLengthBetween(3, 10); - getFieldMappingsRequest.types(type); - } else if (randomBoolean()) { - getFieldMappingsRequest.types((String[]) null); - } - - String[] fields = null; - if (randomBoolean()) { - fields = new String[randomIntBetween(1, 5)]; - for (int i = 0; i < fields.length; i++) { - fields[i] = randomAlphaOfLengthBetween(3, 10); - } - getFieldMappingsRequest.fields(fields); - } else if (randomBoolean()) { - getFieldMappingsRequest.fields((String[]) null); - } - - Map expectedParams = new HashMap<>(); - - RequestConvertersTests.setRandomIndicesOptions(getFieldMappingsRequest::indicesOptions, getFieldMappingsRequest::indicesOptions, - expectedParams); - RequestConvertersTests.setRandomLocal(getFieldMappingsRequest::local, expectedParams); - expectedParams.put(INCLUDE_TYPE_NAME_PARAMETER, "true"); - - Request request = IndicesRequestConverters.getFieldMapping(getFieldMappingsRequest); - StringJoiner endpoint = new StringJoiner("/", "/", ""); - String index = String.join(",", indices); - if (Strings.hasLength(index)) { - endpoint.add(index); - } - endpoint.add("_mapping"); - if (type != null) { - endpoint.add(type); - } - endpoint.add("field"); - if (fields != null) { - endpoint.add(String.join(",", fields)); - } - Assert.assertThat(endpoint.toString(), equalTo(request.getEndpoint())); - - Assert.assertThat(expectedParams, equalTo(request.getParameters())); - Assert.assertThat(HttpGet.METHOD_NAME, equalTo(request.getMethod())); - } - public void testDeleteIndex() { String[] indices = RequestConvertersTests.randomIndicesNames(0, 5); DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indices); @@ -488,41 +353,6 @@ public void testGetIndex() throws IOException { Assert.assertThat(request.getEntity(), nullValue()); } - public void testGetIndexWithTypes() throws IOException { - String[] indicesUnderTest = ESTestCase.randomBoolean() ? null : RequestConvertersTests.randomIndicesNames(0, 5); - - org.elasticsearch.action.admin.indices.get.GetIndexRequest getIndexRequest = - new org.elasticsearch.action.admin.indices.get.GetIndexRequest().indices(indicesUnderTest); - - Map expectedParams = new HashMap<>(); - RequestConvertersTests.setRandomMasterTimeout(getIndexRequest, expectedParams); - RequestConvertersTests.setRandomIndicesOptions(getIndexRequest::indicesOptions, getIndexRequest::indicesOptions, expectedParams); - RequestConvertersTests.setRandomLocal(getIndexRequest::local, expectedParams); - RequestConvertersTests.setRandomHumanReadable(getIndexRequest::humanReadable, expectedParams); - expectedParams.put(INCLUDE_TYPE_NAME_PARAMETER, "true"); - - if (ESTestCase.randomBoolean()) { - // the request object will not have include_defaults present unless it is set to - // true - getIndexRequest.includeDefaults(ESTestCase.randomBoolean()); - if (getIndexRequest.includeDefaults()) { - expectedParams.put("include_defaults", Boolean.toString(true)); - } - } - - StringJoiner endpoint = new StringJoiner("/", "/", ""); - if (indicesUnderTest != null && indicesUnderTest.length > 0) { - endpoint.add(String.join(",", indicesUnderTest)); - } - - Request request = IndicesRequestConverters.getIndex(getIndexRequest); - - Assert.assertThat(endpoint.toString(), equalTo(request.getEndpoint())); - Assert.assertThat(request.getParameters(), equalTo(expectedParams)); - Assert.assertThat(request.getMethod(), equalTo(HttpGet.METHOD_NAME)); - Assert.assertThat(request.getEntity(), nullValue()); - } - public void testDeleteIndexEmptyIndices() { String[] indices = ESTestCase.randomBoolean() ? null : Strings.EMPTY_ARRAY; ActionRequestValidationException validationException = new DeleteIndexRequest(indices).validate(); @@ -889,49 +719,6 @@ public void testRollover() throws IOException { Assert.assertEquals(expectedParams, request.getParameters()); } - public void testRolloverWithTypes() throws IOException { - org.elasticsearch.action.admin.indices.rollover.RolloverRequest rolloverRequest = - new org.elasticsearch.action.admin.indices.rollover.RolloverRequest(ESTestCase.randomAlphaOfLengthBetween(3, 10), - ESTestCase.randomBoolean() ? null : ESTestCase.randomAlphaOfLengthBetween(3, 10)); - Map expectedParams = new HashMap<>(); - RequestConvertersTests.setRandomTimeout(rolloverRequest::timeout, rolloverRequest.timeout(), expectedParams); - RequestConvertersTests.setRandomMasterTimeout(rolloverRequest, expectedParams); - if (ESTestCase.randomBoolean()) { - rolloverRequest.dryRun(ESTestCase.randomBoolean()); - if (rolloverRequest.isDryRun()) { - expectedParams.put("dry_run", "true"); - } - } - expectedParams.put(INCLUDE_TYPE_NAME_PARAMETER, "true"); - if (ESTestCase.randomBoolean()) { - rolloverRequest.addMaxIndexAgeCondition(new TimeValue(ESTestCase.randomNonNegativeLong())); - } - if (ESTestCase.randomBoolean()) { - String type = ESTestCase.randomAlphaOfLengthBetween(3, 10); - rolloverRequest.getCreateIndexRequest().mapping(type, - org.elasticsearch.index.RandomCreateIndexGenerator.randomMapping(type)); - } - if (ESTestCase.randomBoolean()) { - org.elasticsearch.index.RandomCreateIndexGenerator.randomAliases(rolloverRequest.getCreateIndexRequest()); - } - if (ESTestCase.randomBoolean()) { - rolloverRequest.getCreateIndexRequest().settings( - org.elasticsearch.index.RandomCreateIndexGenerator.randomIndexSettings()); - } - RequestConvertersTests.setRandomWaitForActiveShards(rolloverRequest.getCreateIndexRequest()::waitForActiveShards, expectedParams); - - Request request = IndicesRequestConverters.rollover(rolloverRequest); - if (rolloverRequest.getNewIndexName() == null) { - Assert.assertEquals("/" + rolloverRequest.getAlias() + "/_rollover", request.getEndpoint()); - } else { - Assert.assertEquals("/" + rolloverRequest.getAlias() + "/_rollover/" + rolloverRequest.getNewIndexName(), - request.getEndpoint()); - } - Assert.assertEquals(HttpPost.METHOD_NAME, request.getMethod()); - RequestConvertersTests.assertToXContentBody(rolloverRequest, request.getEntity()); - Assert.assertEquals(expectedParams, request.getParameters()); - } - public void testGetAlias() { GetAliasesRequest getAliasesRequest = new GetAliasesRequest(); @@ -990,52 +777,6 @@ public void testIndexPutSettings() throws IOException { Assert.assertEquals(expectedParams, request.getParameters()); } - public void testPutTemplateRequestWithTypes() throws Exception { - Map names = new HashMap<>(); - names.put("log", "log"); - names.put("template#1", "template%231"); - names.put("-#template", "-%23template"); - names.put("foo^bar", "foo%5Ebar"); - - org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest putTemplateRequest = - new org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest() - .name(ESTestCase.randomFrom(names.keySet())) - .patterns(Arrays.asList(ESTestCase.generateRandomStringArray(20, 100, false, false))); - if (ESTestCase.randomBoolean()) { - putTemplateRequest.order(ESTestCase.randomInt()); - } - if (ESTestCase.randomBoolean()) { - putTemplateRequest.version(ESTestCase.randomInt()); - } - if (ESTestCase.randomBoolean()) { - putTemplateRequest.settings(Settings.builder().put("setting-" + ESTestCase.randomInt(), ESTestCase.randomTimeValue())); - } - Map expectedParams = new HashMap<>(); - if (ESTestCase.randomBoolean()) { - putTemplateRequest.mapping("doc-" + ESTestCase.randomInt(), - "field-" + ESTestCase.randomInt(), "type=" + ESTestCase.randomFrom("text", "keyword")); - } - expectedParams.put(INCLUDE_TYPE_NAME_PARAMETER, "true"); - if (ESTestCase.randomBoolean()) { - putTemplateRequest.alias(new Alias("alias-" + ESTestCase.randomInt())); - } - if (ESTestCase.randomBoolean()) { - expectedParams.put("create", Boolean.TRUE.toString()); - putTemplateRequest.create(true); - } - if (ESTestCase.randomBoolean()) { - String cause = ESTestCase.randomUnicodeOfCodepointLengthBetween(1, 50); - putTemplateRequest.cause(cause); - expectedParams.put("cause", cause); - } - RequestConvertersTests.setRandomMasterTimeout(putTemplateRequest, expectedParams); - - Request request = IndicesRequestConverters.putTemplate(putTemplateRequest); - Assert.assertThat(request.getEndpoint(), equalTo("/_template/" + names.get(putTemplateRequest.name()))); - Assert.assertThat(request.getParameters(), equalTo(expectedParams)); - RequestConvertersTests.assertToXContentBody(putTemplateRequest, request.getEntity()); - } - public void testPutTemplateRequest() throws Exception { Map names = new HashMap<>(); names.put("log", "log"); @@ -1122,8 +863,7 @@ public void testGetTemplateRequest() throws Exception { RequestConvertersTests.setRandomMasterTimeout(getTemplatesRequest::setMasterNodeTimeout, expectedParams); RequestConvertersTests.setRandomLocal(getTemplatesRequest::setLocal, expectedParams); - Request request = IndicesRequestConverters.getTemplatesWithDocumentTypes(getTemplatesRequest); - expectedParams.put(INCLUDE_TYPE_NAME_PARAMETER, "true"); + Request request = IndicesRequestConverters.getTemplates(getTemplatesRequest); Assert.assertThat(request.getEndpoint(), equalTo("/_template/" + names.stream().map(encodes::get).collect(Collectors.joining(",")))); Assert.assertThat(request.getParameters(), equalTo(expectedParams)); From 2d881f1bb05f3c757a67d71bbcdbf883d305ec99 Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Tue, 29 Oct 2019 09:33:31 +0000 Subject: [PATCH 04/12] Refine the auto-formatting settings (#48446) * Split arguments for methods, constructors etc into separate lines when they wrap * Enable "joined wrapped lines", which basically means the formatter will ignore existing line breaks and join and re-wrap statements. I had originally hesitated about enabling this, but without it the codebase's style won't be as consistent as it should be, defeating the point of all this formatting business. * Disable formatting between `// tag::` and `// end::` comments, which are the code snippet markers for the docs. They need a different line length, which isn't possible to configure separately. * Detect and preserve aligned line comments at the end of consecutive lines. * And a bunch of other tweaks. Also update the contribution guidelines. --- .eclipseformat.xml | 40 ++++++++++++++++++++-------------------- CONTRIBUTING.md | 22 ++++++++++++++++------ 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/.eclipseformat.xml b/.eclipseformat.xml index 4df52d1b60364..9ff0aa1f4081f 100644 --- a/.eclipseformat.xml +++ b/.eclipseformat.xml @@ -29,7 +29,7 @@ - + @@ -39,15 +39,15 @@ - + - + - + @@ -64,7 +64,7 @@ - + @@ -89,7 +89,7 @@ - + @@ -98,7 +98,7 @@ - + @@ -128,11 +128,11 @@ - + - + @@ -143,7 +143,7 @@ - + @@ -167,7 +167,7 @@ - + @@ -189,8 +189,8 @@ - - + + @@ -202,12 +202,12 @@ - + - - + + - + @@ -225,7 +225,7 @@ - + @@ -240,7 +240,7 @@ - + @@ -291,7 +291,7 @@ - + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8f753d55d0361..99a6de6f050fa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -109,15 +109,15 @@ and `JAVA11_HOME` available so that the tests can pass. Elasticsearch uses the Gradle wrapper for its build. You can execute Gradle using the wrapper via the `gradlew` script in the root of the repository. -We support development in the Eclipse and IntelliJ IDEs. -For Eclipse, the minimum version that we support is [4.13][eclipse]. +We support development in the Eclipse and IntelliJ IDEs. +For Eclipse, the minimum version that we support is [4.13][eclipse]. For IntelliJ, the minimum version that we support is [IntelliJ 2017.2][intellij]. ### Configuring IDEs And Running Tests Eclipse users can automatically configure their IDE: `./gradlew eclipse` then `File: Import: Gradle : Existing Gradle Project`. -Additionally you will want to ensure that Eclipse is using 2048m of heap by modifying +Additionally you will want to ensure that Eclipse is using 2048m of heap by modifying `eclipse.ini` accordingly to avoid GC overhead and OOM errors. IntelliJ users can automatically configure their IDE: `./gradlew idea` @@ -175,9 +175,12 @@ Please follow these formatting guidelines: * Java indent is 4 spaces * Line width is 140 characters -* Lines of code surrounded by `// tag` and `// end` comments are included +* Lines of code surrounded by `// tag::NAME` and `// end::NAME` comments are included in the documentation and should only be 76 characters wide not counting - leading indentation + leading indentation. Such regions of code are not formatted automatically as + it is not possible to change the line length rule of the formatter for + part of a file. Please format such sections sympathetically with the rest + of the code, while keeping lines to maximum length of 76 characters. * Wildcard imports (`import foo.bar.baz.*`) are forbidden and will cause the build to fail. This can be done automatically by your IDE: * Eclipse: `Preferences->Java->Code Style->Organize Imports`. There are @@ -187,6 +190,13 @@ Please follow these formatting guidelines: There are two configuration options: `Class count to use import with '*'` and `Names count to use static import with '*'`. Set their values to 99999 or some other absurdly high value. +* If *absolutely* necessary, you can disable formatting for regions of code + with the `// tag::NAME` and `// end::NAME` directives, but note that + these are intended for use in documentation, so please make it clear what + you have done, and only do this where the benefit clearly outweighs the + decrease in consistency. +* Note that JavaDoc and block comments i.e. `/* ... */` are not formatted, + but line comments i.e `// ...` are. #### Editor / IDE Support @@ -213,7 +223,7 @@ Spotless will write files to different copies of the formatted files, so that you can see how they differ and infer what is the problem. -The `paddedCell() option is disabled for normal operation in order to +The `paddedCell()` option is disabled for normal operation in order to detect any misbehaviour. You can enabled the option from the command line by running Gradle with `-Dspotless.paddedcell`. From cbfd61266e5b180e079b2f497dadf2b4c250c110 Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Tue, 29 Oct 2019 09:38:31 +0000 Subject: [PATCH 05/12] Improve resiliency to auto-formatting in libs, modules (#48448) Make a number of changes so that code in the `libs` and `modules` directories are more resilient to automatic formatting. This covers: * Format cipher lists vertically, instead of horizontally * Remove string concatenation where JSON fits on a single line * Move some comments around to they aren't auto-formatted to a strange place --- .../common/ssl/SslConfigurationLoader.java | 109 ++++++++--- .../ConstructingObjectParserTests.java | 179 ++++++------------ .../common/xcontent/ObjectParserTests.java | 55 ++---- .../analysis/common/CommonAnalysisPlugin.java | 4 +- 4 files changed, 164 insertions(+), 183 deletions(-) diff --git a/libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/SslConfigurationLoader.java b/libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/SslConfigurationLoader.java index e9a1ccad3e950..dd5a9e0b8dd02 100644 --- a/libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/SslConfigurationLoader.java +++ b/libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/SslConfigurationLoader.java @@ -69,30 +69,95 @@ public abstract class SslConfigurationLoader { static final List DEFAULT_PROTOCOLS = List.of("TLSv1.3", "TLSv1.2", "TLSv1.1"); private static final List JDK11_CIPHERS = List.of( - "TLS_AES_256_GCM_SHA384", "TLS_AES_128_GCM_SHA256", // TLSv1.3 cipher has PFS, AEAD, hardware support - "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", // PFS, AEAD, hardware support - "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", // PFS, AEAD, hardware support - "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", // PFS, hardware support - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", // PFS, hardware support - "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", // PFS, hardware support - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", // PFS, hardware support - "TLS_RSA_WITH_AES_256_GCM_SHA384", "TLS_RSA_WITH_AES_128_GCM_SHA256", // AEAD, hardware support - "TLS_RSA_WITH_AES_256_CBC_SHA256", "TLS_RSA_WITH_AES_128_CBC_SHA256", // hardware support - "TLS_RSA_WITH_AES_256_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA"); // hardware support + // TLSv1.3 cipher has PFS, AEAD, hardware support + "TLS_AES_256_GCM_SHA384", + "TLS_AES_128_GCM_SHA256", + + // PFS, AEAD, hardware support + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + + // PFS, AEAD, hardware support + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + + // PFS, hardware support + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", + "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", + + // PFS, hardware support + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", + + // PFS, hardware support + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", + + // PFS, hardware support + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + + // AEAD, hardware support + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + + // hardware support + "TLS_RSA_WITH_AES_256_CBC_SHA256", + "TLS_RSA_WITH_AES_128_CBC_SHA256", + + // hardware support + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA" + ); private static final List JDK12_CIPHERS = List.of( - "TLS_AES_256_GCM_SHA384", "TLS_AES_128_GCM_SHA256", // TLSv1.3 cipher has PFS, AEAD, hardware support - "TLS_CHACHA20_POLY1305_SHA256", // TLSv1.3 cipher has PFS, AEAD - "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", // PFS, AEAD, hardware support - "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", // PFS, AEAD, hardware support - "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", // PFS, AEAD - "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", // PFS, hardware support - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", // PFS, hardware support - "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", // PFS, hardware support - "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", // PFS, hardware support - "TLS_RSA_WITH_AES_256_GCM_SHA384", "TLS_RSA_WITH_AES_128_GCM_SHA256", // AEAD, hardware support - "TLS_RSA_WITH_AES_256_CBC_SHA256", "TLS_RSA_WITH_AES_128_CBC_SHA256", // hardware support - "TLS_RSA_WITH_AES_256_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA"); // hardware support + // TLSv1.3 cipher has PFS, AEAD, hardware support + "TLS_AES_256_GCM_SHA384", + "TLS_AES_128_GCM_SHA256", + + // TLSv1.3 cipher has PFS, AEAD + "TLS_CHACHA20_POLY1305_SHA256", + + // PFS, AEAD, hardware support + "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", + + // PFS, AEAD, hardware support + "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", + "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", + + // PFS, AEAD + "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", + "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", + + // PFS, hardware support + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", + "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", + + // PFS, hardware support + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", + + // PFS, hardware support + "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", + + // PFS, hardware support + "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", + "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", + + // AEAD, hardware support + "TLS_RSA_WITH_AES_256_GCM_SHA384", + "TLS_RSA_WITH_AES_128_GCM_SHA256", + + // hardware support + "TLS_RSA_WITH_AES_256_CBC_SHA256", + "TLS_RSA_WITH_AES_128_CBC_SHA256", + + // hardware support + "TLS_RSA_WITH_AES_256_CBC_SHA", + "TLS_RSA_WITH_AES_128_CBC_SHA" + ); static final List DEFAULT_CIPHERS = JavaVersion.current().compareTo(JavaVersion.parse("12")) > -1 ? JDK12_CIPHERS : JDK11_CIPHERS; diff --git a/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java b/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java index 00e34183d2f78..9020e962e12da 100644 --- a/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java +++ b/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ConstructingObjectParserTests.java @@ -91,10 +91,7 @@ public void testRandomOrder() throws Exception { } public void testMissingAllConstructorArgs() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\n" - + " \"mineral\": 1\n" - + "}"); + XContentParser parser = createParser(JsonXContent.jsonXContent, "{ \"mineral\": 1 }"); ConstructingObjectParser objectParser = randomBoolean() ? HasCtorArguments.PARSER : HasCtorArguments.PARSER_VEGETABLE_OPTIONAL; IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> objectParser.apply(parser, null)); @@ -106,31 +103,20 @@ public void testMissingAllConstructorArgs() throws IOException { } public void testMissingAllConstructorArgsButNotRequired() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\n" - + " \"mineral\": 1\n" - + "}"); + XContentParser parser = createParser(JsonXContent.jsonXContent, "{ \"mineral\": 1 }"); HasCtorArguments parsed = HasCtorArguments.PARSER_ALL_OPTIONAL.apply(parser, null); assertEquals(1, parsed.mineral); } public void testMissingSecondConstructorArg() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\n" - + " \"mineral\": 1,\n" - + " \"animal\": \"cat\"\n" - + "}"); + XContentParser parser = createParser(JsonXContent.jsonXContent, "{ \"mineral\": 1, \"animal\": \"cat\" }"); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> HasCtorArguments.PARSER.apply(parser, null)); assertEquals("Required [vegetable]", e.getMessage()); } public void testMissingSecondConstructorArgButNotRequired() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\n" - + " \"mineral\": 1,\n" - + " \"animal\": \"cat\"\n" - + "}"); + XContentParser parser = createParser(JsonXContent.jsonXContent, "{ \"mineral\": 1, \"animal\": \"cat\" }"); @SuppressWarnings("unchecked") HasCtorArguments parsed = randomFrom(HasCtorArguments.PARSER_VEGETABLE_OPTIONAL, HasCtorArguments.PARSER_ALL_OPTIONAL).apply(parser, null); @@ -139,11 +125,7 @@ public void testMissingSecondConstructorArgButNotRequired() throws IOException { } public void testMissingFirstConstructorArg() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\n" - + " \"mineral\": 1,\n" - + " \"vegetable\": 2\n" - + "}"); + XContentParser parser = createParser(JsonXContent.jsonXContent, "{ \"mineral\": 1, \"vegetable\": 2 }"); @SuppressWarnings("unchecked") IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> randomFrom(HasCtorArguments.PARSER, HasCtorArguments.PARSER_VEGETABLE_OPTIONAL).apply(parser, null)); @@ -151,23 +133,19 @@ public void testMissingFirstConstructorArg() throws IOException { } public void testMissingFirstConstructorArgButNotRequired() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\n" - + " \"mineral\": 1,\n" - + " \"vegetable\": 2\n" - + "}"); + XContentParser parser = createParser(JsonXContent.jsonXContent, "{ \"mineral\": 1, \"vegetable\": 2 }"); HasCtorArguments parsed = HasCtorArguments.PARSER_ALL_OPTIONAL.apply(parser, null); assertEquals(1, parsed.mineral); assertEquals((Integer) 2, parsed.vegetable); } public void testBadParam() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\n" - + " \"animal\": \"cat\",\n" - + " \"vegetable\": 2,\n" - + " \"a\": \"supercalifragilisticexpialidocious\"\n" - + "}"); + XContentParser parser = createParser( + JsonXContent.jsonXContent, + // The following JSON needs to include newlines, in order to affect the line numbers + // included in the exception + "{\n" + " \"animal\": \"cat\",\n" + " \"vegetable\": 2,\n" + " \"a\": \"supercalifragilisticexpialidocious\"\n" + "}" + ); XContentParseException e = expectThrows(XContentParseException.class, () -> randomFrom(HasCtorArguments.ALL_PARSERS).apply(parser, null)); assertThat(e.getMessage(), containsString("[has_required_arguments] failed to parse field [a]")); @@ -177,12 +155,12 @@ public void testBadParam() throws IOException { } public void testBadParamBeforeObjectBuilt() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\n" - + " \"a\": \"supercalifragilisticexpialidocious\",\n" - + " \"animal\": \"cat\"\n," - + " \"vegetable\": 2\n" - + "}"); + XContentParser parser = createParser( + JsonXContent.jsonXContent, + // The following JSON needs to include newlines, in order to affect the line numbers + // included in the exception + "{\n" + " \"a\": \"supercalifragilisticexpialidocious\",\n" + " \"animal\": \"cat\"\n," + " \"vegetable\": 2\n" + "}" + ); XContentParseException e = expectThrows(XContentParseException.class, () -> randomFrom(HasCtorArguments.ALL_PARSERS).apply(parser, null)); assertThat(e.getMessage(), containsString("[has_required_arguments] failed to parse field [vegetable]")); @@ -238,40 +216,25 @@ void setFoo(String foo) { parser.declareString(ctorArgOptional ? optionalConstructorArg() : constructorArg(), new ParseField("yeah")); // ctor arg first so we can test for the bug we found one time - XContentParser xcontent = createParser(JsonXContent.jsonXContent, - "{\n" - + " \"yeah\": \"!\",\n" - + " \"foo\": \"foo\"\n" - + "}"); + XContentParser xcontent = createParser(JsonXContent.jsonXContent, "{ \"yeah\": \"!\", \"foo\": \"foo\" }"); CalledOneTime result = parser.apply(xcontent, null); assertTrue(result.fooSet); // and ctor arg second just in case - xcontent = createParser(JsonXContent.jsonXContent, - "{\n" - + " \"foo\": \"foo\",\n" - + " \"yeah\": \"!\"\n" - + "}"); + xcontent = createParser(JsonXContent.jsonXContent, "{ \"foo\": \"foo\", \"yeah\": \"!\" }"); result = parser.apply(xcontent, null); assertTrue(result.fooSet); if (ctorArgOptional) { // and without the constructor arg if we've made it optional - xcontent = createParser(JsonXContent.jsonXContent, - "{\n" - + " \"foo\": \"foo\"\n" - + "}"); + xcontent = createParser(JsonXContent.jsonXContent, "{ \"foo\": \"foo\" }"); result = parser.apply(xcontent, null); } assertTrue(result.fooSet); } public void testIgnoreUnknownFields() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\n" - + " \"test\" : \"foo\",\n" - + " \"junk\" : 2\n" - + "}"); + XContentParser parser = createParser(JsonXContent.jsonXContent, "{ \"test\" : \"foo\", \"junk\" : 2 }"); class TestStruct { public final String test; TestStruct(String test) { @@ -286,11 +249,7 @@ class TestStruct { } public void testConstructObjectUsingContext() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\n" - + " \"animal\": \"dropbear\",\n" - + " \"mineral\": -8\n" - + "}"); + XContentParser parser = createParser(JsonXContent.jsonXContent, "{ \"animal\": \"dropbear\", \"mineral\": -8 }"); HasCtorArguments parsed = HasCtorArguments.PARSER_INT_CONTEXT.apply(parser, 42); assertEquals(Integer.valueOf(42), parsed.vegetable); assertEquals("dropbear", parsed.animal); @@ -410,12 +369,10 @@ private static void declareSetters(ConstructingObjectParser } public void testParseNamedObject() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"named\": {\n" - + " \"a\": {}" - + "},\"named_in_constructor\": {\n" - + " \"b\": {}" - + "}}"); + XContentParser parser = createParser( + JsonXContent.jsonXContent, + "{\"named\": { \"a\": {} }, \"named_in_constructor\": { \"b\": {} } }" + ); NamedObjectHolder h = NamedObjectHolder.PARSER.apply(parser, null); assertThat(h.named, hasSize(1)); assertEquals("a", h.named.get(0).name); @@ -425,12 +382,10 @@ public void testParseNamedObject() throws IOException { } public void testParseNamedObjectInOrder() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"named\": [\n" - + " {\"a\": {}}" - + "],\"named_in_constructor\": [\n" - + " {\"b\": {}}" - + "]}"); + XContentParser parser = createParser( + JsonXContent.jsonXContent, + "{\"named\": [ {\"a\": {}} ], \"named_in_constructor\": [ {\"b\": {}} ]}" + ); NamedObjectHolder h = NamedObjectHolder.PARSER.apply(parser, null); assertThat(h.named, hasSize(1)); assertEquals("a", h.named.get(0).name); @@ -440,12 +395,10 @@ public void testParseNamedObjectInOrder() throws IOException { } public void testParseNamedObjectTwoFieldsInArray() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"named\": [\n" - + " {\"a\": {}, \"b\": {}}" - + "],\"named_in_constructor\": [\n" - + " {\"c\": {}}" - + "]}"); + XContentParser parser = createParser( + JsonXContent.jsonXContent, + "{\"named\": [ {\"a\": {}, \"b\": {}}], \"named_in_constructor\": [ {\"c\": {}} ]}" + ); XContentParseException e = expectThrows(XContentParseException.class, () -> NamedObjectHolder.PARSER.apply(parser, null)); assertThat(e.getMessage(), containsString("[named_object_holder] failed to parse field [named]")); assertThat(e.getCause().getMessage(), @@ -454,12 +407,10 @@ public void testParseNamedObjectTwoFieldsInArray() throws IOException { } public void testParseNamedObjectTwoFieldsInArrayConstructorArg() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"named\": [\n" - + " {\"a\": {}}" - + "],\"named_in_constructor\": [\n" - + " {\"c\": {}, \"d\": {}}" - + "]}"); + XContentParser parser = createParser( + JsonXContent.jsonXContent, + "{\"named\": [ {\"a\": {}}], \"named_in_constructor\": [ {\"c\": {}, \"d\": {}} ]}" + ); XContentParseException e = expectThrows(XContentParseException.class, () -> NamedObjectHolder.PARSER.apply(parser, null)); assertThat(e.getMessage(), containsString("[named_object_holder] failed to parse field [named_in_constructor]")); assertThat(e.getCause().getMessage(), @@ -468,12 +419,7 @@ public void testParseNamedObjectTwoFieldsInArrayConstructorArg() throws IOExcept } public void testParseNamedObjectNoFieldsInArray() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"named\": [\n" - + " {}" - + "],\"named_in_constructor\": [\n" - + " {\"a\": {}}" - + "]}"); + XContentParser parser = createParser(JsonXContent.jsonXContent, "{\"named\": [ {} ], \"named_in_constructor\": [ {\"a\": {}} ]}"); XContentParseException e = expectThrows(XContentParseException.class, () -> NamedObjectHolder.PARSER.apply(parser, null)); assertThat(e.getMessage(), containsString("[named_object_holder] failed to parse field [named]")); assertThat(e.getCause().getMessage(), @@ -482,12 +428,7 @@ public void testParseNamedObjectNoFieldsInArray() throws IOException { } public void testParseNamedObjectNoFieldsInArrayConstructorArg() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"named\": [\n" - + " {\"a\": {}}" - + "],\"named_in_constructor\": [\n" - + " {}" - + "]}"); + XContentParser parser = createParser(JsonXContent.jsonXContent, "{\"named\": [ {\"a\": {}} ], \"named_in_constructor\": [ {} ]}"); XContentParseException e = expectThrows(XContentParseException.class, () -> NamedObjectHolder.PARSER.apply(parser, null)); assertThat(e.getMessage(), containsString("[named_object_holder] failed to parse field [named_in_constructor]")); assertThat(e.getCause().getMessage(), @@ -496,12 +437,10 @@ public void testParseNamedObjectNoFieldsInArrayConstructorArg() throws IOExcepti } public void testParseNamedObjectJunkInArray() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"named\": [\n" - + " \"junk\"" - + "],\"named_in_constructor\": [\n" - + " {\"a\": {}}" - + "]}"); + XContentParser parser = createParser( + JsonXContent.jsonXContent, + "{\"named\": [ \"junk\" ], \"named_in_constructor\": [ {\"a\": {}} ]}" + ); XContentParseException e = expectThrows(XContentParseException.class, () -> NamedObjectHolder.PARSER.apply(parser, null)); assertThat(e.getMessage(), containsString("[named_object_holder] failed to parse field [named]")); assertThat(e.getCause().getMessage(), @@ -510,12 +449,10 @@ public void testParseNamedObjectJunkInArray() throws IOException { } public void testParseNamedObjectJunkInArrayConstructorArg() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"named\": [\n" - + " {\"a\": {}}" - + "],\"named_in_constructor\": [\n" - + " \"junk\"" - + "]}"); + XContentParser parser = createParser( + JsonXContent.jsonXContent, + "{\"named\": [ {\"a\": {}} ], \"named_in_constructor\": [ \"junk\" ]}" + ); XContentParseException e = expectThrows(XContentParseException.class, () -> NamedObjectHolder.PARSER.apply(parser, null)); assertThat(e.getMessage(), containsString("[named_object_holder] failed to parse field [named_in_constructor]")); assertThat(e.getCause().getMessage(), @@ -524,11 +461,10 @@ public void testParseNamedObjectJunkInArrayConstructorArg() throws IOException { } public void testParseNamedObjectInOrderNotSupported() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"named\": [\n" - + " {\"a\": {}}" - + "],\"named_in_constructor\": {\"b\": {}}" - + "}"); + XContentParser parser = createParser( + JsonXContent.jsonXContent, + "{\"named\": [\n" + " {\"a\": {}}" + "],\"named_in_constructor\": {\"b\": {}}" + "}" + ); // Create our own parser for this test so we can disable support for the "ordered" mode specified by the array above @SuppressWarnings("unchecked") @@ -545,11 +481,10 @@ public void testParseNamedObjectInOrderNotSupported() throws IOException { } public void testParseNamedObjectInOrderNotSupportedConstructorArg() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"named\": {\"a\": {}}" - + ",\"named_in_constructor\": [\n" - + " {\"b\": {}}" - + "]}"); + XContentParser parser = createParser( + JsonXContent.jsonXContent, + "{\"named\": {\"a\": {}}, \"named_in_constructor\": [ {\"b\": {}} ]}" + ); // Create our own parser for this test so we can disable support for the "ordered" mode specified by the array above @SuppressWarnings("unchecked") diff --git a/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java b/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java index 6002c6bd35076..a2c45eceb8d58 100644 --- a/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java +++ b/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java @@ -44,12 +44,10 @@ public class ObjectParserTests extends ESTestCase { public void testBasics() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\n" - + " \"test\" : \"foo\",\n" - + " \"test_number\" : 2,\n" - + " \"test_array\": [1,2,3,4]\n" - + "}"); + XContentParser parser = createParser( + JsonXContent.jsonXContent, + "{ \"test\" : \"foo\", \"test_number\" : 2, \"test_array\": [1,2,3,4] }" + ); class TestStruct { public String test; int testNumber; @@ -176,8 +174,10 @@ public URI parseURI(XContentParser parser) { } } } - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"url\" : { \"host\": \"http://foobar\", \"port\" : 80}, \"name\" : \"foobarbaz\"}"); + XContentParser parser = createParser( + JsonXContent.jsonXContent, + "{\"url\" : { \"host\": \"http://foobar\", \"port\" : 80}, \"name\" : \"foobarbaz\"}" + ); ObjectParser objectParser = new ObjectParser<>("foo"); objectParser.declareString(Foo::setName, new ParseField("name")); objectParser.declareObjectOrDefault(Foo::setURI, (p, s) -> s.parseURI(p), () -> null, new ParseField("url")); @@ -449,10 +449,7 @@ public void setString_or_null(String string_or_null) { } public void testParseNamedObject() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"named\": {\n" - + " \"a\": {}" - + "}}"); + XContentParser parser = createParser(JsonXContent.jsonXContent, "{\"named\": { \"a\": {} }}"); NamedObjectHolder h = NamedObjectHolder.PARSER.apply(parser, null); assertThat(h.named, hasSize(1)); assertEquals("a", h.named.get(0).name); @@ -460,10 +457,7 @@ public void testParseNamedObject() throws IOException { } public void testParseNamedObjectInOrder() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"named\": [\n" - + " {\"a\": {}}" - + "]}"); + XContentParser parser = createParser(JsonXContent.jsonXContent, "{\"named\": [ {\"a\": {}} ] }"); NamedObjectHolder h = NamedObjectHolder.PARSER.apply(parser, null); assertThat(h.named, hasSize(1)); assertEquals("a", h.named.get(0).name); @@ -471,10 +465,7 @@ public void testParseNamedObjectInOrder() throws IOException { } public void testParseNamedObjectTwoFieldsInArray() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"named\": [\n" - + " {\"a\": {}, \"b\": {}}" - + "]}"); + XContentParser parser = createParser(JsonXContent.jsonXContent, "{\"named\": [ {\"a\": {}, \"b\": {}}]}"); XContentParseException e = expectThrows(XContentParseException.class, () -> NamedObjectHolder.PARSER.apply(parser, null)); assertThat(e.getMessage(), containsString("[named_object_holder] failed to parse field [named]")); assertThat(e.getCause().getMessage(), @@ -483,10 +474,7 @@ public void testParseNamedObjectTwoFieldsInArray() throws IOException { } public void testParseNamedObjectNoFieldsInArray() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"named\": [\n" - + " {}" - + "]}"); + XContentParser parser = createParser(JsonXContent.jsonXContent, "{\"named\": [ {} ]}"); XContentParseException e = expectThrows(XContentParseException.class, () -> NamedObjectHolder.PARSER.apply(parser, null)); assertThat(e.getMessage(), containsString("[named_object_holder] failed to parse field [named]")); assertThat(e.getCause().getMessage(), @@ -495,10 +483,7 @@ public void testParseNamedObjectNoFieldsInArray() throws IOException { } public void testParseNamedObjectJunkInArray() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"named\": [\n" - + " \"junk\"" - + "]}"); + XContentParser parser = createParser(JsonXContent.jsonXContent, "{\"named\": [ \"junk\" ] }"); XContentParseException e = expectThrows(XContentParseException.class, () -> NamedObjectHolder.PARSER.apply(parser, null)); assertThat(e.getMessage(), containsString("[named_object_holder] failed to parse field [named]")); assertThat(e.getCause().getMessage(), @@ -507,10 +492,7 @@ public void testParseNamedObjectJunkInArray() throws IOException { } public void testParseNamedObjectInOrderNotSupported() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\"named\": [\n" - + " {\"a\": {}}" - + "]}"); + XContentParser parser = createParser(JsonXContent.jsonXContent, "{\"named\": [ {\"a\": {}} ] }"); // Create our own parser for this test so we can disable support for the "ordered" mode specified by the array above ObjectParser objectParser = new ObjectParser<>("named_object_holder", @@ -601,11 +583,10 @@ class TestStruct { } public void testArraysOfGenericValues() throws IOException { - XContentParser parser = createParser(JsonXContent.jsonXContent, - "{\n" - + " \"test_array\": [ 1, null, \"3\", 4.2],\n" - + " \"int_array\": [ 1, 2, 3]\n" - + "}"); + XContentParser parser = createParser( + JsonXContent.jsonXContent, + "{ \"test_array\": [ 1, null, \"3\", 4.2], \"int_array\": [ 1, 2, 3] }" + ); class TestStruct { List testArray = new ArrayList<>(); diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java index a655f42a36c26..07f20c1639b71 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java @@ -408,8 +408,8 @@ public List getPreConfiguredTokenFilters() { filters.add(PreConfiguredTokenFilter.singleton("indic_normalization", true, IndicNormalizationFilter::new)); filters.add(PreConfiguredTokenFilter.singleton("keyword_repeat", false, false, KeywordRepeatFilter::new)); filters.add(PreConfiguredTokenFilter.singleton("kstem", false, KStemFilter::new)); - filters.add(PreConfiguredTokenFilter.singleton("length", false, input -> - new LengthFilter(input, 0, Integer.MAX_VALUE))); // TODO this one seems useless + // TODO this one seems useless + filters.add(PreConfiguredTokenFilter.singleton("length", false, input -> new LengthFilter(input, 0, Integer.MAX_VALUE))); filters.add(PreConfiguredTokenFilter.singleton("limit", false, input -> new LimitTokenCountFilter(input, LimitTokenCountFilterFactory.DEFAULT_MAX_TOKEN_COUNT, From 7836ddd32853f82a97db55b988839d14b91c5794 Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Tue, 29 Oct 2019 10:42:37 +0100 Subject: [PATCH 06/12] Fix expectations in SearchAfter integration tests (#48372) This commit fixes the expectations of SearchAfterIT#shouldFail regarding the inner exceptions that should be thrown when testing failures. The exception is sometimes wrapped in a QueryShardException so this change only checks that the toString representation contains the expected message. Closes #43143 --- .../search/searchafter/SearchAfterIT.java | 113 +++++++----------- 1 file changed, 46 insertions(+), 67 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/search/searchafter/SearchAfterIT.java b/server/src/test/java/org/elasticsearch/search/searchafter/SearchAfterIT.java index c6e4b94069a43..c2c2efd755d17 100644 --- a/server/src/test/java/org/elasticsearch/search/searchafter/SearchAfterIT.java +++ b/server/src/test/java/org/elasticsearch/search/searchafter/SearchAfterIT.java @@ -27,7 +27,6 @@ import org.elasticsearch.action.search.ShardSearchFailure; import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.search.SearchException; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.test.ESIntegTestCase; @@ -38,11 +37,11 @@ import java.util.Comparator; import java.util.Collections; import java.util.Arrays; -import java.util.concurrent.ExecutionException; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; +import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; public class SearchAfterIT extends ESIntegTestCase { @@ -52,107 +51,87 @@ public class SearchAfterIT extends ESIntegTestCase { public void testsShouldFail() throws Exception { assertAcked(client().admin().indices().prepareCreate("test") - .addMapping("type1", "field2", "type=keyword").get()); + .addMapping("type1", "field2", "type=keyword") + .get() + ); ensureGreen(); indexRandom(true, client().prepareIndex("test").setId("0").setSource("field1", 0, "field2", "toto")); - try { - client().prepareSearch("test") - .addSort("field1", SortOrder.ASC) - .setQuery(matchAllQuery()) - .searchAfter(new Object[]{0}) - .setScroll("1m") - .get(); - - fail("Should fail on search_after cannot be used with scroll."); - } catch (SearchPhaseExecutionException e) { + { + SearchPhaseExecutionException e = expectThrows(SearchPhaseExecutionException.class, () -> client().prepareSearch("test") + .addSort("field1", SortOrder.ASC) + .setQuery(matchAllQuery()) + .searchAfter(new Object[]{0}) + .setScroll("1m") + .get()); assertTrue(e.shardFailures().length > 0); for (ShardSearchFailure failure : e.shardFailures()) { - assertThat(failure.getCause().getClass(), Matchers.equalTo(SearchException.class)); - assertThat(failure.getCause().getMessage(), Matchers.equalTo("`search_after` cannot be used in a scroll context.")); + assertThat(failure.toString(), containsString("`search_after` cannot be used in a scroll context.")); } } - try { - client().prepareSearch("test") + + { + SearchPhaseExecutionException e = expectThrows(SearchPhaseExecutionException.class, () -> client().prepareSearch("test") .addSort("field1", SortOrder.ASC) .setQuery(matchAllQuery()) .searchAfter(new Object[]{0}) .setFrom(10) - .get(); - - fail("Should fail on search_after cannot be used with from > 0."); - } catch (SearchPhaseExecutionException e) { + .get()); assertTrue(e.shardFailures().length > 0); for (ShardSearchFailure failure : e.shardFailures()) { - assertThat(failure.getCause().getClass(), Matchers.equalTo(SearchException.class)); - assertThat(failure.getCause().getMessage(), - Matchers.equalTo("`from` parameter must be set to 0 when `search_after` is used.")); + assertThat(failure.toString(), containsString("`from` parameter must be set to 0 when `search_after` is used.")); } } - try { - client().prepareSearch("test") - .setQuery(matchAllQuery()) - .searchAfter(new Object[]{0.75f}) - .get(); - - fail("Should fail on search_after on score only is disabled"); - } catch (SearchPhaseExecutionException e) { + { + SearchPhaseExecutionException e = expectThrows(SearchPhaseExecutionException.class, () -> client().prepareSearch("test") + .setQuery(matchAllQuery()) + .searchAfter(new Object[]{0.75f}) + .get()); assertTrue(e.shardFailures().length > 0); for (ShardSearchFailure failure : e.shardFailures()) { - assertThat(failure.getCause().getClass(), Matchers.equalTo(IllegalArgumentException.class)); - assertThat(failure.getCause().getMessage(), Matchers.equalTo("Sort must contain at least one field.")); + assertThat(failure.toString(), containsString("Sort must contain at least one field.")); } } - try { - client().prepareSearch("test") - .addSort("field2", SortOrder.DESC) - .addSort("field1", SortOrder.ASC) - .setQuery(matchAllQuery()) - .searchAfter(new Object[]{1}) - .get(); - fail("Should fail on search_after size differs from sort field size"); - } catch (SearchPhaseExecutionException e) { + { + SearchPhaseExecutionException e = expectThrows(SearchPhaseExecutionException.class, () -> client().prepareSearch("test") + .addSort("field2", SortOrder.DESC) + .addSort("field1", SortOrder.ASC) + .setQuery(matchAllQuery()) + .searchAfter(new Object[]{1}) + .get()); assertTrue(e.shardFailures().length > 0); for (ShardSearchFailure failure : e.shardFailures()) { - assertThat(failure.getCause().getClass(), Matchers.equalTo(IllegalArgumentException.class)); - assertThat(failure.getCause().getMessage(), Matchers.equalTo("search_after has 1 value(s) but sort has 2.")); + assertThat(failure.toString(), containsString("search_after has 1 value(s) but sort has 2.")); } } - try { - client().prepareSearch("test") - .setQuery(matchAllQuery()) - .addSort("field1", SortOrder.ASC) - .searchAfter(new Object[]{1, 2}) - .get(); - fail("Should fail on search_after size differs from sort field size"); - } catch (SearchPhaseExecutionException e) { + { + SearchPhaseExecutionException e = expectThrows(SearchPhaseExecutionException.class, () -> client().prepareSearch("test") + .setQuery(matchAllQuery()) + .addSort("field1", SortOrder.ASC) + .searchAfter(new Object[]{1, 2}) + .get()); for (ShardSearchFailure failure : e.shardFailures()) { assertTrue(e.shardFailures().length > 0); - assertThat(failure.getCause().getClass(), Matchers.equalTo(IllegalArgumentException.class)); - assertThat(failure.getCause().getMessage(), Matchers.equalTo("search_after has 2 value(s) but sort has 1.")); + assertThat(failure.toString(), containsString("search_after has 2 value(s) but sort has 1.")); } } - try { - client().prepareSearch("test") - .setQuery(matchAllQuery()) - .addSort("field1", SortOrder.ASC) - .searchAfter(new Object[]{"toto"}) - .get(); - - fail("Should fail on search_after on score only is disabled"); - } catch (SearchPhaseExecutionException e) { + { + SearchPhaseExecutionException e = expectThrows(SearchPhaseExecutionException.class, () -> client().prepareSearch("test") + .setQuery(matchAllQuery()) + .addSort("field1", SortOrder.ASC) + .searchAfter(new Object[]{"toto"}) + .get()); assertTrue(e.shardFailures().length > 0); for (ShardSearchFailure failure : e.shardFailures()) { - assertThat(failure.getCause().getClass(), Matchers.equalTo(IllegalArgumentException.class)); - assertThat(failure.getCause().getMessage(), Matchers.equalTo("Failed to parse search_after value for field [field1].")); + assertThat(failure.toString(), containsString("Failed to parse search_after value for field [field1].")); } } } - public void testWithNullStrings() throws ExecutionException, InterruptedException { + public void testWithNullStrings() throws InterruptedException { assertAcked(client().admin().indices().prepareCreate("test") .addMapping("type1", "field2", "type=keyword").get()); ensureGreen(); From 35144859912e3fa4a4ae3d0a44b6c6f7a7477123 Mon Sep 17 00:00:00 2001 From: Mayya Sharipova Date: Tue, 29 Oct 2019 05:44:29 -0400 Subject: [PATCH 07/12] Upgrade lucene to 8.4.0-snapshot-e648d601efb (#48607) --- buildSrc/version.properties | 2 +- docs/Versions.asciidoc | 4 ++-- ...essions-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...essions-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...ers-icu-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...ers-icu-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...uromoji-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...uromoji-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...rs-nori-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...rs-nori-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...honetic-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...honetic-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...smartcn-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...smartcn-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...stempel-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...stempel-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...fologik-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...fologik-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...-common-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...-common-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...-codecs-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...-codecs-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...ne-core-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...ne-core-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...rouping-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...rouping-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...lighter-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...lighter-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...ne-join-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...ne-join-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...-memory-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...-memory-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...ne-misc-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...ne-misc-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...queries-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...queries-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...yparser-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...yparser-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...sandbox-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...sandbox-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...spatial-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...spatial-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...-extras-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...-extras-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...atial3d-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...atial3d-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + ...suggest-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...suggest-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + .../main/java/org/elasticsearch/Version.java | 2 +- .../admin/indices/stats/IndicesStatsTests.java | 18 +++++++++++++++--- ...ne-core-8.3.0-snapshot-25968e3b75e.jar.sha1 | 1 - ...ne-core-8.4.0-snapshot-e648d601efb.jar.sha1 | 1 + 52 files changed, 43 insertions(+), 31 deletions(-) delete mode 100644 modules/lang-expression/licenses/lucene-expressions-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 modules/lang-expression/licenses/lucene-expressions-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 plugins/analysis-icu/licenses/lucene-analyzers-icu-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 plugins/analysis-icu/licenses/lucene-analyzers-icu-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 plugins/analysis-nori/licenses/lucene-analyzers-nori-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 plugins/analysis-nori/licenses/lucene-analyzers-nori-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 server/licenses/lucene-analyzers-common-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 server/licenses/lucene-analyzers-common-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 server/licenses/lucene-backward-codecs-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 server/licenses/lucene-backward-codecs-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 server/licenses/lucene-core-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 server/licenses/lucene-core-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 server/licenses/lucene-grouping-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 server/licenses/lucene-grouping-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 server/licenses/lucene-highlighter-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 server/licenses/lucene-highlighter-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 server/licenses/lucene-join-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 server/licenses/lucene-join-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 server/licenses/lucene-memory-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 server/licenses/lucene-memory-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 server/licenses/lucene-misc-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 server/licenses/lucene-misc-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 server/licenses/lucene-queries-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 server/licenses/lucene-queries-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 server/licenses/lucene-queryparser-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 server/licenses/lucene-queryparser-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 server/licenses/lucene-sandbox-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 server/licenses/lucene-sandbox-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 server/licenses/lucene-spatial-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 server/licenses/lucene-spatial-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 server/licenses/lucene-spatial-extras-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 server/licenses/lucene-spatial-extras-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 server/licenses/lucene-spatial3d-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 server/licenses/lucene-spatial3d-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 server/licenses/lucene-suggest-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 server/licenses/lucene-suggest-8.4.0-snapshot-e648d601efb.jar.sha1 delete mode 100644 x-pack/plugin/sql/sql-action/licenses/lucene-core-8.3.0-snapshot-25968e3b75e.jar.sha1 create mode 100644 x-pack/plugin/sql/sql-action/licenses/lucene-core-8.4.0-snapshot-e648d601efb.jar.sha1 diff --git a/buildSrc/version.properties b/buildSrc/version.properties index a54da2bc93289..714232facc5ea 100644 --- a/buildSrc/version.properties +++ b/buildSrc/version.properties @@ -1,5 +1,5 @@ elasticsearch = 8.0.0 -lucene = 8.3.0-snapshot-25968e3b75e +lucene = 8.4.0-snapshot-e648d601efb bundled_jdk_vendor = adoptopenjdk bundled_jdk = 13.0.1+9 diff --git a/docs/Versions.asciidoc b/docs/Versions.asciidoc index 5fe417a38e97f..d103f4c09b268 100644 --- a/docs/Versions.asciidoc +++ b/docs/Versions.asciidoc @@ -1,8 +1,8 @@ include::{asciidoc-dir}/../../shared/versions/stack/{source_branch}.asciidoc[] -:lucene_version: 8.3.0 -:lucene_version_path: 8_3_0 +:lucene_version: 8.4.0 +:lucene_version_path: 8_4_0 :jdk: 11.0.2 :jdk_major: 11 :build_flavor: default diff --git a/modules/lang-expression/licenses/lucene-expressions-8.3.0-snapshot-25968e3b75e.jar.sha1 b/modules/lang-expression/licenses/lucene-expressions-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index ae94a3f34bd2f..0000000000000 --- a/modules/lang-expression/licenses/lucene-expressions-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -738a12e76b5c60f2a714fc3e6611c8ae6dc63159 \ No newline at end of file diff --git a/modules/lang-expression/licenses/lucene-expressions-8.4.0-snapshot-e648d601efb.jar.sha1 b/modules/lang-expression/licenses/lucene-expressions-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..7a75661f63f65 --- /dev/null +++ b/modules/lang-expression/licenses/lucene-expressions-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +43b9178f582373f4fcee61837404c0cc8636043e \ No newline at end of file diff --git a/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.3.0-snapshot-25968e3b75e.jar.sha1 b/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index 1e1113301af7d..0000000000000 --- a/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -6313d19a4f40d54ad12e20a66666049f88bac0ff \ No newline at end of file diff --git a/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.4.0-snapshot-e648d601efb.jar.sha1 b/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..2765cfafb0520 --- /dev/null +++ b/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +8ee342fa6e6306e56b583251639a661250fada46 \ No newline at end of file diff --git a/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.3.0-snapshot-25968e3b75e.jar.sha1 b/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index 8236b15fde19f..0000000000000 --- a/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -a28b8590a4f9ae219241a34382a39fe2f205f2e2 \ No newline at end of file diff --git a/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.4.0-snapshot-e648d601efb.jar.sha1 b/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..f653bf5c3b5dc --- /dev/null +++ b/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +7e31f2a38d1434eb50781efc65b0e028f08d7821 \ No newline at end of file diff --git a/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.3.0-snapshot-25968e3b75e.jar.sha1 b/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index 4864ae98d0923..0000000000000 --- a/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -c088334a34e477b122d8fa8623fb3b8f6a0a46e4 \ No newline at end of file diff --git a/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.4.0-snapshot-e648d601efb.jar.sha1 b/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..2c3ee0313a9c7 --- /dev/null +++ b/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +9079d81a8ea2c7190ef09ca06a987d1cab2fdf17 \ No newline at end of file diff --git a/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.3.0-snapshot-25968e3b75e.jar.sha1 b/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index 3554da79760e4..0000000000000 --- a/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -c36d794f4f1758e6e7fab457c3a6d41b45690484 \ No newline at end of file diff --git a/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.4.0-snapshot-e648d601efb.jar.sha1 b/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..5de2626b6ad2e --- /dev/null +++ b/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +f253f59d4e8bb6e55eb307b011ddb81ba0ebab92 \ No newline at end of file diff --git a/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.3.0-snapshot-25968e3b75e.jar.sha1 b/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index 9264c024639a5..0000000000000 --- a/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -8707a4fae440930f198a05083435466b605aa42f \ No newline at end of file diff --git a/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.4.0-snapshot-e648d601efb.jar.sha1 b/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..fcb579806bfeb --- /dev/null +++ b/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +36547378493e6e84f63dc744df8d414cb2add1a4 \ No newline at end of file diff --git a/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.3.0-snapshot-25968e3b75e.jar.sha1 b/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index 66ee8dd6f6359..0000000000000 --- a/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -49f9c34735dfc9bfc182ca56a7271350d1944040 \ No newline at end of file diff --git a/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.4.0-snapshot-e648d601efb.jar.sha1 b/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..d26f99ab24e7b --- /dev/null +++ b/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +8b15a376efa7d4289b697144f34a819a9f8772f1 \ No newline at end of file diff --git a/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.3.0-snapshot-25968e3b75e.jar.sha1 b/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index dc8902e6d150b..0000000000000 --- a/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -f1e4bb9faba619705f0b5753db65ce51f2156712 \ No newline at end of file diff --git a/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.4.0-snapshot-e648d601efb.jar.sha1 b/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..43a7650c70d7a --- /dev/null +++ b/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +d1bc4170e6981ca9af71d7a4ce46a3feb2f7b613 \ No newline at end of file diff --git a/server/licenses/lucene-analyzers-common-8.3.0-snapshot-25968e3b75e.jar.sha1 b/server/licenses/lucene-analyzers-common-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index c69a768b51344..0000000000000 --- a/server/licenses/lucene-analyzers-common-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -9ceeaa74e15fd21435331bd5be3176f61972cdc2 \ No newline at end of file diff --git a/server/licenses/lucene-analyzers-common-8.4.0-snapshot-e648d601efb.jar.sha1 b/server/licenses/lucene-analyzers-common-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..c2ec1128c1741 --- /dev/null +++ b/server/licenses/lucene-analyzers-common-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +1cb225781b19e758d216987e363b77fa4b041174 \ No newline at end of file diff --git a/server/licenses/lucene-backward-codecs-8.3.0-snapshot-25968e3b75e.jar.sha1 b/server/licenses/lucene-backward-codecs-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index 738b3cdf9751e..0000000000000 --- a/server/licenses/lucene-backward-codecs-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -43eaefd258e3cc9b1261679f18421d264d8f40a1 \ No newline at end of file diff --git a/server/licenses/lucene-backward-codecs-8.4.0-snapshot-e648d601efb.jar.sha1 b/server/licenses/lucene-backward-codecs-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..b6486fb3eeba7 --- /dev/null +++ b/server/licenses/lucene-backward-codecs-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +cbbf849e24ef0cc61312579acf6d6c5b72c99cf5 \ No newline at end of file diff --git a/server/licenses/lucene-core-8.3.0-snapshot-25968e3b75e.jar.sha1 b/server/licenses/lucene-core-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index ec00b55a480a3..0000000000000 --- a/server/licenses/lucene-core-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -d84d93bf46fb105864fa5d54c08fd63ca2650d56 \ No newline at end of file diff --git a/server/licenses/lucene-core-8.4.0-snapshot-e648d601efb.jar.sha1 b/server/licenses/lucene-core-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..4b736046f3ade --- /dev/null +++ b/server/licenses/lucene-core-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +aa74590851b6fcf536976f75448be52f6ca18a4a \ No newline at end of file diff --git a/server/licenses/lucene-grouping-8.3.0-snapshot-25968e3b75e.jar.sha1 b/server/licenses/lucene-grouping-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index 7981a4a98fd47..0000000000000 --- a/server/licenses/lucene-grouping-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -aa4a4b7b27591003e290a2eb02b61cfc52147b4c \ No newline at end of file diff --git a/server/licenses/lucene-grouping-8.4.0-snapshot-e648d601efb.jar.sha1 b/server/licenses/lucene-grouping-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..97a3c7b927b87 --- /dev/null +++ b/server/licenses/lucene-grouping-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +1bd113010c183168d79fbc10a6b590fdacc3fa35 \ No newline at end of file diff --git a/server/licenses/lucene-highlighter-8.3.0-snapshot-25968e3b75e.jar.sha1 b/server/licenses/lucene-highlighter-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index 731960a90ab70..0000000000000 --- a/server/licenses/lucene-highlighter-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -7a4f796d2f8617d805f9f84623e7497085dda0d4 \ No newline at end of file diff --git a/server/licenses/lucene-highlighter-8.4.0-snapshot-e648d601efb.jar.sha1 b/server/licenses/lucene-highlighter-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..f2dd654d8d64c --- /dev/null +++ b/server/licenses/lucene-highlighter-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +4e44a435e14d12113ca9193182a302677fda155e \ No newline at end of file diff --git a/server/licenses/lucene-join-8.3.0-snapshot-25968e3b75e.jar.sha1 b/server/licenses/lucene-join-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index ba001c04bb4ab..0000000000000 --- a/server/licenses/lucene-join-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -ffd05f24dd7749b08809dfc2ad3a93c0845c5f84 \ No newline at end of file diff --git a/server/licenses/lucene-join-8.4.0-snapshot-e648d601efb.jar.sha1 b/server/licenses/lucene-join-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..9e8d72cc13fcf --- /dev/null +++ b/server/licenses/lucene-join-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +eb8eacd015ef81ef2055ada357a92c9751308ef1 \ No newline at end of file diff --git a/server/licenses/lucene-memory-8.3.0-snapshot-25968e3b75e.jar.sha1 b/server/licenses/lucene-memory-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index 0f9204010e39c..0000000000000 --- a/server/licenses/lucene-memory-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -fb576d36ebf966c48fb58765c6bd7b6e5320cbd6 \ No newline at end of file diff --git a/server/licenses/lucene-memory-8.4.0-snapshot-e648d601efb.jar.sha1 b/server/licenses/lucene-memory-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..e6048ffd91225 --- /dev/null +++ b/server/licenses/lucene-memory-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +4dc565203bb1eab0222c52215891e207e7032209 \ No newline at end of file diff --git a/server/licenses/lucene-misc-8.3.0-snapshot-25968e3b75e.jar.sha1 b/server/licenses/lucene-misc-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index 5a3b6719e4adc..0000000000000 --- a/server/licenses/lucene-misc-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -b052ad9ac2ad9d81d1b80e48ec47985644d36f3f \ No newline at end of file diff --git a/server/licenses/lucene-misc-8.4.0-snapshot-e648d601efb.jar.sha1 b/server/licenses/lucene-misc-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..480dcc632907f --- /dev/null +++ b/server/licenses/lucene-misc-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +ef596e6d2a7ac9c7dfc6196dad75dc719c81ce85 \ No newline at end of file diff --git a/server/licenses/lucene-queries-8.3.0-snapshot-25968e3b75e.jar.sha1 b/server/licenses/lucene-queries-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index 1ae72bdc1fc68..0000000000000 --- a/server/licenses/lucene-queries-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -8edf59c2cd920a1cd926573620b8b0f82fe03f2a \ No newline at end of file diff --git a/server/licenses/lucene-queries-8.4.0-snapshot-e648d601efb.jar.sha1 b/server/licenses/lucene-queries-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..2524672e062b1 --- /dev/null +++ b/server/licenses/lucene-queries-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +b0c963e68dd71444f09336258c8f63425514426a \ No newline at end of file diff --git a/server/licenses/lucene-queryparser-8.3.0-snapshot-25968e3b75e.jar.sha1 b/server/licenses/lucene-queryparser-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index 911dd7ed37b7b..0000000000000 --- a/server/licenses/lucene-queryparser-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -d070d33ddf37bf45a0656dec980a69ac930c8218 \ No newline at end of file diff --git a/server/licenses/lucene-queryparser-8.4.0-snapshot-e648d601efb.jar.sha1 b/server/licenses/lucene-queryparser-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..4ab7a7fe6f644 --- /dev/null +++ b/server/licenses/lucene-queryparser-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +bfab3e9b0467662a8ff969da215dc4a999b73076 \ No newline at end of file diff --git a/server/licenses/lucene-sandbox-8.3.0-snapshot-25968e3b75e.jar.sha1 b/server/licenses/lucene-sandbox-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index 06bcd6e821d64..0000000000000 --- a/server/licenses/lucene-sandbox-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -5ea387ae19df210c5b6e75eb38bf589dc39e54f4 \ No newline at end of file diff --git a/server/licenses/lucene-sandbox-8.4.0-snapshot-e648d601efb.jar.sha1 b/server/licenses/lucene-sandbox-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..9361e9252f212 --- /dev/null +++ b/server/licenses/lucene-sandbox-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +dadfc90e4cd032f8a4db5cc1e0bdddecea635edb \ No newline at end of file diff --git a/server/licenses/lucene-spatial-8.3.0-snapshot-25968e3b75e.jar.sha1 b/server/licenses/lucene-spatial-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index b764a6f6488b8..0000000000000 --- a/server/licenses/lucene-spatial-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -395ddd7e7774ad9027269222d746d30651ab8cf3 \ No newline at end of file diff --git a/server/licenses/lucene-spatial-8.4.0-snapshot-e648d601efb.jar.sha1 b/server/licenses/lucene-spatial-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..ce5a13ec8d6be --- /dev/null +++ b/server/licenses/lucene-spatial-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +e72dd79d30781e4d05bc8397ae61d0b51d7ad522 \ No newline at end of file diff --git a/server/licenses/lucene-spatial-extras-8.3.0-snapshot-25968e3b75e.jar.sha1 b/server/licenses/lucene-spatial-extras-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index 0c2d20e82248b..0000000000000 --- a/server/licenses/lucene-spatial-extras-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -85da517bdc0b200b040c0293eea0ff6f36082e31 \ No newline at end of file diff --git a/server/licenses/lucene-spatial-extras-8.4.0-snapshot-e648d601efb.jar.sha1 b/server/licenses/lucene-spatial-extras-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..4530b17e84e25 --- /dev/null +++ b/server/licenses/lucene-spatial-extras-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +e6b6dbd0526287f25d98d7fe354d5e290c875b8a \ No newline at end of file diff --git a/server/licenses/lucene-spatial3d-8.3.0-snapshot-25968e3b75e.jar.sha1 b/server/licenses/lucene-spatial3d-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index bdbba1f81f900..0000000000000 --- a/server/licenses/lucene-spatial3d-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -ccf4b384c0051d9bd1df73a0a5f62c7064039db6 \ No newline at end of file diff --git a/server/licenses/lucene-spatial3d-8.4.0-snapshot-e648d601efb.jar.sha1 b/server/licenses/lucene-spatial3d-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..a96977cf1340f --- /dev/null +++ b/server/licenses/lucene-spatial3d-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +6351edfc6dde2aefd8f6d8ef33ae5a6e08f88321 \ No newline at end of file diff --git a/server/licenses/lucene-suggest-8.3.0-snapshot-25968e3b75e.jar.sha1 b/server/licenses/lucene-suggest-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index 6e26830f99fc4..0000000000000 --- a/server/licenses/lucene-suggest-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -9bf83a2a79cf6c392961c06b3afaa3d3871274da \ No newline at end of file diff --git a/server/licenses/lucene-suggest-8.4.0-snapshot-e648d601efb.jar.sha1 b/server/licenses/lucene-suggest-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..090cf9ee734ca --- /dev/null +++ b/server/licenses/lucene-suggest-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +921dd4ab493b9d70a0b1bf7b0fe8a6790b7e8036 \ No newline at end of file diff --git a/server/src/main/java/org/elasticsearch/Version.java b/server/src/main/java/org/elasticsearch/Version.java index fe0378c1ea2ef..efcaf39ebc2ed 100644 --- a/server/src/main/java/org/elasticsearch/Version.java +++ b/server/src/main/java/org/elasticsearch/Version.java @@ -71,7 +71,7 @@ public class Version implements Comparable, ToXContentFragment { public static final Version V_7_4_2 = new Version(7040299, org.apache.lucene.util.Version.LUCENE_8_2_0); public static final Version V_7_5_0 = new Version(7050099, org.apache.lucene.util.Version.LUCENE_8_2_0); public static final Version V_7_6_0 = new Version(7060099, org.apache.lucene.util.Version.LUCENE_8_3_0); - public static final Version V_8_0_0 = new Version(8000099, org.apache.lucene.util.Version.LUCENE_8_3_0); + public static final Version V_8_0_0 = new Version(8000099, org.apache.lucene.util.Version.LUCENE_8_4_0); public static final Version CURRENT = V_8_0_0; private static final ImmutableOpenIntMap idToVersion; diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsTests.java index fc983673b013f..5603b573dd4fd 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsTests.java @@ -27,6 +27,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.index.IndexModule; import org.elasticsearch.index.engine.CommitStats; import org.elasticsearch.index.engine.SegmentsStats; import org.elasticsearch.index.translog.Translog; @@ -55,6 +56,7 @@ public void testSegmentStatsEmptyIndex() { } public void testSegmentStats() throws Exception { + IndexModule.Type storeType = IndexModule.defaultStoreType(true); XContentBuilder mapping = XContentFactory.jsonBuilder() .startObject() .startObject("doc") @@ -74,7 +76,8 @@ public void testSegmentStats() throws Exception { .endObject() .endObject() .endObject(); - assertAcked(client().admin().indices().prepareCreate("test").addMapping("doc", mapping)); + assertAcked(client().admin().indices().prepareCreate("test").addMapping("doc", mapping) + .setSettings(Settings.builder().put("index.store.type", storeType.getSettingsKey()))); ensureGreen("test"); client().prepareIndex("test").setId("1").setSource("foo", "bar", "bar", "baz", "baz", 42).get(); client().admin().indices().prepareRefresh("test").get(); @@ -85,8 +88,12 @@ public void testSegmentStats() throws Exception { assertThat(stats.getStoredFieldsMemoryInBytes(), greaterThan(0L)); assertThat(stats.getTermVectorsMemoryInBytes(), greaterThan(0L)); assertThat(stats.getNormsMemoryInBytes(), greaterThan(0L)); - assertThat(stats.getPointsMemoryInBytes(), greaterThan(0L)); assertThat(stats.getDocValuesMemoryInBytes(), greaterThan(0L)); + if ((storeType == IndexModule.Type.MMAPFS) || (storeType == IndexModule.Type.HYBRIDFS)) { + assertEquals(0, stats.getPointsMemoryInBytes()); // bkd tree is stored off-heap + } else { + assertThat(stats.getPointsMemoryInBytes(), greaterThan(0L)); // bkd tree is stored on heap + } // now check multiple segments stats are merged together client().prepareIndex("test").setId("2").setSource("foo", "bar", "bar", "baz", "baz", 43).get(); @@ -98,8 +105,13 @@ public void testSegmentStats() throws Exception { assertThat(stats2.getStoredFieldsMemoryInBytes(), greaterThan(stats.getStoredFieldsMemoryInBytes())); assertThat(stats2.getTermVectorsMemoryInBytes(), greaterThan(stats.getTermVectorsMemoryInBytes())); assertThat(stats2.getNormsMemoryInBytes(), greaterThan(stats.getNormsMemoryInBytes())); - assertThat(stats2.getPointsMemoryInBytes(), greaterThan(stats.getPointsMemoryInBytes())); + assertThat(stats2.getDocValuesMemoryInBytes(), greaterThan(stats.getDocValuesMemoryInBytes())); + if ((storeType == IndexModule.Type.MMAPFS) || (storeType == IndexModule.Type.HYBRIDFS)) { + assertEquals(0, stats2.getPointsMemoryInBytes()); // bkd tree is stored off-heap + } else { + assertThat(stats2.getPointsMemoryInBytes(), greaterThan(stats.getPointsMemoryInBytes())); // bkd tree is stored on heap + } } public void testCommitStats() throws Exception { diff --git a/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.3.0-snapshot-25968e3b75e.jar.sha1 b/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.3.0-snapshot-25968e3b75e.jar.sha1 deleted file mode 100644 index ec00b55a480a3..0000000000000 --- a/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.3.0-snapshot-25968e3b75e.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -d84d93bf46fb105864fa5d54c08fd63ca2650d56 \ No newline at end of file diff --git a/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.4.0-snapshot-e648d601efb.jar.sha1 b/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.4.0-snapshot-e648d601efb.jar.sha1 new file mode 100644 index 0000000000000..4b736046f3ade --- /dev/null +++ b/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.4.0-snapshot-e648d601efb.jar.sha1 @@ -0,0 +1 @@ +aa74590851b6fcf536976f75448be52f6ca18a4a \ No newline at end of file From 87bf0bce5f38dbf21c2970f57e4dbfb8d1654b79 Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Tue, 29 Oct 2019 10:49:11 +0000 Subject: [PATCH 08/12] MappingMetaData routing can be a simple boolean (#48281) MappingMetaData contains a Routing class, which ultimately delegates down to a simple boolean (does this mapping require a routing key or not). At some point in the past this may have been necessary to distinguish between unconfigured and configured states, but this is no longer required and so the class can be removed. --- .../action/index/IndexRequest.java | 2 +- .../cluster/metadata/MappingMetaData.java | 63 +++++-------------- .../cluster/metadata/MetaData.java | 2 +- .../gateway/GatewayIndexStateIT.java | 9 ++- 4 files changed, 20 insertions(+), 56 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java index c4289edd58f7a..87866de8ab3eb 100644 --- a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -543,7 +543,7 @@ public VersionType versionType() { public void process(Version indexCreatedVersion, @Nullable MappingMetaData mappingMd, String concreteIndex) { if (mappingMd != null) { // might as well check for routing here - if (mappingMd.routing().required() && routing == null) { + if (mappingMd.routingRequired() && routing == null) { throw new RoutingMissingException(concreteIndex, id); } } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java index 6d62f220af824..eba28e66db32c 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java @@ -35,6 +35,7 @@ import java.io.UncheckedIOException; import java.util.Collections; import java.util.Map; +import java.util.Objects; import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeBooleanValue; @@ -45,46 +46,16 @@ public class MappingMetaData extends AbstractDiffable { public static final MappingMetaData EMPTY_MAPPINGS = new MappingMetaData("_doc", Collections.emptyMap()); - public static class Routing { - - public static final Routing EMPTY = new Routing(false); - - private final boolean required; - - public Routing(boolean required) { - this.required = required; - } - - public boolean required() { - return required; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Routing routing = (Routing) o; - - return required == routing.required; - } - - @Override - public int hashCode() { - return getClass().hashCode() + (required ? 1 : 0); - } - } - private final String type; private final CompressedXContent source; - private final Routing routing; + private final boolean routingRequired; public MappingMetaData(DocumentMapper docMapper) { this.type = docMapper.type(); this.source = docMapper.mappingSource(); - this.routing = new Routing(docMapper.routingFieldMapper().required()); + this.routingRequired = docMapper.routingFieldMapper().required(); } @SuppressWarnings("unchecked") @@ -95,7 +66,7 @@ public MappingMetaData(CompressedXContent mapping) { throw new IllegalStateException("Can't derive type from mapping, no root type: " + mapping.string()); } this.type = mappingMap.keySet().iterator().next(); - this.routing = initRouting((Map) mappingMap.get(this.type)); + this.routingRequired = routingRequired((Map) mappingMap.get(this.type)); } @SuppressWarnings("unchecked") @@ -112,13 +83,13 @@ public MappingMetaData(String type, Map mapping) { if (mapping.size() == 1 && mapping.containsKey(type)) { withoutType = (Map) mapping.get(type); } - this.routing = initRouting(withoutType); + this.routingRequired = routingRequired(withoutType); } @SuppressWarnings("unchecked") - private Routing initRouting(Map withoutType) { + private boolean routingRequired(Map withoutType) { + boolean required = false; if (withoutType.containsKey("_routing")) { - boolean required = false; Map routingNode = (Map) withoutType.get("_routing"); for (Map.Entry entry : routingNode.entrySet()) { String fieldName = entry.getKey(); @@ -132,10 +103,8 @@ private Routing initRouting(Map withoutType) { } } } - return new Routing(required); - } else { - return Routing.EMPTY; } + return required; } public String type() { @@ -165,8 +134,8 @@ public Map getSourceAsMap() throws ElasticsearchParseException { return sourceAsMap(); } - public Routing routing() { - return this.routing; + public boolean routingRequired() { + return this.routingRequired; } @Override @@ -174,7 +143,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(type()); source().writeTo(out); // routing - out.writeBoolean(routing().required()); + out.writeBoolean(routingRequired); } @Override @@ -184,7 +153,7 @@ public boolean equals(Object o) { MappingMetaData that = (MappingMetaData) o; - if (!routing.equals(that.routing)) return false; + if (!Objects.equals(this.routingRequired, that.routingRequired)) return false; if (!source.equals(that.source)) return false; if (!type.equals(that.type)) return false; @@ -193,17 +162,13 @@ public boolean equals(Object o) { @Override public int hashCode() { - int result = type.hashCode(); - result = 31 * result + source.hashCode(); - result = 31 * result + routing.hashCode(); - return result; + return Objects.hash(type, source, routingRequired); } public MappingMetaData(StreamInput in) throws IOException { type = in.readString(); source = CompressedXContent.readCompressedString(in); - // routing - routing = new Routing(in.readBoolean()); + routingRequired = in.readBoolean(); } public static Diff readDiffFrom(StreamInput in) throws IOException { diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java index 55e08d7a86b96..a6ad4e2d19cb7 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MetaData.java @@ -696,7 +696,7 @@ public boolean routingRequired(String concreteIndex) { if (indexMetaData != null) { MappingMetaData mappingMetaData = indexMetaData.mapping(); if (mappingMetaData != null) { - return mappingMetaData.routing().required(); + return mappingMetaData.routingRequired(); } } return false; diff --git a/server/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java b/server/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java index f38b2437b2f12..e9cbd912202a0 100644 --- a/server/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java +++ b/server/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java @@ -93,8 +93,8 @@ public void testMappingMetaDataParsed() throws Exception { logger.info("--> verify meta _routing required exists"); MappingMetaData mappingMd = client().admin().cluster().prepareState().execute().actionGet().getState().metaData() - .index("test").getMappings().get("type1"); - assertThat(mappingMd.routing().required(), equalTo(true)); + .index("test").mapping(); + assertThat(mappingMd.routingRequired(), equalTo(true)); logger.info("--> restarting nodes..."); internalCluster().fullRestart(); @@ -103,9 +103,8 @@ public void testMappingMetaDataParsed() throws Exception { ensureYellow(); logger.info("--> verify meta _routing required exists"); - mappingMd = client().admin().cluster().prepareState().execute().actionGet().getState().metaData().index("test").getMappings() - .get("type1"); - assertThat(mappingMd.routing().required(), equalTo(true)); + mappingMd = client().admin().cluster().prepareState().execute().actionGet().getState().metaData().index("test").mapping(); + assertThat(mappingMd.routingRequired(), equalTo(true)); } public void testSimpleOpenClose() throws Exception { From 84f4f39aafd0a43a8532954485acf0553d3c1af9 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Tue, 29 Oct 2019 12:09:59 +0100 Subject: [PATCH 09/12] Filter on node id in AllocationIdIT (#48623) Makes the assertions more targeted. Relates #48529 --- .../java/org/elasticsearch/cluster/routing/AllocationIdIT.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/AllocationIdIT.java b/server/src/test/java/org/elasticsearch/cluster/routing/AllocationIdIT.java index 4b0d28d4c99bd..09c9d814e8468 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/AllocationIdIT.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/AllocationIdIT.java @@ -208,8 +208,10 @@ private IndexSettings getIndexSettings(String indexName, String nodeName) { private String historyUUID(String node, String indexName) { final ShardStats[] shards = client(node).admin().indices().prepareStats(indexName).clear().get().getShards(); + final String nodeId = client(node).admin().cluster().prepareState().get().getState().nodes().resolveNode(node).getId(); assertThat(shards.length, greaterThan(0)); final Set historyUUIDs = Arrays.stream(shards) + .filter(shard -> shard.getShardRouting().currentNodeId().equals(nodeId)) .map(shard -> shard.getCommitStats().getUserData().get(Engine.HISTORY_UUID_KEY)) .collect(Collectors.toSet()); assertThat(historyUUIDs, hasSize(1)); From 4820361febedc8c24d55caa26612d382c905f0e0 Mon Sep 17 00:00:00 2001 From: Ioannis Kakavas Date: Tue, 29 Oct 2019 13:30:01 +0200 Subject: [PATCH 10/12] Update oauth2-oidc-sdk and nimbus-jose-jwt (#48537) Update two dependencies for our OpenID Connect realm implementation to their latest versions --- x-pack/plugin/security/build.gradle | 14 ++++++++++---- .../licenses/nimbus-jose-jwt-4.41.2.jar.sha1 | 1 - .../security/licenses/nimbus-jose-jwt-8.2.jar.sha1 | 1 + .../licenses/oauth2-oidc-sdk-6.16.5.jar.sha1 | 1 + .../security/licenses/oauth2-oidc-sdk-6.5.jar.sha1 | 1 - .../oidc/OpenIdConnectAuthenticatorTests.java | 11 ++++++----- 6 files changed, 18 insertions(+), 11 deletions(-) delete mode 100644 x-pack/plugin/security/licenses/nimbus-jose-jwt-4.41.2.jar.sha1 create mode 100644 x-pack/plugin/security/licenses/nimbus-jose-jwt-8.2.jar.sha1 create mode 100644 x-pack/plugin/security/licenses/oauth2-oidc-sdk-6.16.5.jar.sha1 delete mode 100644 x-pack/plugin/security/licenses/oauth2-oidc-sdk-6.5.jar.sha1 diff --git a/x-pack/plugin/security/build.gradle b/x-pack/plugin/security/build.gradle index 61512a5bee59f..ad51c2b12961f 100644 --- a/x-pack/plugin/security/build.gradle +++ b/x-pack/plugin/security/build.gradle @@ -56,8 +56,8 @@ dependencies { compile 'com.google.guava:guava:19.0' // Dependencies for oidc - compile "com.nimbusds:oauth2-oidc-sdk:6.5" - compile "com.nimbusds:nimbus-jose-jwt:4.41.2" + compile "com.nimbusds:oauth2-oidc-sdk:6.16.5" + compile "com.nimbusds:nimbus-jose-jwt:8.2" compile "com.nimbusds:lang-tag:1.4.4" compile "com.sun.mail:jakarta.mail:1.6.3" compile "net.jcip:jcip-annotations:1.0" @@ -82,7 +82,7 @@ dependencies { testCompile('org.apache.kerby:kerb-crypto:1.1.1') testCompile('org.apache.kerby:kerb-util:1.1.1') testCompile('org.apache.kerby:token-provider:1.1.1') - testCompile('com.nimbusds:nimbus-jose-jwt:4.41.2') + testCompile('com.nimbusds:nimbus-jose-jwt:8.2') testCompile('net.jcip:jcip-annotations:1.0') testCompile('org.apache.kerby:kerb-admin:1.1.1') testCompile('org.apache.kerby:kerb-server:1.1.1') @@ -270,7 +270,13 @@ thirdPartyAudit { // [missing classes] SLF4j includes an optional class that depends on an extension class (!) 'org.slf4j.ext.EventData', // Optional dependency of oauth2-oidc-sdk that we don't need since we do not support AES-SIV for JWE - 'org.cryptomator.siv.SivMode' + 'org.cryptomator.siv.SivMode', + // Optional dependency of nimbus-jose-jwt for handling Ed25519 signatures and ECDH with X25519 (RFC 8037) + 'com.google.crypto.tink.subtle.Ed25519Sign', + 'com.google.crypto.tink.subtle.Ed25519Sign$KeyPair', + 'com.google.crypto.tink.subtle.Ed25519Verify', + 'com.google.crypto.tink.subtle.X25519' + ) ignoreViolations ( diff --git a/x-pack/plugin/security/licenses/nimbus-jose-jwt-4.41.2.jar.sha1 b/x-pack/plugin/security/licenses/nimbus-jose-jwt-4.41.2.jar.sha1 deleted file mode 100644 index 7713379f35a6c..0000000000000 --- a/x-pack/plugin/security/licenses/nimbus-jose-jwt-4.41.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -3981d32ddfa2919a7af46eb5e484f8dc064da665 \ No newline at end of file diff --git a/x-pack/plugin/security/licenses/nimbus-jose-jwt-8.2.jar.sha1 b/x-pack/plugin/security/licenses/nimbus-jose-jwt-8.2.jar.sha1 new file mode 100644 index 0000000000000..e2d35d19dab1e --- /dev/null +++ b/x-pack/plugin/security/licenses/nimbus-jose-jwt-8.2.jar.sha1 @@ -0,0 +1 @@ +3cc99de85969253f2f085c39d87124e21011ae74 \ No newline at end of file diff --git a/x-pack/plugin/security/licenses/oauth2-oidc-sdk-6.16.5.jar.sha1 b/x-pack/plugin/security/licenses/oauth2-oidc-sdk-6.16.5.jar.sha1 new file mode 100644 index 0000000000000..bccf0afc4077d --- /dev/null +++ b/x-pack/plugin/security/licenses/oauth2-oidc-sdk-6.16.5.jar.sha1 @@ -0,0 +1 @@ +690bf0290fe0c03dabfb43566dbd334f78ddce84 \ No newline at end of file diff --git a/x-pack/plugin/security/licenses/oauth2-oidc-sdk-6.5.jar.sha1 b/x-pack/plugin/security/licenses/oauth2-oidc-sdk-6.5.jar.sha1 deleted file mode 100644 index 12e6376c4db32..0000000000000 --- a/x-pack/plugin/security/licenses/oauth2-oidc-sdk-6.5.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -422759fc195f65345e8da3265c69dea3c6cf56a5 \ No newline at end of file diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/oidc/OpenIdConnectAuthenticatorTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/oidc/OpenIdConnectAuthenticatorTests.java index d4734ce93e076..ad4b9fcd2af81 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/oidc/OpenIdConnectAuthenticatorTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/oidc/OpenIdConnectAuthenticatorTests.java @@ -10,6 +10,7 @@ import com.nimbusds.jose.crypto.ECDSASigner; import com.nimbusds.jose.crypto.MACSigner; import com.nimbusds.jose.crypto.RSASSASigner; +import com.nimbusds.jose.jwk.Curve; import com.nimbusds.jose.jwk.ECKey; import com.nimbusds.jose.jwk.JWK; import com.nimbusds.jose.jwk.JWKSet; @@ -971,7 +972,7 @@ private Tuple getRandomJwkForType(String type) throws Exception { } else if (type.equals("ES")) { hashSize = randomFrom(256, 384, 512); - ECKey.Curve curve = curveFromHashSize(hashSize); + Curve curve = curveFromHashSize(hashSize); KeyPairGenerator gen = KeyPairGenerator.getInstance("EC"); gen.initialize(curve.toECParameterSpec()); KeyPair keyPair = gen.generateKeyPair(); @@ -986,13 +987,13 @@ private Tuple getRandomJwkForType(String type) throws Exception { return new Tuple(key, new JWKSet(jwk)); } - private ECKey.Curve curveFromHashSize(int size) { + private Curve curveFromHashSize(int size) { if (size == 256) { - return ECKey.Curve.P_256; + return Curve.P_256; } else if (size == 384) { - return ECKey.Curve.P_384; + return Curve.P_384; } else if (size == 512) { - return ECKey.Curve.P_521; + return Curve.P_521; } else { throw new IllegalArgumentException("Invalid hash size:" + size); } From b7f87a6946ca1fba019c447f2513236e4aa62871 Mon Sep 17 00:00:00 2001 From: Dan Hermann Date: Tue, 29 Oct 2019 06:44:28 -0500 Subject: [PATCH 11/12] Validate monitoring username at parse time (#47821) --- .../exporter/http/HttpExporter.java | 42 ++++++++++++++++++- .../exporter/http/HttpExporterTests.java | 22 ++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java index 6963cd2fab14c..e9df728c7780a 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java @@ -177,7 +177,47 @@ public Iterator> settings() { */ public static final Setting.AffixSetting AUTH_USERNAME_SETTING = Setting.affixKeySetting("xpack.monitoring.exporters.","auth.username", - (key) -> Setting.simpleString(key, Property.Dynamic, Property.NodeScope, Property.Filtered)); + (key) -> Setting.simpleString( + key, + new Setting.Validator() { + @Override + public void validate(String password) { + // no username validation that is independent of other settings + } + + @Override + public void validate(String username, Map, Object> settings) { + final String namespace = + HttpExporter.AUTH_USERNAME_SETTING.getNamespace( + HttpExporter.AUTH_USERNAME_SETTING.getConcreteSetting(key)); + final String password = + (String) settings.get(AUTH_PASSWORD_SETTING.getConcreteSettingForNamespace(namespace)); + + // password must be specified along with username for any auth + if (Strings.isNullOrEmpty(username) == false) { + if (Strings.isNullOrEmpty(password)) { + throw new SettingsException( + "[" + AUTH_USERNAME_SETTING.getConcreteSettingForNamespace(namespace).getKey() + "] is set " + + "but [" + AUTH_PASSWORD_SETTING.getConcreteSettingForNamespace(namespace).getKey() + "] is " + + "missing"); + } + } + } + + @Override + public Iterator> settings() { + final String namespace = + HttpExporter.AUTH_USERNAME_SETTING.getNamespace( + HttpExporter.AUTH_USERNAME_SETTING.getConcreteSetting(key)); + final List> settings = List.of( + HttpExporter.AUTH_PASSWORD_SETTING.getConcreteSettingForNamespace(namespace)); + return settings.iterator(); + } + + }, + Property.Dynamic, + Property.NodeScope, + Property.Filtered)); /** * Password for basic auth. */ diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterTests.java index 79a5da518e7c1..c8f4fb6958aa7 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterTests.java @@ -238,6 +238,28 @@ public void testExporterWithPasswordButNoUsername() { assertThat(exception.getMessage(), equalTo(expected)); } + public void testExporterWithUsernameButNoPassword() { + final String expected = + "[xpack.monitoring.exporters._http.auth.username] is set but [xpack.monitoring.exporters._http.auth.password] is missing"; + final String prefix = "xpack.monitoring.exporters._http"; + final Settings settings = Settings.builder() + .put(prefix + ".type", HttpExporter.TYPE) + .put(prefix + ".host", "localhost:9200") + .put(prefix + ".auth.username", "_user") + .build(); + + final IllegalArgumentException e = expectThrows( + IllegalArgumentException.class, + () -> HttpExporter.AUTH_USERNAME_SETTING.getConcreteSetting(prefix + ".auth.username").get(settings)); + assertThat( + e, + hasToString( + containsString("Failed to parse value for setting [xpack.monitoring.exporters._http.auth.username]"))); + + assertThat(e.getCause(), instanceOf(SettingsException.class)); + assertThat(e.getCause(), hasToString(containsString(expected))); + } + public void testExporterWithUnknownBlacklistedClusterAlerts() { final SSLIOSessionStrategy sslStrategy = mock(SSLIOSessionStrategy.class); when(sslService.sslIOSessionStrategy(any(Settings.class))).thenReturn(sslStrategy); From 7241a748e613cc16a025f334bea9952106143eb1 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Tue, 29 Oct 2019 14:05:34 +0200 Subject: [PATCH 12/12] Work around incorrect lintian version on debian 10 (#48620) * Work around incorrect lintian version on debian 10 Relates to #48573 and intended as a work around to stop the CI failures until we fix the image. * Need to pass --allow-downgrades --- .ci/os.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.ci/os.sh b/.ci/os.sh index 59a8a9a03a7b9..8ec110ac183b7 100755 --- a/.ci/os.sh +++ b/.ci/os.sh @@ -33,6 +33,11 @@ if [ -f "/etc/os-release" ] ; then if [[ "$ID" == "debian" || "$ID_LIKE" == "debian" ]] ; then # FIXME: The base image should not have rpm installed sudo rm -Rf /usr/bin/rpm + # Work around incorrect lintian version + # https://github.com/elastic/elasticsearch/issues/48573 + if [ $VERSION_ID == 10 ] ; then + sudo apt-get install -y --allow-downgrades lintian=2.15.0 + fi fi else cat /etc/issue || true