Skip to content

Commit 017ffe5

Browse files
committed
Merge branch 'master' into index-lifecycle
2 parents 21bb472 + 79cd638 commit 017ffe5

File tree

672 files changed

+6435
-4932
lines changed

Some content is hidden

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

672 files changed

+6435
-4932
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,9 @@ class BuildPlugin implements Plugin<Project> {
539539
from generatePOMTask.destination
540540
into "${project.buildDir}/distributions"
541541
rename {
542-
generatePOMTask.ext.pomFileName == null ?
543-
"${project.archivesBaseName}-${project.version}.pom" :
544-
generatePOMTask.ext.pomFileName
542+
generatePOMTask.ext.pomFileName == null ?
543+
"${project.archivesBaseName}-${project.version}.pom" :
544+
generatePOMTask.ext.pomFileName
545545
}
546546
}
547547
}

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,7 @@
360360
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]bucket[/\\]terms[/\\]TermsAggregator.java" checks="LineLength" />
361361
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]bucket[/\\]terms[/\\]TermsAggregatorFactory.java" checks="LineLength" />
362362
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]bucket[/\\]terms[/\\]support[/\\]IncludeExclude.java" checks="LineLength" />
363-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]metrics[/\\]cardinality[/\\]CardinalityAggregator.java" checks="LineLength" />
364-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]metrics[/\\]cardinality[/\\]HyperLogLogPlusPlus.java" checks="LineLength" />
365-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]metrics[/\\]geobounds[/\\]GeoBoundsAggregator.java" checks="LineLength" />
366-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]metrics[/\\]geocentroid[/\\]InternalGeoCentroid.java" checks="LineLength" />
367-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]metrics[/\\]percentiles[/\\]tdigest[/\\]TDigestPercentileRanksAggregator.java" checks="LineLength" />
368-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]metrics[/\\]percentiles[/\\]tdigest[/\\]TDigestPercentilesAggregator.java" checks="LineLength" />
369-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]metrics[/\\]scripted[/\\]ScriptedMetricAggregator.java" checks="LineLength" />
363+
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]metrics[/\\]HyperLogLogPlusPlus.java" checks="LineLength" />
370364
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]support[/\\]AggregationPath.java" checks="LineLength" />
371365
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]dfs[/\\]AggregatedDfs.java" checks="LineLength" />
372366
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]dfs[/\\]DfsSearchResult.java" checks="LineLength" />
@@ -641,8 +635,6 @@
641635
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]bucket[/\\]TermsDocCountErrorIT.java" checks="LineLength" />
642636
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]bucket[/\\]TermsShardMinDocCountIT.java" checks="LineLength" />
643637
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]bucket[/\\]nested[/\\]NestedAggregatorTests.java" checks="LineLength" />
644-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]metrics[/\\]AbstractGeoTestCase.java" checks="LineLength" />
645-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]metrics[/\\]TopHitsIT.java" checks="LineLength" />
646638
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]pipeline[/\\]ExtendedStatsBucketIT.java" checks="LineLength" />
647639
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]pipeline[/\\]moving[/\\]avg[/\\]MovAvgIT.java" checks="LineLength" />
648640
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]search[/\\]aggregations[/\\]pipeline[/\\]serialdiff[/\\]SerialDiffIT.java" checks="LineLength" />

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 = 7.5.0-snapshot-13b9e28f9d
2+
lucene = 8.0.0-snapshot-4d78db26be
33

44
# optional dependencies
55
spatial4j = 0.7

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class GraphClient {
4343
*/
4444
public final GraphExploreResponse explore(GraphExploreRequest graphExploreRequest,
4545
RequestOptions options) throws IOException {
46-
return restHighLevelClient.performRequestAndParseEntity(graphExploreRequest, RequestConverters::xPackGraphExplore,
46+
return restHighLevelClient.performRequestAndParseEntity(graphExploreRequest, GraphRequestConverters::explore,
4747
options, GraphExploreResponse::fromXContext, emptySet());
4848
}
4949

@@ -56,7 +56,7 @@ public final GraphExploreResponse explore(GraphExploreRequest graphExploreReques
5656
public final void exploreAsync(GraphExploreRequest graphExploreRequest,
5757
RequestOptions options,
5858
ActionListener<GraphExploreResponse> listener) {
59-
restHighLevelClient.performRequestAsyncAndParseEntity(graphExploreRequest, RequestConverters::xPackGraphExplore,
59+
restHighLevelClient.performRequestAsyncAndParseEntity(graphExploreRequest, GraphRequestConverters::explore,
6060
options, GraphExploreResponse::fromXContext, listener, emptySet());
6161
}
6262

server/src/main/java/org/elasticsearch/index/analysis/StandardTokenFilterFactory.java renamed to client/rest-high-level/src/main/java/org/elasticsearch/client/GraphRequestConverters.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,19 @@
1717
* under the License.
1818
*/
1919

20-
package org.elasticsearch.index.analysis;
20+
package org.elasticsearch.client;
2121

22-
import org.apache.lucene.analysis.TokenStream;
23-
import org.apache.lucene.analysis.standard.StandardFilter;
24-
import org.elasticsearch.common.settings.Settings;
25-
import org.elasticsearch.env.Environment;
26-
import org.elasticsearch.index.IndexSettings;
22+
import org.apache.http.client.methods.HttpGet;
23+
import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest;
2724

25+
import java.io.IOException;
2826

29-
public class StandardTokenFilterFactory extends AbstractTokenFilterFactory {
27+
public class GraphRequestConverters {
3028

31-
public StandardTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
32-
super(indexSettings, name, settings);
29+
static Request explore(GraphExploreRequest exploreRequest) throws IOException {
30+
String endpoint = RequestConverters.endpoint(exploreRequest.indices(), exploreRequest.types(), "_xpack/graph/_explore");
31+
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
32+
request.setEntity(RequestConverters.createEntity(exploreRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
33+
return request;
3334
}
34-
35-
@Override
36-
public TokenStream create(TokenStream tokenStream) {
37-
return new StandardFilter(tokenStream);
38-
}
39-
}
35+
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public final class LicenseClient {
6565
* @throws IOException in case there is a problem sending the request or parsing back the response
6666
*/
6767
public PutLicenseResponse putLicense(PutLicenseRequest request, RequestOptions options) throws IOException {
68-
return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::putLicense, options,
68+
return restHighLevelClient.performRequestAndParseEntity(request, LicenseRequestConverters::putLicense, options,
6969
PutLicenseResponse::fromXContent, emptySet());
7070
}
7171

@@ -75,7 +75,7 @@ public PutLicenseResponse putLicense(PutLicenseRequest request, RequestOptions o
7575
* @param listener the listener to be notified upon request completion
7676
*/
7777
public void putLicenseAsync(PutLicenseRequest request, RequestOptions options, ActionListener<PutLicenseResponse> listener) {
78-
restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::putLicense, options,
78+
restHighLevelClient.performRequestAsyncAndParseEntity(request, LicenseRequestConverters::putLicense, options,
7979
PutLicenseResponse::fromXContent, listener, emptySet());
8080
}
8181

@@ -86,7 +86,7 @@ public void putLicenseAsync(PutLicenseRequest request, RequestOptions options, A
8686
* @throws IOException in case there is a problem sending the request or parsing back the response
8787
*/
8888
public GetLicenseResponse getLicense(GetLicenseRequest request, RequestOptions options) throws IOException {
89-
return restHighLevelClient.performRequest(request, RequestConverters::getLicense, options,
89+
return restHighLevelClient.performRequest(request, LicenseRequestConverters::getLicense, options,
9090
response -> new GetLicenseResponse(convertResponseToJson(response)), emptySet());
9191
}
9292

@@ -96,7 +96,7 @@ public GetLicenseResponse getLicense(GetLicenseRequest request, RequestOptions o
9696
* @param listener the listener to be notified upon request completion
9797
*/
9898
public void getLicenseAsync(GetLicenseRequest request, RequestOptions options, ActionListener<GetLicenseResponse> listener) {
99-
restHighLevelClient.performRequestAsync(request, RequestConverters::getLicense, options,
99+
restHighLevelClient.performRequestAsync(request, LicenseRequestConverters::getLicense, options,
100100
response -> new GetLicenseResponse(convertResponseToJson(response)), listener, emptySet());
101101
}
102102

@@ -107,7 +107,7 @@ public void getLicenseAsync(GetLicenseRequest request, RequestOptions options, A
107107
* @throws IOException in case there is a problem sending the request or parsing back the response
108108
*/
109109
public AcknowledgedResponse deleteLicense(DeleteLicenseRequest request, RequestOptions options) throws IOException {
110-
return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::deleteLicense, options,
110+
return restHighLevelClient.performRequestAndParseEntity(request, LicenseRequestConverters::deleteLicense, options,
111111
AcknowledgedResponse::fromXContent, emptySet());
112112
}
113113

@@ -117,7 +117,7 @@ public AcknowledgedResponse deleteLicense(DeleteLicenseRequest request, RequestO
117117
* @param listener the listener to be notified upon request completion
118118
*/
119119
public void deleteLicenseAsync(DeleteLicenseRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
120-
restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::deleteLicense, options,
120+
restHighLevelClient.performRequestAsyncAndParseEntity(request, LicenseRequestConverters::deleteLicense, options,
121121
AcknowledgedResponse::fromXContent, listener, emptySet());
122122
}
123123

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.client;
21+
22+
import org.apache.http.client.methods.HttpDelete;
23+
import org.apache.http.client.methods.HttpGet;
24+
import org.apache.http.client.methods.HttpPut;
25+
import org.elasticsearch.protocol.xpack.license.DeleteLicenseRequest;
26+
import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
27+
import org.elasticsearch.protocol.xpack.license.PutLicenseRequest;
28+
29+
public class LicenseRequestConverters {
30+
static Request putLicense(PutLicenseRequest putLicenseRequest) {
31+
String endpoint = new RequestConverters.EndpointBuilder()
32+
.addPathPartAsIs("_xpack")
33+
.addPathPartAsIs("license")
34+
.build();
35+
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
36+
RequestConverters.Params parameters = new RequestConverters.Params(request);
37+
parameters.withTimeout(putLicenseRequest.timeout());
38+
parameters.withMasterTimeout(putLicenseRequest.masterNodeTimeout());
39+
if (putLicenseRequest.isAcknowledge()) {
40+
parameters.putParam("acknowledge", "true");
41+
}
42+
request.setJsonEntity(putLicenseRequest.getLicenseDefinition());
43+
return request;
44+
}
45+
46+
static Request getLicense(GetLicenseRequest getLicenseRequest) {
47+
String endpoint = new RequestConverters.EndpointBuilder()
48+
.addPathPartAsIs("_xpack")
49+
.addPathPartAsIs("license")
50+
.build();
51+
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
52+
RequestConverters.Params parameters = new RequestConverters.Params(request);
53+
parameters.withLocal(getLicenseRequest.local());
54+
return request;
55+
}
56+
57+
static Request deleteLicense(DeleteLicenseRequest deleteLicenseRequest) {
58+
Request request = new Request(HttpDelete.METHOD_NAME, "/_xpack/license");
59+
RequestConverters.Params parameters = new RequestConverters.Params(request);
60+
parameters.withTimeout(deleteLicenseRequest.timeout());
61+
parameters.withMasterTimeout(deleteLicenseRequest.masterNodeTimeout());
62+
return request;
63+
}
64+
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.elasticsearch.client.ml.GetRecordsRequest;
3636
import org.elasticsearch.client.ml.OpenJobRequest;
3737
import org.elasticsearch.client.ml.PutJobRequest;
38+
import org.elasticsearch.client.ml.UpdateJobRequest;
3839
import org.elasticsearch.common.Strings;
3940

4041
import java.io.IOException;
@@ -146,6 +147,19 @@ static Request flushJob(FlushJobRequest flushJobRequest) throws IOException {
146147
return request;
147148
}
148149

150+
static Request updateJob(UpdateJobRequest updateJobRequest) throws IOException {
151+
String endpoint = new EndpointBuilder()
152+
.addPathPartAsIs("_xpack")
153+
.addPathPartAsIs("ml")
154+
.addPathPartAsIs("anomaly_detectors")
155+
.addPathPart(updateJobRequest.getJobUpdate().getJobId())
156+
.addPathPartAsIs("_update")
157+
.build();
158+
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
159+
request.setEntity(createEntity(updateJobRequest.getJobUpdate(), REQUEST_BODY_CONTENT_TYPE));
160+
return request;
161+
}
162+
149163
static Request getBuckets(GetBucketsRequest getBucketsRequest) throws IOException {
150164
String endpoint = new EndpointBuilder()
151165
.addPathPartAsIs("_xpack")

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.elasticsearch.client;
2020

2121
import org.elasticsearch.action.ActionListener;
22+
import org.elasticsearch.client.ml.UpdateJobRequest;
2223
import org.elasticsearch.client.ml.CloseJobRequest;
2324
import org.elasticsearch.client.ml.CloseJobResponse;
2425
import org.elasticsearch.client.ml.DeleteJobRequest;
@@ -319,6 +320,7 @@ public void closeJobAsync(CloseJobRequest request, RequestOptions options, Actio
319320
*
320321
* @param request The {@link FlushJobRequest} object enclosing the `jobId` and additional request options
321322
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
323+
* @throws IOException when there is a serialization issue sending the request or receiving the response
322324
*/
323325
public FlushJobResponse flushJob(FlushJobRequest request, RequestOptions options) throws IOException {
324326
return restHighLevelClient.performRequestAndParseEntity(request,
@@ -356,6 +358,38 @@ public void flushJobAsync(FlushJobRequest request, RequestOptions options, Actio
356358
Collections.emptySet());
357359
}
358360

361+
/**
362+
* Updates a Machine Learning {@link org.elasticsearch.client.ml.job.config.Job}
363+
*
364+
* @param request the {@link UpdateJobRequest} object enclosing the desired updates
365+
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
366+
* @return a PutJobResponse object containing the updated job object
367+
* @throws IOException when there is a serialization issue sending the request or receiving the response
368+
*/
369+
public PutJobResponse updateJob(UpdateJobRequest request, RequestOptions options) throws IOException {
370+
return restHighLevelClient.performRequestAndParseEntity(request,
371+
MLRequestConverters::updateJob,
372+
options,
373+
PutJobResponse::fromXContent,
374+
Collections.emptySet());
375+
}
376+
377+
/**
378+
* Updates a Machine Learning {@link org.elasticsearch.client.ml.job.config.Job} asynchronously
379+
*
380+
* @param request the {@link UpdateJobRequest} object enclosing the desired updates
381+
* @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
382+
* @param listener Listener to be notified upon request completion
383+
*/
384+
public void updateJobAsync(UpdateJobRequest request, RequestOptions options, ActionListener<PutJobResponse> listener) {
385+
restHighLevelClient.performRequestAsyncAndParseEntity(request,
386+
MLRequestConverters::updateJob,
387+
options,
388+
PutJobResponse::fromXContent,
389+
listener,
390+
Collections.emptySet());
391+
}
392+
359393
/**
360394
* Gets the buckets for a Machine Learning Job.
361395
* <p>

0 commit comments

Comments
 (0)