Skip to content

Commit 2c3a276

Browse files
committed
Merge branch 'master' into pr/33501
* master: (43 commits) [HLRC][ML] Add ML put datafeed API to HLRC (elastic#33603) Update AWS SDK to 1.11.406 in repository-s3 (elastic#30723) Expose CCR stats to monitoring (elastic#33617) [Docs] Update match-query.asciidoc (elastic#33610) TEST: Adjust rollback condition when shard is empty [CCR] Improve shard follow task's retryable error handling (elastic#33371) Forbid negative `weight` in Function Score Query (elastic#33390) Clarify context suggestions filtering and boosting (elastic#33601) Disable CCR REST endpoints if CCR disabled (elastic#33619) Lower version on full cluster restart settings test Upgrade remote cluster settings (elastic#33537) NETWORKING: http.publish_host Should Contain CNAME (elastic#32806) Add test coverage for global checkpoint listeners Reset replica engine to global checkpoint on promotion (elastic#33473) HLRC: ML Delete Forecast API (elastic#33526) Remove debug logging in full cluster restart tests (elastic#33612) Expose CCR to the transport client (elastic#33608) Mute testIndexDeletionWhenNodeRejoins SQL: Make Literal a NamedExpression (elastic#33583) [DOCS] Adds missing built-in user information (elastic#33585) ...
2 parents 797bfb4 + 2eb2313 commit 2c3a276

File tree

296 files changed

+8449
-3095
lines changed

Some content is hidden

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

296 files changed

+8449
-3095
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,9 @@ class BuildPlugin implements Plugin<Project> {
831831
// TODO: remove this once ctx isn't added to update script params in 7.0
832832
systemProperty 'es.scripting.update.ctx_in_params', 'false'
833833

834+
//TODO: remove this once the cname is prepended to the address by default in 7.0
835+
systemProperty 'es.http.cname_in_publish_address', 'true'
836+
834837
// Set the system keystore/truststore password if we're running tests in a FIPS-140 JVM
835838
if (project.inFipsJvm) {
836839
systemProperty 'javax.net.ssl.trustStorePassword', 'password'

buildSrc/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
elasticsearch = 7.0.0-alpha1
2-
lucene = 8.0.0-snapshot-4d78db26be
2+
lucene = 8.0.0-snapshot-66c671ea80
33

44
# optional dependencies
55
spatial4j = 0.7

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,20 @@
2828
import org.apache.lucene.util.BytesRef;
2929
import org.elasticsearch.client.RequestConverters.EndpointBuilder;
3030
import org.elasticsearch.client.ml.CloseJobRequest;
31+
import org.elasticsearch.client.ml.DeleteForecastRequest;
3132
import org.elasticsearch.client.ml.DeleteJobRequest;
3233
import org.elasticsearch.client.ml.FlushJobRequest;
3334
import org.elasticsearch.client.ml.ForecastJobRequest;
3435
import org.elasticsearch.client.ml.GetBucketsRequest;
36+
import org.elasticsearch.client.ml.GetCategoriesRequest;
3537
import org.elasticsearch.client.ml.GetInfluencersRequest;
3638
import org.elasticsearch.client.ml.GetJobRequest;
3739
import org.elasticsearch.client.ml.GetJobStatsRequest;
3840
import org.elasticsearch.client.ml.GetOverallBucketsRequest;
3941
import org.elasticsearch.client.ml.GetRecordsRequest;
4042
import org.elasticsearch.client.ml.OpenJobRequest;
4143
import org.elasticsearch.client.ml.PostDataRequest;
44+
import org.elasticsearch.client.ml.PutDatafeedRequest;
4245
import org.elasticsearch.client.ml.PutJobRequest;
4346
import org.elasticsearch.client.ml.UpdateJobRequest;
4447
import org.elasticsearch.common.Strings;
@@ -180,6 +183,38 @@ static Request updateJob(UpdateJobRequest updateJobRequest) throws IOException {
180183
return request;
181184
}
182185

186+
static Request putDatafeed(PutDatafeedRequest putDatafeedRequest) throws IOException {
187+
String endpoint = new EndpointBuilder()
188+
.addPathPartAsIs("_xpack")
189+
.addPathPartAsIs("ml")
190+
.addPathPartAsIs("datafeeds")
191+
.addPathPart(putDatafeedRequest.getDatafeed().getId())
192+
.build();
193+
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
194+
request.setEntity(createEntity(putDatafeedRequest, REQUEST_BODY_CONTENT_TYPE));
195+
return request;
196+
}
197+
198+
static Request deleteForecast(DeleteForecastRequest deleteForecastRequest) throws IOException {
199+
String endpoint = new EndpointBuilder()
200+
.addPathPartAsIs("_xpack")
201+
.addPathPartAsIs("ml")
202+
.addPathPartAsIs("anomaly_detectors")
203+
.addPathPart(deleteForecastRequest.getJobId())
204+
.addPathPartAsIs("_forecast")
205+
.addPathPart(Strings.collectionToCommaDelimitedString(deleteForecastRequest.getForecastIds()))
206+
.build();
207+
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
208+
RequestConverters.Params params = new RequestConverters.Params(request);
209+
if (deleteForecastRequest.isAllowNoForecasts() != null) {
210+
params.putParam("allow_no_forecasts", Boolean.toString(deleteForecastRequest.isAllowNoForecasts()));
211+
}
212+
if (deleteForecastRequest.timeout() != null) {
213+
params.putParam("timeout", deleteForecastRequest.timeout().getStringRep());
214+
}
215+
return request;
216+
}
217+
183218
static Request getBuckets(GetBucketsRequest getBucketsRequest) throws IOException {
184219
String endpoint = new EndpointBuilder()
185220
.addPathPartAsIs("_xpack")
@@ -194,6 +229,20 @@ static Request getBuckets(GetBucketsRequest getBucketsRequest) throws IOExceptio
194229
return request;
195230
}
196231

232+
static Request getCategories(GetCategoriesRequest getCategoriesRequest) throws IOException {
233+
String endpoint = new EndpointBuilder()
234+
.addPathPartAsIs("_xpack")
235+
.addPathPartAsIs("ml")
236+
.addPathPartAsIs("anomaly_detectors")
237+
.addPathPart(getCategoriesRequest.getJobId())
238+
.addPathPartAsIs("results")
239+
.addPathPartAsIs("categories")
240+
.build();
241+
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
242+
request.setEntity(createEntity(getCategoriesRequest, REQUEST_BODY_CONTENT_TYPE));
243+
return request;
244+
}
245+
197246
static Request getOverallBuckets(GetOverallBucketsRequest getOverallBucketsRequest) throws IOException {
198247
String endpoint = new EndpointBuilder()
199248
.addPathPartAsIs("_xpack")

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

Lines changed: 140 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@
1919
package org.elasticsearch.client;
2020

2121
import org.elasticsearch.action.ActionListener;
22-
import org.elasticsearch.client.ml.ForecastJobRequest;
23-
import org.elasticsearch.client.ml.ForecastJobResponse;
24-
import org.elasticsearch.client.ml.PostDataRequest;
25-
import org.elasticsearch.client.ml.PostDataResponse;
26-
import org.elasticsearch.client.ml.UpdateJobRequest;
22+
import org.elasticsearch.action.support.master.AcknowledgedResponse;
2723
import org.elasticsearch.client.ml.CloseJobRequest;
2824
import org.elasticsearch.client.ml.CloseJobResponse;
25+
import org.elasticsearch.client.ml.DeleteForecastRequest;
2926
import org.elasticsearch.client.ml.DeleteJobRequest;
3027
import org.elasticsearch.client.ml.DeleteJobResponse;
3128
import org.elasticsearch.client.ml.FlushJobRequest;
3229
import org.elasticsearch.client.ml.FlushJobResponse;
30+
import org.elasticsearch.client.ml.ForecastJobRequest;
31+
import org.elasticsearch.client.ml.ForecastJobResponse;
3332
import org.elasticsearch.client.ml.GetBucketsRequest;
3433
import org.elasticsearch.client.ml.GetBucketsResponse;
34+
import org.elasticsearch.client.ml.GetCategoriesRequest;
35+
import org.elasticsearch.client.ml.GetCategoriesResponse;
3536
import org.elasticsearch.client.ml.GetInfluencersRequest;
3637
import org.elasticsearch.client.ml.GetInfluencersResponse;
3738
import org.elasticsearch.client.ml.GetJobRequest;
@@ -44,13 +45,19 @@
4445
import org.elasticsearch.client.ml.GetRecordsResponse;
4546
import org.elasticsearch.client.ml.OpenJobRequest;
4647
import org.elasticsearch.client.ml.OpenJobResponse;
48+
import org.elasticsearch.client.ml.PostDataRequest;
49+
import org.elasticsearch.client.ml.PostDataResponse;
50+
import org.elasticsearch.client.ml.PutDatafeedRequest;
51+
import org.elasticsearch.client.ml.PutDatafeedResponse;
4752
import org.elasticsearch.client.ml.PutJobRequest;
4853
import org.elasticsearch.client.ml.PutJobResponse;
54+
import org.elasticsearch.client.ml.UpdateJobRequest;
4955
import org.elasticsearch.client.ml.job.stats.JobStats;
5056

5157
import java.io.IOException;
5258
import java.util.Collections;
5359

60+
5461
/**
5562
* Machine Learning API client wrapper for the {@link RestHighLevelClient}
5663
*
@@ -387,6 +394,11 @@ public ForecastJobResponse forecastJob(ForecastJobRequest request, RequestOption
387394
/**
388395
* Updates a Machine Learning {@link org.elasticsearch.client.ml.job.config.Job}
389396
*
397+
* <p>
398+
* For additional info
399+
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html"></a>
400+
* </p>
401+
*
390402
* @param request the {@link UpdateJobRequest} object enclosing the desired updates
391403
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
392404
* @return a PutJobResponse object containing the updated job object
@@ -425,6 +437,10 @@ public void forecastJobAsync(ForecastJobRequest request, RequestOptions options,
425437
/**
426438
* Updates a Machine Learning {@link org.elasticsearch.client.ml.job.config.Job} asynchronously
427439
*
440+
* <p>
441+
* For additional info
442+
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html"></a>
443+
* </p>
428444
* @param request the {@link UpdateJobRequest} object enclosing the desired updates
429445
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
430446
* @param listener Listener to be notified upon request completion
@@ -438,6 +454,86 @@ public void updateJobAsync(UpdateJobRequest request, RequestOptions options, Act
438454
Collections.emptySet());
439455
}
440456

457+
/**
458+
* Creates a new Machine Learning Datafeed
459+
* <p>
460+
* For additional info
461+
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html">ML PUT datafeed documentation</a>
462+
*
463+
* @param request The PutDatafeedRequest containing the {@link org.elasticsearch.client.ml.datafeed.DatafeedConfig} settings
464+
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
465+
* @return PutDatafeedResponse with enclosed {@link org.elasticsearch.client.ml.datafeed.DatafeedConfig} object
466+
* @throws IOException when there is a serialization issue sending the request or receiving the response
467+
*/
468+
public PutDatafeedResponse putDatafeed(PutDatafeedRequest request, RequestOptions options) throws IOException {
469+
return restHighLevelClient.performRequestAndParseEntity(request,
470+
MLRequestConverters::putDatafeed,
471+
options,
472+
PutDatafeedResponse::fromXContent,
473+
Collections.emptySet());
474+
}
475+
476+
/**
477+
* Creates a new Machine Learning Datafeed asynchronously and notifies listener on completion
478+
* <p>
479+
* For additional info
480+
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html">ML PUT datafeed documentation</a>
481+
*
482+
* @param request The request containing the {@link org.elasticsearch.client.ml.datafeed.DatafeedConfig} settings
483+
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
484+
* @param listener Listener to be notified upon request completion
485+
*/
486+
public void putDatafeedAsync(PutDatafeedRequest request, RequestOptions options, ActionListener<PutDatafeedResponse> listener) {
487+
restHighLevelClient.performRequestAsyncAndParseEntity(request,
488+
MLRequestConverters::putDatafeed,
489+
options,
490+
PutDatafeedResponse::fromXContent,
491+
listener,
492+
Collections.emptySet());
493+
}
494+
495+
/**
496+
* Deletes Machine Learning Job Forecasts
497+
*
498+
* <p>
499+
* For additional info
500+
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html"></a>
501+
* </p>
502+
*
503+
* @param request the {@link DeleteForecastRequest} object enclosing the desired jobId, forecastIDs, and other options
504+
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
505+
* @return a AcknowledgedResponse object indicating request success
506+
* @throws IOException when there is a serialization issue sending the request or receiving the response
507+
*/
508+
public AcknowledgedResponse deleteForecast(DeleteForecastRequest request, RequestOptions options) throws IOException {
509+
return restHighLevelClient.performRequestAndParseEntity(request,
510+
MLRequestConverters::deleteForecast,
511+
options,
512+
AcknowledgedResponse::fromXContent,
513+
Collections.emptySet());
514+
}
515+
516+
/**
517+
* Deletes Machine Learning Job Forecasts asynchronously
518+
*
519+
* <p>
520+
* For additional info
521+
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html"></a>
522+
* </p>
523+
*
524+
* @param request the {@link DeleteForecastRequest} object enclosing the desired jobId, forecastIDs, and other options
525+
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
526+
* @param listener Listener to be notified upon request completion
527+
*/
528+
public void deleteForecastAsync(DeleteForecastRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
529+
restHighLevelClient.performRequestAsyncAndParseEntity(request,
530+
MLRequestConverters::deleteForecast,
531+
options,
532+
AcknowledgedResponse::fromXContent,
533+
listener,
534+
Collections.emptySet());
535+
}
536+
441537
/**
442538
* Gets the buckets for a Machine Learning Job.
443539
* <p>
@@ -474,6 +570,45 @@ public void getBucketsAsync(GetBucketsRequest request, RequestOptions options, A
474570
Collections.emptySet());
475571
}
476572

573+
/**
574+
* Gets the categories for a Machine Learning Job.
575+
* <p>
576+
* For additional info
577+
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html">
578+
* ML GET categories documentation</a>
579+
*
580+
* @param request The request
581+
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
582+
* @throws IOException when there is a serialization issue sending the request or receiving the response
583+
*/
584+
public GetCategoriesResponse getCategories(GetCategoriesRequest request, RequestOptions options) throws IOException {
585+
return restHighLevelClient.performRequestAndParseEntity(request,
586+
MLRequestConverters::getCategories,
587+
options,
588+
GetCategoriesResponse::fromXContent,
589+
Collections.emptySet());
590+
}
591+
592+
/**
593+
* Gets the categories for a Machine Learning Job, notifies listener once the requested buckets are retrieved.
594+
* <p>
595+
* For additional info
596+
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html">
597+
* ML GET categories documentation</a>
598+
*
599+
* @param request The request
600+
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
601+
* @param listener Listener to be notified upon request completion
602+
*/
603+
public void getCategoriesAsync(GetCategoriesRequest request, RequestOptions options, ActionListener<GetCategoriesResponse> listener) {
604+
restHighLevelClient.performRequestAsyncAndParseEntity(request,
605+
MLRequestConverters::getCategories,
606+
options,
607+
GetCategoriesResponse::fromXContent,
608+
listener,
609+
Collections.emptySet());
610+
}
611+
477612
/**
478613
* Gets overall buckets for a set of Machine Learning Jobs.
479614
* <p>

0 commit comments

Comments
 (0)