Skip to content

Commit d95ac27

Browse files
committed
Merge remote-tracking branch 'upstream/6.x' into index-lifecycle-6.x
2 parents d86ea32 + 6a2d768 commit d95ac27

File tree

417 files changed

+10727
-5493
lines changed

Some content is hidden

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

417 files changed

+10727
-5493
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ Contributing to the Elasticsearch codebase
9292

9393
**Repository:** [https://github.com/elastic/elasticsearch](https://github.com/elastic/elasticsearch)
9494

95-
JDK 10 is required to build Elasticsearch. You must have a JDK 10 installation
95+
JDK 11 is required to build Elasticsearch. You must have a JDK 11 installation
9696
with the environment variable `JAVA_HOME` referencing the path to Java home for
97-
your JDK 10 installation. By default, tests use the same runtime as `JAVA_HOME`.
97+
your JDK 11 installation. By default, tests use the same runtime as `JAVA_HOME`.
9898
However, since Elasticsearch supports JDK 8, the build supports compiling with
99-
JDK 10 and testing on a JDK 8 runtime; to do this, set `RUNTIME_JAVA_HOME`
99+
JDK 11 and testing on a JDK 8 runtime; to do this, set `RUNTIME_JAVA_HOME`
100100
pointing to the Java home of a JDK 8 installation. Note that this mechanism can
101101
be used to test against other JDKs as well, this is not only limited to JDK 8.
102102

103-
> Note: It is also required to have `JAVA7_HOME`, `JAVA8_HOME` and
104-
`JAVA10_HOME` available so that the tests can pass.
103+
> Note: It is also required to have `JAVA8_HOME`, `JAVA9_HOME`, and
104+
`JAVA10_HOME` are available so that the tests can pass.
105105

106106
> Warning: do not use `sdkman` for Java installations which do not have proper
107107
`jrunscript` for jdk distributions.

README.textile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,21 @@ h3. Indexing
4848
Let's try and index some twitter like information. First, let's index some tweets (the @twitter@ index will be created automatically):
4949

5050
<pre>
51-
curl -XPUT 'http://localhost:9200/twitter/doc/1?pretty' -H 'Content-Type: application/json' -d '
51+
curl -XPUT 'http://localhost:9200/twitter/_doc/1?pretty' -H 'Content-Type: application/json' -d '
5252
{
5353
"user": "kimchy",
5454
"post_date": "2009-11-15T13:12:00",
5555
"message": "Trying out Elasticsearch, so far so good?"
5656
}'
5757

58-
curl -XPUT 'http://localhost:9200/twitter/doc/2?pretty' -H 'Content-Type: application/json' -d '
58+
curl -XPUT 'http://localhost:9200/twitter/_doc/2?pretty' -H 'Content-Type: application/json' -d '
5959
{
6060
"user": "kimchy",
6161
"post_date": "2009-11-15T14:12:12",
6262
"message": "Another tweet, will it be indexed?"
6363
}'
6464

65-
curl -XPUT 'http://localhost:9200/twitter/doc/3?pretty' -H 'Content-Type: application/json' -d '
65+
curl -XPUT 'http://localhost:9200/twitter/_doc/3?pretty' -H 'Content-Type: application/json' -d '
6666
{
6767
"user": "elastic",
6868
"post_date": "2010-01-15T01:46:38",
@@ -73,9 +73,9 @@ curl -XPUT 'http://localhost:9200/twitter/doc/3?pretty' -H 'Content-Type: applic
7373
Now, let's see if the information was added by GETting it:
7474

7575
<pre>
76-
curl -XGET 'http://localhost:9200/twitter/doc/1?pretty=true'
77-
curl -XGET 'http://localhost:9200/twitter/doc/2?pretty=true'
78-
curl -XGET 'http://localhost:9200/twitter/doc/3?pretty=true'
76+
curl -XGET 'http://localhost:9200/twitter/_doc/1?pretty=true'
77+
curl -XGET 'http://localhost:9200/twitter/_doc/2?pretty=true'
78+
curl -XGET 'http://localhost:9200/twitter/_doc/3?pretty=true'
7979
</pre>
8080

8181
h3. Searching
@@ -133,14 +133,14 @@ Elasticsearch supports multiple indices. In the previous example we used an inde
133133
Another way to define our simple twitter system is to have a different index per user (note, though that each index has an overhead). Here is the indexing curl's in this case:
134134

135135
<pre>
136-
curl -XPUT 'http://localhost:9200/kimchy/doc/1?pretty' -H 'Content-Type: application/json' -d '
136+
curl -XPUT 'http://localhost:9200/kimchy/_doc/1?pretty' -H 'Content-Type: application/json' -d '
137137
{
138138
"user": "kimchy",
139139
"post_date": "2009-11-15T13:12:00",
140140
"message": "Trying out Elasticsearch, so far so good?"
141141
}'
142142

143-
curl -XPUT 'http://localhost:9200/kimchy/doc/2?pretty' -H 'Content-Type: application/json' -d '
143+
curl -XPUT 'http://localhost:9200/kimchy/_doc/2?pretty' -H 'Content-Type: application/json' -d '
144144
{
145145
"user": "kimchy",
146146
"post_date": "2009-11-15T14:12:12",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class BuildPlugin implements Plugin<Project> {
119119
File gradleJavaHome = Jvm.current().javaHome
120120

121121
final Map<Integer, String> javaVersions = [:]
122-
for (int version = 7; version <= Integer.parseInt(minimumCompilerVersion.majorVersion); version++) {
122+
for (int version = 8; version <= Integer.parseInt(minimumCompilerVersion.majorVersion); version++) {
123123
if(System.getenv(getJavaHomeEnvVarName(version.toString())) != null) {
124124
javaVersions.put(version, findJavaHome(version.toString()));
125125
}

buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/RestTestsFromSnippetsTask.groovy

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
193193
"$snippet: Use `js` instead of `${snippet.language}`.")
194194
}
195195
if (snippet.testSetup) {
196-
setup(snippet)
196+
testSetup(snippet)
197197
previousTest = snippet
198198
return
199199
}
@@ -258,20 +258,23 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
258258
current.println(" reason: $test.skip")
259259
}
260260
if (test.setup != null) {
261-
// Insert a setup defined outside of the docs
262-
for (String setupName : test.setup.split(',')) {
263-
String setup = setups[setupName]
264-
if (setup == null) {
265-
throw new InvalidUserDataException("Couldn't find setup "
266-
+ "for $test")
267-
}
268-
current.println(setup)
269-
}
261+
setup(test)
270262
}
271263

272264
body(test, false)
273265
}
274266

267+
private void setup(final Snippet snippet) {
268+
// insert a setup defined outside of the docs
269+
for (final String setupName : snippet.setup.split(',')) {
270+
final String setup = setups[setupName]
271+
if (setup == null) {
272+
throw new InvalidUserDataException("Couldn't find setup for $snippet")
273+
}
274+
current.println(setup)
275+
}
276+
}
277+
275278
private void response(Snippet response) {
276279
if (null == response.skip) {
277280
current.println(" - match: ")
@@ -338,14 +341,17 @@ public class RestTestsFromSnippetsTask extends SnippetsTask {
338341
}
339342
}
340343

341-
private void setup(Snippet setup) {
342-
if (lastDocsPath == setup.path) {
343-
throw new InvalidUserDataException("$setup: wasn't first")
344+
private void testSetup(Snippet snippet) {
345+
if (lastDocsPath == snippet.path) {
346+
throw new InvalidUserDataException("$snippet: wasn't first")
344347
}
345-
setupCurrent(setup)
348+
setupCurrent(snippet)
346349
current.println('---')
347350
current.println("setup:")
348-
body(setup, true)
351+
if (snippet.setup != null) {
352+
setup(snippet)
353+
}
354+
body(snippet, true)
349355
}
350356

351357
private void body(Snippet snippet, boolean inSetup) {

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/NodeInfo.groovy

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,7 @@ class NodeInfo {
177177
javaVersion = 8
178178
} else if (nodeVersion.onOrAfter("6.2.0") && nodeVersion.before("6.3.0")) {
179179
javaVersion = 9
180-
} else if (project.inFipsJvm && nodeVersion.onOrAfter("6.3.0") && nodeVersion.before("6.4.0")) {
181-
/*
182-
* Elasticsearch versions before 6.4.0 cannot be run in a FIPS-140 JVM. If we're running
183-
* bwc tests in a FIPS-140 JVM, ensure that the pre v6.4.0 nodes use a Java 10 JVM instead.
184-
*/
180+
} else if (nodeVersion.onOrAfter("6.3.0") && nodeVersion.before("6.5.0")) {
185181
javaVersion = 10
186182
}
187183

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
import org.elasticsearch.common.xcontent.XContentFactory;
3535
import org.elasticsearch.common.xcontent.XContentParser;
3636
import org.elasticsearch.common.xcontent.XContentType;
37-
import org.elasticsearch.protocol.xpack.license.DeleteLicenseRequest;
38-
import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
39-
import org.elasticsearch.protocol.xpack.license.GetLicenseResponse;
40-
import org.elasticsearch.protocol.xpack.license.PutLicenseRequest;
41-
import org.elasticsearch.protocol.xpack.license.PutLicenseResponse;
37+
import org.elasticsearch.client.license.DeleteLicenseRequest;
38+
import org.elasticsearch.client.license.GetLicenseRequest;
39+
import org.elasticsearch.client.license.GetLicenseResponse;
40+
import org.elasticsearch.client.license.PutLicenseRequest;
41+
import org.elasticsearch.client.license.PutLicenseResponse;
4242

4343
import java.io.IOException;
4444
import java.io.InputStream;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
import org.apache.http.client.methods.HttpPut;
2626
import org.elasticsearch.client.license.StartTrialRequest;
2727
import org.elasticsearch.client.license.StartBasicRequest;
28-
import org.elasticsearch.protocol.xpack.license.DeleteLicenseRequest;
29-
import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
30-
import org.elasticsearch.protocol.xpack.license.PutLicenseRequest;
28+
import org.elasticsearch.client.license.DeleteLicenseRequest;
29+
import org.elasticsearch.client.license.GetLicenseRequest;
30+
import org.elasticsearch.client.license.PutLicenseRequest;
3131

3232
public class LicenseRequestConverters {
3333
static Request putLicense(PutLicenseRequest putLicenseRequest) {
@@ -47,7 +47,7 @@ static Request getLicense(GetLicenseRequest getLicenseRequest) {
4747
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_xpack", "license").build();
4848
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
4949
RequestConverters.Params parameters = new RequestConverters.Params(request);
50-
parameters.withLocal(getLicenseRequest.local());
50+
parameters.withLocal(getLicenseRequest.isLocal());
5151
return request;
5252
}
5353

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ static Request getJob(GetJobRequest getJobRequest) {
8888
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
8989

9090
RequestConverters.Params params = new RequestConverters.Params(request);
91-
if (getJobRequest.isAllowNoJobs() != null) {
92-
params.putParam("allow_no_jobs", Boolean.toString(getJobRequest.isAllowNoJobs()));
91+
if (getJobRequest.getAllowNoJobs() != null) {
92+
params.putParam("allow_no_jobs", Boolean.toString(getJobRequest.getAllowNoJobs()));
9393
}
9494

9595
return request;
@@ -106,8 +106,8 @@ static Request getJobStats(GetJobStatsRequest getJobStatsRequest) {
106106
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
107107

108108
RequestConverters.Params params = new RequestConverters.Params(request);
109-
if (getJobStatsRequest.isAllowNoJobs() != null) {
110-
params.putParam("allow_no_jobs", Boolean.toString(getJobStatsRequest.isAllowNoJobs()));
109+
if (getJobStatsRequest.getAllowNoJobs() != null) {
110+
params.putParam("allow_no_jobs", Boolean.toString(getJobStatsRequest.getAllowNoJobs()));
111111
}
112112
return request;
113113
}
@@ -219,9 +219,9 @@ static Request getDatafeed(GetDatafeedRequest getDatafeedRequest) {
219219
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
220220

221221
RequestConverters.Params params = new RequestConverters.Params(request);
222-
if (getDatafeedRequest.isAllowNoDatafeeds() != null) {
222+
if (getDatafeedRequest.getAllowNoDatafeeds() != null) {
223223
params.putParam(GetDatafeedRequest.ALLOW_NO_DATAFEEDS.getPreferredName(),
224-
Boolean.toString(getDatafeedRequest.isAllowNoDatafeeds()));
224+
Boolean.toString(getDatafeedRequest.getAllowNoDatafeeds()));
225225
}
226226

227227
return request;
@@ -236,7 +236,9 @@ static Request deleteDatafeed(DeleteDatafeedRequest deleteDatafeedRequest) {
236236
.build();
237237
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
238238
RequestConverters.Params params = new RequestConverters.Params(request);
239-
params.putParam("force", Boolean.toString(deleteDatafeedRequest.isForce()));
239+
if (deleteDatafeedRequest.getForce() != null) {
240+
params.putParam("force", Boolean.toString(deleteDatafeedRequest.getForce()));
241+
}
240242
return request;
241243
}
242244

@@ -277,8 +279,8 @@ static Request getDatafeedStats(GetDatafeedStatsRequest getDatafeedStatsRequest)
277279
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
278280

279281
RequestConverters.Params params = new RequestConverters.Params(request);
280-
if (getDatafeedStatsRequest.isAllowNoDatafeeds() != null) {
281-
params.putParam("allow_no_datafeeds", Boolean.toString(getDatafeedStatsRequest.isAllowNoDatafeeds()));
282+
if (getDatafeedStatsRequest.getAllowNoDatafeeds() != null) {
283+
params.putParam("allow_no_datafeeds", Boolean.toString(getDatafeedStatsRequest.getAllowNoDatafeeds()));
282284
}
283285
return request;
284286
}
@@ -305,8 +307,8 @@ static Request deleteForecast(DeleteForecastRequest deleteForecastRequest) {
305307
.build();
306308
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
307309
RequestConverters.Params params = new RequestConverters.Params(request);
308-
if (deleteForecastRequest.isAllowNoForecasts() != null) {
309-
params.putParam("allow_no_forecasts", Boolean.toString(deleteForecastRequest.isAllowNoForecasts()));
310+
if (deleteForecastRequest.getAllowNoForecasts() != null) {
311+
params.putParam("allow_no_forecasts", Boolean.toString(deleteForecastRequest.getAllowNoForecasts()));
310312
}
311313
if (deleteForecastRequest.timeout() != null) {
312314
params.putParam("timeout", deleteForecastRequest.timeout().getStringRep());

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

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@
8181
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
8282
import org.elasticsearch.index.reindex.ReindexRequest;
8383
import org.elasticsearch.index.reindex.UpdateByQueryRequest;
84-
import org.elasticsearch.protocol.xpack.license.DeleteLicenseRequest;
85-
import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
86-
import org.elasticsearch.protocol.xpack.license.PutLicenseRequest;
8784
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
8885
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
8986
import org.elasticsearch.rest.action.search.RestSearchAction;
@@ -764,41 +761,6 @@ static Request explainLifecycle(ExplainLifecycleRequest explainLifecycleRequest)
764761
return request;
765762
}
766763

767-
static Request putLicense(PutLicenseRequest putLicenseRequest) {
768-
String endpoint = new EndpointBuilder()
769-
.addPathPartAsIs("_xpack")
770-
.addPathPartAsIs("license")
771-
.build();
772-
Request request = new Request(HttpPut.METHOD_NAME, endpoint);
773-
Params parameters = new Params(request);
774-
parameters.withTimeout(putLicenseRequest.timeout());
775-
parameters.withMasterTimeout(putLicenseRequest.masterNodeTimeout());
776-
if (putLicenseRequest.isAcknowledge()) {
777-
parameters.putParam("acknowledge", "true");
778-
}
779-
request.setJsonEntity(putLicenseRequest.getLicenseDefinition());
780-
return request;
781-
}
782-
783-
static Request getLicense(GetLicenseRequest getLicenseRequest) {
784-
String endpoint = new EndpointBuilder()
785-
.addPathPartAsIs("_xpack")
786-
.addPathPartAsIs("license")
787-
.build();
788-
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
789-
Params parameters = new Params(request);
790-
parameters.withLocal(getLicenseRequest.local());
791-
return request;
792-
}
793-
794-
static Request deleteLicense(DeleteLicenseRequest deleteLicenseRequest) {
795-
Request request = new Request(HttpDelete.METHOD_NAME, "/_xpack/license");
796-
Params parameters = new Params(request);
797-
parameters.withTimeout(deleteLicenseRequest.timeout());
798-
parameters.withMasterTimeout(deleteLicenseRequest.masterNodeTimeout());
799-
return request;
800-
}
801-
802764
static HttpEntity createEntity(ToXContent toXContent, XContentType xContentType) throws IOException {
803765
BytesRef source = XContentHelper.toXContent(toXContent, xContentType, false).toBytesRef();
804766
return new ByteArrayEntity(source.bytes, source.offset, source.length, createContentType(xContentType));
@@ -1218,3 +1180,4 @@ private static String encodePart(String pathPart) {
12181180
}
12191181
}
12201182
}
1183+

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import org.elasticsearch.action.ActionListener;
2323
import org.elasticsearch.client.rollup.GetRollupJobRequest;
2424
import org.elasticsearch.client.rollup.GetRollupJobResponse;
25+
import org.elasticsearch.client.rollup.GetRollupCapsRequest;
26+
import org.elasticsearch.client.rollup.GetRollupCapsResponse;
2527
import org.elasticsearch.client.rollup.PutRollupJobRequest;
2628
import org.elasticsearch.client.rollup.PutRollupJobResponse;
2729

@@ -101,11 +103,48 @@ public GetRollupJobResponse getRollupJob(GetRollupJobRequest request, RequestOpt
101103
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
102104
* @param listener the listener to be notified upon request completion
103105
*/
106+
107+
104108
public void getRollupJobAsync(GetRollupJobRequest request, RequestOptions options, ActionListener<GetRollupJobResponse> listener) {
105109
restHighLevelClient.performRequestAsyncAndParseEntity(request,
106110
RollupRequestConverters::getJob,
107111
options,
108112
GetRollupJobResponse::fromXContent,
109113
listener, Collections.emptySet());
110114
}
115+
116+
/**
117+
* Get the Rollup Capabilities of a target (non-rollup) index or pattern
118+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-rollup-caps.html">
119+
* the docs</a> for more.
120+
* @param request the request
121+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
122+
* @return the response
123+
* @throws IOException in case there is a problem sending the request or parsing back the response
124+
*/
125+
public GetRollupCapsResponse getRollupCapabilities(GetRollupCapsRequest request, RequestOptions options) throws IOException {
126+
return restHighLevelClient.performRequestAndParseEntity(request,
127+
RollupRequestConverters::getRollupCaps,
128+
options,
129+
GetRollupCapsResponse::fromXContent,
130+
Collections.emptySet());
131+
}
132+
133+
/**
134+
* Asynchronously Get the Rollup Capabilities of a target (non-rollup) index or pattern
135+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/rollup-put-job.html">
136+
* the docs</a> for more.
137+
* @param request the request
138+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
139+
* @param listener the listener to be notified upon request completion
140+
*/
141+
public void getRollupCapabilitiesAsync(GetRollupCapsRequest request, RequestOptions options,
142+
ActionListener<GetRollupCapsResponse> listener) {
143+
restHighLevelClient.performRequestAsyncAndParseEntity(request,
144+
RollupRequestConverters::getRollupCaps,
145+
options,
146+
GetRollupCapsResponse::fromXContent,
147+
listener,
148+
Collections.emptySet());
149+
}
111150
}

0 commit comments

Comments
 (0)