Skip to content

Commit b56fede

Browse files
committed
Merge remote-tracking branch 'es/master' into ccr
* es/master: (27 commits) [Docs] Add rank_eval size parameter k (#29218) [DOCS] Remove ignore_z_value parameter link Docs: Update docs/index_.asciidoc (#29172) Docs: Link C++ client lib elasticlient (#28949) [DOCS] Unregister repository instead of deleting it (#29206) Docs: HighLevelRestClient#multiSearch (#29144) Add Z value support to geo_shape Remove type casts in logging in server component (#28807) Change BroadcastResponse from ToXContentFragment to ToXContentObject (#28878) REST : Split `RestUpgradeAction` into two actions (#29124) Add error file docs to important settings Add note to low-level client docs for DNS caching (#29213) Harden periodically check to avoid endless flush loop (#29125) Remove deprecated options for query_string (#29203) REST high-level client: add force merge API (#28896) Remove license information from README.textile (#29198) Decouple more classes from XContentBuilder and make builder strict (#29197) [Docs] Fix missing closing block in cluster/misc.asciidoc RankEvalRequest should implement IndicesRequest (#29188) Use EnumMap in ClusterBlocks (#29112) ...
2 parents 5498be7 + afe95a7 commit b56fede

File tree

228 files changed

+3080
-1347
lines changed

Some content is hidden

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

228 files changed

+3080
-1347
lines changed

README.textile

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ Elasticsearch is a distributed RESTful search engine built for the cloud. Featur
2727
** All the power of Lucene easily exposed through simple configuration / plugins.
2828
* Per operation consistency
2929
** Single document level operations are atomic, consistent, isolated and durable.
30-
* Open Source under the Apache License, version 2 ("ALv2")
3130

3231
h2. Getting Started
3332

@@ -217,23 +216,3 @@ Elasticsearch (1.x), it is required to perform a full cluster restart. Please
217216
see the "setup reference":
218217
https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-upgrade.html
219218
for more details on the upgrade process.
220-
221-
h1. License
222-
223-
<pre>
224-
This software is licensed under the Apache License, version 2 ("ALv2"), quoted below.
225-
226-
Copyright 2009-2016 Elasticsearch <https://www.elastic.co>
227-
228-
Licensed under the Apache License, Version 2.0 (the "License"); you may not
229-
use this file except in compliance with the License. You may obtain a copy of
230-
the License at
231-
232-
http://www.apache.org/licenses/LICENSE-2.0
233-
234-
Unless required by applicable law or agreed to in writing, software
235-
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
236-
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
237-
License for the specific language governing permissions and limitations under
238-
the License.
239-
</pre>

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,18 @@ class BuildPlugin implements Plugin<Project> {
475475
}
476476

477477
static void configureJavadoc(Project project) {
478-
project.tasks.withType(Javadoc) {
479-
executable = new File(project.compilerJavaHome, 'bin/javadoc')
478+
// remove compiled classes from the Javadoc classpath: http://mail.openjdk.java.net/pipermail/javadoc-dev/2018-January/000400.html
479+
final List<File> classes = new ArrayList<>()
480+
project.tasks.withType(JavaCompile) { javaCompile ->
481+
classes.add(javaCompile.destinationDir)
480482
}
481-
configureJavadocJar(project)
482-
if (project.compilerJavaVersion == JavaVersion.VERSION_1_10) {
483-
project.tasks.withType(Javadoc) { it.enabled = false }
484-
project.tasks.getByName('javadocJar').each { it.enabled = false }
483+
project.tasks.withType(Javadoc) { javadoc ->
484+
javadoc.executable = new File(project.compilerJavaHome, 'bin/javadoc')
485+
javadoc.classpath = javadoc.getClasspath().filter { f ->
486+
return classes.contains(f) == false
487+
}
485488
}
489+
configureJavadocJar(project)
486490
}
487491

488492
/** Adds a javadocJar task to generate a jar containing javadocs. */

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@
3434
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;
3535
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
3636
import org.elasticsearch.action.admin.indices.flush.FlushResponse;
37+
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest;
38+
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse;
3739
import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
3840
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
3941
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
4042
import org.elasticsearch.action.admin.indices.open.OpenIndexRequest;
4143
import org.elasticsearch.action.admin.indices.open.OpenIndexResponse;
42-
import org.elasticsearch.action.admin.indices.rollover.RolloverRequest;
43-
import org.elasticsearch.action.admin.indices.rollover.RolloverResponse;
4444
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
4545
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
46+
import org.elasticsearch.action.admin.indices.rollover.RolloverRequest;
47+
import org.elasticsearch.action.admin.indices.rollover.RolloverResponse;
4648
import org.elasticsearch.action.admin.indices.shrink.ResizeRequest;
4749
import org.elasticsearch.action.admin.indices.shrink.ResizeResponse;
4850

@@ -261,6 +263,28 @@ public void flushAsync(FlushRequest flushRequest, ActionListener<FlushResponse>
261263
listener, emptySet(), headers);
262264
}
263265

266+
/**
267+
* Force merge one or more indices using the Force Merge API
268+
* <p>
269+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html">
270+
* Force Merge API on elastic.co</a>
271+
*/
272+
public ForceMergeResponse forceMerge(ForceMergeRequest forceMergeRequest, Header... headers) throws IOException {
273+
return restHighLevelClient.performRequestAndParseEntity(forceMergeRequest, Request::forceMerge, ForceMergeResponse::fromXContent,
274+
emptySet(), headers);
275+
}
276+
277+
/**
278+
* Asynchronously force merge one or more indices using the Force Merge API
279+
* <p>
280+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html">
281+
* Force Merge API on elastic.co</a>
282+
*/
283+
public void forceMergeAsync(ForceMergeRequest forceMergeRequest, ActionListener<ForceMergeResponse> listener, Header... headers) {
284+
restHighLevelClient.performRequestAsyncAndParseEntity(forceMergeRequest, Request::forceMerge, ForceMergeResponse::fromXContent,
285+
listener, emptySet(), headers);
286+
}
287+
264288
/**
265289
* Clears the cache of one or more indices using the Clear Cache API
266290
* <p>

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
3838
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
3939
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
40+
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest;
4041
import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
4142
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
4243
import org.elasticsearch.action.admin.indices.open.OpenIndexRequest;
@@ -233,6 +234,17 @@ static Request flush(FlushRequest flushRequest) {
233234
return new Request(HttpPost.METHOD_NAME, endpoint, parameters.getParams(), null);
234235
}
235236

237+
static Request forceMerge(ForceMergeRequest forceMergeRequest) {
238+
String[] indices = forceMergeRequest.indices() == null ? Strings.EMPTY_ARRAY : forceMergeRequest.indices();
239+
String endpoint = endpoint(indices, "_forcemerge");
240+
Params parameters = Params.builder();
241+
parameters.withIndicesOptions(forceMergeRequest.indicesOptions());
242+
parameters.putParam("max_num_segments", Integer.toString(forceMergeRequest.maxNumSegments()));
243+
parameters.putParam("only_expunge_deletes", Boolean.toString(forceMergeRequest.onlyExpungeDeletes()));
244+
parameters.putParam("flush", Boolean.toString(forceMergeRequest.flush()));
245+
return new Request(HttpPost.METHOD_NAME, endpoint, parameters.getParams(), null);
246+
}
247+
236248
static Request clearCache(ClearIndicesCacheRequest clearIndicesCacheRequest) {
237249
String[] indices = clearIndicesCacheRequest.indices() == null ? Strings.EMPTY_ARRAY :clearIndicesCacheRequest.indices();
238250
String endpoint = endpoint(indices, "_cache/clear");
@@ -531,7 +543,7 @@ static Request existsAlias(GetAliasesRequest getAliasesRequest) {
531543
}
532544

533545
static Request rankEval(RankEvalRequest rankEvalRequest) throws IOException {
534-
String endpoint = endpoint(rankEvalRequest.getIndices(), Strings.EMPTY_ARRAY, "_rank_eval");
546+
String endpoint = endpoint(rankEvalRequest.indices(), Strings.EMPTY_ARRAY, "_rank_eval");
535547
HttpEntity entity = createEntity(rankEvalRequest.getRankEvalSpec(), REQUEST_BODY_CONTENT_TYPE);
536548
return new Request(HttpGet.METHOD_NAME, endpoint, Collections.emptyMap(), entity);
537549
}

client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;
3939
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
4040
import org.elasticsearch.action.admin.indices.flush.FlushResponse;
41+
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest;
42+
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse;
4143
import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
4244
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
4345
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
@@ -467,6 +469,32 @@ public void testClearCache() throws IOException {
467469
}
468470
}
469471

472+
public void testForceMerge() throws IOException {
473+
{
474+
String index = "index";
475+
Settings settings = Settings.builder()
476+
.put("number_of_shards", 1)
477+
.put("number_of_replicas", 0)
478+
.build();
479+
createIndex(index, settings);
480+
ForceMergeRequest forceMergeRequest = new ForceMergeRequest(index);
481+
ForceMergeResponse forceMergeResponse =
482+
execute(forceMergeRequest, highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync);
483+
assertThat(forceMergeResponse.getTotalShards(), equalTo(1));
484+
assertThat(forceMergeResponse.getSuccessfulShards(), equalTo(1));
485+
assertThat(forceMergeResponse.getFailedShards(), equalTo(0));
486+
assertThat(forceMergeResponse.getShardFailures(), equalTo(BroadcastResponse.EMPTY));
487+
}
488+
{
489+
String nonExistentIndex = "non_existent_index";
490+
assertFalse(indexExists(nonExistentIndex));
491+
ForceMergeRequest forceMergeRequest = new ForceMergeRequest(nonExistentIndex);
492+
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
493+
() -> execute(forceMergeRequest, highLevelClient().indices()::forceMerge, highLevelClient().indices()::forceMergeAsync));
494+
assertEquals(RestStatus.NOT_FOUND, exception.status());
495+
}
496+
}
497+
470498
public void testExistsAlias() throws IOException {
471499
GetAliasesRequest getAliasesRequest = new GetAliasesRequest("alias");
472500
assertFalse(execute(getAliasesRequest, highLevelClient().indices()::existsAlias, highLevelClient().indices()::existsAliasAsync));

client/rest-high-level/src/test/java/org/elasticsearch/client/RequestTests.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
4141
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
4242
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
43+
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest;
4344
import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
4445
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
4546
import org.elasticsearch.action.admin.indices.open.OpenIndexRequest;
@@ -621,6 +622,43 @@ public void testFlush() {
621622
assertThat(request.getMethod(), equalTo(HttpPost.METHOD_NAME));
622623
}
623624

625+
public void testForceMerge() {
626+
String[] indices = randomBoolean() ? null : randomIndicesNames(0, 5);
627+
ForceMergeRequest forceMergeRequest;
628+
if (randomBoolean()) {
629+
forceMergeRequest = new ForceMergeRequest(indices);
630+
} else {
631+
forceMergeRequest = new ForceMergeRequest();
632+
forceMergeRequest.indices(indices);
633+
}
634+
635+
Map<String, String> expectedParams = new HashMap<>();
636+
setRandomIndicesOptions(forceMergeRequest::indicesOptions, forceMergeRequest::indicesOptions, expectedParams);
637+
if (randomBoolean()) {
638+
forceMergeRequest.maxNumSegments(randomInt());
639+
}
640+
expectedParams.put("max_num_segments", Integer.toString(forceMergeRequest.maxNumSegments()));
641+
if (randomBoolean()) {
642+
forceMergeRequest.onlyExpungeDeletes(randomBoolean());
643+
}
644+
expectedParams.put("only_expunge_deletes", Boolean.toString(forceMergeRequest.onlyExpungeDeletes()));
645+
if (randomBoolean()) {
646+
forceMergeRequest.flush(randomBoolean());
647+
}
648+
expectedParams.put("flush", Boolean.toString(forceMergeRequest.flush()));
649+
650+
Request request = Request.forceMerge(forceMergeRequest);
651+
StringJoiner endpoint = new StringJoiner("/", "/", "");
652+
if (indices != null && indices.length > 0) {
653+
endpoint.add(String.join(",", indices));
654+
}
655+
endpoint.add("_forcemerge");
656+
assertThat(request.getEndpoint(), equalTo(endpoint.toString()));
657+
assertThat(request.getParameters(), equalTo(expectedParams));
658+
assertThat(request.getEntity(), nullValue());
659+
assertThat(request.getMethod(), equalTo(HttpPost.METHOD_NAME));
660+
}
661+
624662
public void testClearCache() {
625663
String[] indices = randomBoolean() ? null : randomIndicesNames(0, 5);
626664
ClearIndicesCacheRequest clearIndicesCacheRequest;

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;
3838
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
3939
import org.elasticsearch.action.admin.indices.flush.FlushResponse;
40+
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest;
41+
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse;
4042
import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
4143
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
4244
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
@@ -771,6 +773,79 @@ public void onFailure(Exception e) {
771773
}
772774
}
773775

776+
public void testForceMergeIndex() throws Exception {
777+
RestHighLevelClient client = highLevelClient();
778+
779+
{
780+
createIndex("index", Settings.EMPTY);
781+
}
782+
783+
{
784+
// tag::force-merge-request
785+
ForceMergeRequest request = new ForceMergeRequest("index1"); // <1>
786+
ForceMergeRequest requestMultiple = new ForceMergeRequest("index1", "index2"); // <2>
787+
ForceMergeRequest requestAll = new ForceMergeRequest(); // <3>
788+
// end::force-merge-request
789+
790+
// tag::force-merge-request-indicesOptions
791+
request.indicesOptions(IndicesOptions.lenientExpandOpen()); // <1>
792+
// end::force-merge-request-indicesOptions
793+
794+
// tag::force-merge-request-segments-num
795+
request.maxNumSegments(1); // <1>
796+
// end::force-merge-request-segments-num
797+
798+
// tag::force-merge-request-only-expunge-deletes
799+
request.onlyExpungeDeletes(true); // <1>
800+
// end::force-merge-request-only-expunge-deletes
801+
802+
// tag::force-merge-request-flush
803+
request.flush(true); // <1>
804+
// end::force-merge-request-flush
805+
806+
// tag::force-merge-execute
807+
ForceMergeResponse forceMergeResponse = client.indices().forceMerge(request);
808+
// end::force-merge-execute
809+
810+
// tag::force-merge-response
811+
int totalShards = forceMergeResponse.getTotalShards(); // <1>
812+
int successfulShards = forceMergeResponse.getSuccessfulShards(); // <2>
813+
int failedShards = forceMergeResponse.getFailedShards(); // <3>
814+
DefaultShardOperationFailedException[] failures = forceMergeResponse.getShardFailures(); // <4>
815+
// end::force-merge-response
816+
817+
// tag::force-merge-execute-listener
818+
ActionListener<ForceMergeResponse> listener = new ActionListener<ForceMergeResponse>() {
819+
@Override
820+
public void onResponse(ForceMergeResponse forceMergeResponse) {
821+
// <1>
822+
}
823+
824+
@Override
825+
public void onFailure(Exception e) {
826+
// <2>
827+
}
828+
};
829+
// end::force-merge-execute-listener
830+
831+
// tag::force-merge-execute-async
832+
client.indices().forceMergeAsync(request, listener); // <1>
833+
// end::force-merge-execute-async
834+
}
835+
{
836+
// tag::force-merge-notfound
837+
try {
838+
ForceMergeRequest request = new ForceMergeRequest("does_not_exist");
839+
client.indices().forceMerge(request);
840+
} catch (ElasticsearchException exception) {
841+
if (exception.status() == RestStatus.NOT_FOUND) {
842+
// <1>
843+
}
844+
}
845+
// end::force-merge-notfound
846+
}
847+
}
848+
774849
public void testClearCache() throws Exception {
775850
RestHighLevelClient client = highLevelClient();
776851

@@ -855,7 +930,6 @@ public void onFailure(Exception e) {
855930
}
856931
}
857932

858-
859933
public void testCloseIndex() throws Exception {
860934
RestHighLevelClient client = highLevelClient();
861935

0 commit comments

Comments
 (0)