Skip to content

Commit 71cc05d

Browse files
committed
Merge branch '6.x' into ccr-6.x
* 6.x: Do not check for object existence when deleting repository index files (#31680) Remove extra check for object existence in repository-gcs read object (#31661) [Test] Clean up some repository-s3 tests (#31601) Merge AzureStorageService and AzureStorageServiceImpl and clean up tests (#31607) [Docs] Use capital letters in section headings (#31678) [DOCS] Add PQL language Plugin (#31237) [DOCS] Fix licensing API details (#31667) Fix CreateSnapshotRequestTests Failure (#31630) Add Create Snapshot to High-Level Rest Client (#31215) Add MultiSearchTemplate support to High Level Rest client (#31662) SQL: Refactor package names of sql-proto and sql-shared-proto projects (#31622) [TEST] Mute failing NamingConventionsTaskIT tests [DOCS] Replace CONFIG_DIR with ES_PATH_CONF (#31635) Add test for low-level client round-robin behaviour (#31616) HLRest: Fix test for explain API Add explain API to high-level REST client (#31387)
2 parents 767172c + e057f1a commit 71cc05d

File tree

207 files changed

+3476
-2312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

207 files changed

+3476
-2312
lines changed

buildSrc/src/test/java/org/elasticsearch/gradle/precommit/NamingConventionsTaskIT.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.gradle.testkit.runner.BuildResult;
55
import org.gradle.testkit.runner.GradleRunner;
66
import org.gradle.testkit.runner.TaskOutcome;
7+
import org.junit.Ignore;
78

89
import java.util.Arrays;
910

@@ -20,6 +21,7 @@ public void testPluginCanBeApplied() {
2021
assertTrue(result.getOutput().contains("build plugin can be applied"));
2122
}
2223

24+
@Ignore("AwaitsFix : https://github.com/elastic/elasticsearch/issues/31665")
2325
public void testNameCheckFailsAsItShould() {
2426
BuildResult result = GradleRunner.create()
2527
.withProjectDir(getProjectDir("namingConventionsSelfTest"))
@@ -44,6 +46,7 @@ public void testNameCheckFailsAsItShould() {
4446
}
4547
}
4648

49+
@Ignore("AwaitsFix : https://github.com/elastic/elasticsearch/issues/31665")
4750
public void testNameCheckFailsAsItShouldWithMain() {
4851
BuildResult result = GradleRunner.create()
4952
.withProjectDir(getProjectDir("namingConventionsSelfTest"))

client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest;
3838
import org.elasticsearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest;
3939
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
40+
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest;
4041
import org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest;
4142
import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptRequest;
4243
import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest;
@@ -65,14 +66,15 @@
6566
import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest;
6667
import org.elasticsearch.action.bulk.BulkRequest;
6768
import org.elasticsearch.action.delete.DeleteRequest;
69+
import org.elasticsearch.action.explain.ExplainRequest;
6870
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest;
6971
import org.elasticsearch.action.get.GetRequest;
7072
import org.elasticsearch.action.get.MultiGetRequest;
7173
import org.elasticsearch.action.index.IndexRequest;
7274
import org.elasticsearch.action.ingest.DeletePipelineRequest;
73-
import org.elasticsearch.action.ingest.PutPipelineRequest;
7475
import org.elasticsearch.action.ingest.GetPipelineRequest;
7576
import org.elasticsearch.action.ingest.SimulatePipelineRequest;
77+
import org.elasticsearch.action.ingest.PutPipelineRequest;
7678
import org.elasticsearch.action.search.ClearScrollRequest;
7779
import org.elasticsearch.action.search.MultiSearchRequest;
7880
import org.elasticsearch.action.search.SearchRequest;
@@ -100,6 +102,7 @@
100102
import org.elasticsearch.index.VersionType;
101103
import org.elasticsearch.index.rankeval.RankEvalRequest;
102104
import org.elasticsearch.rest.action.search.RestSearchAction;
105+
import org.elasticsearch.script.mustache.MultiSearchTemplateRequest;
103106
import org.elasticsearch.script.mustache.SearchTemplateRequest;
104107
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
105108
import org.elasticsearch.tasks.TaskId;
@@ -610,6 +613,21 @@ static Request searchTemplate(SearchTemplateRequest searchTemplateRequest) throw
610613
request.setEntity(createEntity(searchTemplateRequest, REQUEST_BODY_CONTENT_TYPE));
611614
return request;
612615
}
616+
617+
static Request multiSearchTemplate(MultiSearchTemplateRequest multiSearchTemplateRequest) throws IOException {
618+
Request request = new Request(HttpPost.METHOD_NAME, "/_msearch/template");
619+
620+
Params params = new Params(request);
621+
params.putParam(RestSearchAction.TYPED_KEYS_PARAM, "true");
622+
if (multiSearchTemplateRequest.maxConcurrentSearchRequests() != MultiSearchRequest.MAX_CONCURRENT_SEARCH_REQUESTS_DEFAULT) {
623+
params.putParam("max_concurrent_searches", Integer.toString(multiSearchTemplateRequest.maxConcurrentSearchRequests()));
624+
}
625+
626+
XContent xContent = REQUEST_BODY_CONTENT_TYPE.xContent();
627+
byte[] source = MultiSearchTemplateRequest.writeMultiLineFormat(multiSearchTemplateRequest, xContent);
628+
request.setEntity(new ByteArrayEntity(source, createContentType(xContent.type())));
629+
return request;
630+
}
613631

614632
static Request existsAlias(GetAliasesRequest getAliasesRequest) {
615633
if ((getAliasesRequest.indices() == null || getAliasesRequest.indices().length == 0) &&
@@ -627,6 +645,19 @@ static Request existsAlias(GetAliasesRequest getAliasesRequest) {
627645
return request;
628646
}
629647

648+
static Request explain(ExplainRequest explainRequest) throws IOException {
649+
Request request = new Request(HttpGet.METHOD_NAME,
650+
endpoint(explainRequest.index(), explainRequest.type(), explainRequest.id(), "_explain"));
651+
652+
Params params = new Params(request);
653+
params.withStoredFields(explainRequest.storedFields());
654+
params.withFetchSourceContext(explainRequest.fetchSourceContext());
655+
params.withRouting(explainRequest.routing());
656+
params.withPreference(explainRequest.preference());
657+
request.setEntity(createEntity(explainRequest, REQUEST_BODY_CONTENT_TYPE));
658+
return request;
659+
}
660+
630661
static Request fieldCaps(FieldCapabilitiesRequest fieldCapabilitiesRequest) {
631662
String[] indices = fieldCapabilitiesRequest.indices();
632663
Request request = new Request(HttpGet.METHOD_NAME, endpoint(indices, "_field_caps"));
@@ -877,6 +908,19 @@ static Request verifyRepository(VerifyRepositoryRequest verifyRepositoryRequest)
877908
return request;
878909
}
879910

911+
static Request createSnapshot(CreateSnapshotRequest createSnapshotRequest) throws IOException {
912+
String endpoint = new EndpointBuilder().addPathPart("_snapshot")
913+
.addPathPart(createSnapshotRequest.repository())
914+
.addPathPart(createSnapshotRequest.snapshot())
915+
.build();
916+
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
917+
Params params = new Params(request);
918+
params.withMasterTimeout(createSnapshotRequest.masterNodeTimeout());
919+
params.withWaitForCompletion(createSnapshotRequest.waitForCompletion());
920+
request.setEntity(createEntity(createSnapshotRequest, REQUEST_BODY_CONTENT_TYPE));
921+
return request;
922+
}
923+
880924
static Request deleteSnapshot(DeleteSnapshotRequest deleteSnapshotRequest) {
881925
String endpoint = new EndpointBuilder().addPathPartAsIs("_snapshot")
882926
.addPathPart(deleteSnapshotRequest.repository())

client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import org.elasticsearch.action.bulk.BulkResponse;
3535
import org.elasticsearch.action.delete.DeleteRequest;
3636
import org.elasticsearch.action.delete.DeleteResponse;
37+
import org.elasticsearch.action.explain.ExplainRequest;
38+
import org.elasticsearch.action.explain.ExplainResponse;
3739
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest;
3840
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse;
3941
import org.elasticsearch.action.get.GetRequest;
@@ -66,6 +68,8 @@
6668
import org.elasticsearch.plugins.spi.NamedXContentProvider;
6769
import org.elasticsearch.rest.BytesRestResponse;
6870
import org.elasticsearch.rest.RestStatus;
71+
import org.elasticsearch.script.mustache.MultiSearchTemplateRequest;
72+
import org.elasticsearch.script.mustache.MultiSearchTemplateResponse;
6973
import org.elasticsearch.script.mustache.SearchTemplateRequest;
7074
import org.elasticsearch.script.mustache.SearchTemplateResponse;
7175
import org.elasticsearch.search.aggregations.Aggregation;
@@ -899,6 +903,42 @@ public final void searchTemplateAsync(SearchTemplateRequest searchTemplateReques
899903
SearchTemplateResponse::fromXContent, listener, emptySet());
900904
}
901905

906+
/**
907+
* Executes a request using the Explain API.
908+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html">Explain API on elastic.co</a>
909+
* @param explainRequest the request
910+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
911+
* @return the response
912+
* @throws IOException in case there is a problem sending the request or parsing back the response
913+
*/
914+
public final ExplainResponse explain(ExplainRequest explainRequest, RequestOptions options) throws IOException {
915+
return performRequest(explainRequest, RequestConverters::explain, options,
916+
response -> {
917+
CheckedFunction<XContentParser, ExplainResponse, IOException> entityParser =
918+
parser -> ExplainResponse.fromXContent(parser, convertExistsResponse(response));
919+
return parseEntity(response.getEntity(), entityParser);
920+
},
921+
singleton(404));
922+
}
923+
924+
/**
925+
* Asynchronously executes a request using the Explain API.
926+
*
927+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-explain.html">Explain API on elastic.co</a>
928+
* @param explainRequest the request
929+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
930+
* @param listener the listener to be notified upon request completion
931+
*/
932+
public final void explainAsync(ExplainRequest explainRequest, RequestOptions options, ActionListener<ExplainResponse> listener) {
933+
performRequestAsync(explainRequest, RequestConverters::explain, options,
934+
response -> {
935+
CheckedFunction<XContentParser, ExplainResponse, IOException> entityParser =
936+
parser -> ExplainResponse.fromXContent(parser, convertExistsResponse(response));
937+
return parseEntity(response.getEntity(), entityParser);
938+
},
939+
listener, singleton(404));
940+
}
941+
902942
/**
903943
* Executes a request using the Ranking Evaluation API.
904944
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-rank-eval.html">Ranking Evaluation API
@@ -939,6 +979,32 @@ public final void rankEvalAsync(RankEvalRequest rankEvalRequest, RequestOptions
939979
emptySet());
940980
}
941981

982+
983+
/**
984+
* Executes a request using the Multi Search Template API.
985+
*
986+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-search-template.html">Multi Search Template API
987+
* on elastic.co</a>.
988+
*/
989+
public final MultiSearchTemplateResponse multiSearchTemplate(MultiSearchTemplateRequest multiSearchTemplateRequest,
990+
RequestOptions options) throws IOException {
991+
return performRequestAndParseEntity(multiSearchTemplateRequest, RequestConverters::multiSearchTemplate,
992+
options, MultiSearchTemplateResponse::fromXContext, emptySet());
993+
}
994+
995+
/**
996+
* Asynchronously executes a request using the Multi Search Template API
997+
*
998+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-search-template.html">Multi Search Template API
999+
* on elastic.co</a>.
1000+
*/
1001+
public final void multiSearchTemplateAsync(MultiSearchTemplateRequest multiSearchTemplateRequest,
1002+
RequestOptions options,
1003+
ActionListener<MultiSearchTemplateResponse> listener) {
1004+
performRequestAsyncAndParseEntity(multiSearchTemplateRequest, RequestConverters::multiSearchTemplate,
1005+
options, MultiSearchTemplateResponse::fromXContext, listener, emptySet());
1006+
}
1007+
9421008
/**
9431009
* Asynchronously executes a request using the Ranking Evaluation API.
9441010
*

client/rest-high-level/src/main/java/org/elasticsearch/client/SnapshotClient.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse;
2929
import org.elasticsearch.action.admin.cluster.repositories.verify.VerifyRepositoryRequest;
3030
import org.elasticsearch.action.admin.cluster.repositories.verify.VerifyRepositoryResponse;
31+
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest;
32+
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
3133
import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest;
3234
import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotResponse;
3335

@@ -164,6 +166,30 @@ public void verifyRepositoryAsync(VerifyRepositoryRequest verifyRepositoryReques
164166
VerifyRepositoryResponse::fromXContent, listener, emptySet());
165167
}
166168

169+
/**
170+
* Creates a snapshot.
171+
* <p>
172+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html"> Snapshot and Restore
173+
* API on elastic.co</a>
174+
*/
175+
public CreateSnapshotResponse createSnapshot(CreateSnapshotRequest createSnapshotRequest, RequestOptions options)
176+
throws IOException {
177+
return restHighLevelClient.performRequestAndParseEntity(createSnapshotRequest, RequestConverters::createSnapshot, options,
178+
CreateSnapshotResponse::fromXContent, emptySet());
179+
}
180+
181+
/**
182+
* Asynchronously creates a snapshot.
183+
* <p>
184+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html"> Snapshot and Restore
185+
* API on elastic.co</a>
186+
*/
187+
public void createSnapshotAsync(CreateSnapshotRequest createSnapshotRequest, RequestOptions options,
188+
ActionListener<CreateSnapshotResponse> listener) {
189+
restHighLevelClient.performRequestAsyncAndParseEntity(createSnapshotRequest, RequestConverters::createSnapshot, options,
190+
CreateSnapshotResponse::fromXContent, listener, emptySet());
191+
}
192+
167193
/**
168194
* Deletes a snapshot.
169195
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html"> Snapshot and Restore

0 commit comments

Comments
 (0)