Removing _reload_search_analyzers related changes since the related x-pack support is removed (#48)
Signed-off-by: Peter Nied <petern@amazon.com>
This commit is contained in:
parent
eb49365800
commit
f2a90be773
|
@ -72,8 +72,6 @@ import org.elasticsearch.client.indices.IndexTemplatesExistRequest;
|
|||
import org.elasticsearch.client.indices.PutComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutMappingRequest;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersRequest;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersResponse;
|
||||
import org.elasticsearch.client.indices.ResizeRequest;
|
||||
import org.elasticsearch.client.indices.ResizeResponse;
|
||||
import org.elasticsearch.client.indices.SimulateIndexTemplateRequest;
|
||||
|
@ -1837,30 +1835,6 @@ public final class IndicesClient {
|
|||
options, AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronously calls the _reload_search_analyzers API
|
||||
*
|
||||
* @param request the request
|
||||
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
|
||||
*/
|
||||
public ReloadAnalyzersResponse reloadAnalyzers(ReloadAnalyzersRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity(request, IndicesRequestConverters::reloadAnalyzers, options,
|
||||
ReloadAnalyzersResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously calls the _reload_search_analyzers API
|
||||
* @param request the request
|
||||
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
|
||||
* @param listener the listener to be notified upon request completion
|
||||
* @return cancellable that may be used to cancel the request
|
||||
*/
|
||||
public Cancellable reloadAnalyzersAsync(ReloadAnalyzersRequest request, RequestOptions options,
|
||||
ActionListener<ReloadAnalyzersResponse> listener) {
|
||||
return restHighLevelClient.performRequestAsyncAndParseEntity(request, IndicesRequestConverters::reloadAnalyzers, options,
|
||||
ReloadAnalyzersResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronously calls the delete alias api
|
||||
* @param request the request
|
||||
|
|
|
@ -58,7 +58,6 @@ import org.elasticsearch.client.indices.IndexTemplatesExistRequest;
|
|||
import org.elasticsearch.client.indices.PutIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutMappingRequest;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersRequest;
|
||||
import org.elasticsearch.client.indices.ResizeRequest;
|
||||
import org.elasticsearch.client.indices.SimulateIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.UnfreezeIndexRequest;
|
||||
|
@ -806,15 +805,6 @@ final class IndicesRequestConverters {
|
|||
return request;
|
||||
}
|
||||
|
||||
static Request reloadAnalyzers(ReloadAnalyzersRequest reloadAnalyzersRequest) {
|
||||
String endpoint = RequestConverters.endpoint(reloadAnalyzersRequest.getIndices(), "_reload_search_analyzers");
|
||||
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
|
||||
RequestConverters.Params parameters = new RequestConverters.Params();
|
||||
parameters.withIndicesOptions(reloadAnalyzersRequest.indicesOptions());
|
||||
request.addParameters(parameters.asMap());
|
||||
return request;
|
||||
}
|
||||
|
||||
static Request deleteAlias(DeleteAliasRequest deleteAliasRequest) {
|
||||
String endpoint = new RequestConverters.EndpointBuilder()
|
||||
.addPathPart(deleteAliasRequest.getIndex())
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.elasticsearch.client.indices;
|
||||
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.client.Validatable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Request for the _reload_search_analyzers API
|
||||
*/
|
||||
public final class ReloadAnalyzersRequest implements Validatable {
|
||||
|
||||
private final String[] indices;
|
||||
private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen();
|
||||
|
||||
/**
|
||||
* Creates a new reload analyzers request
|
||||
* @param indices the index for which to reload analyzers
|
||||
*/
|
||||
public ReloadAnalyzersRequest(String... indices) {
|
||||
this.indices = Objects.requireNonNull(indices);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the indices
|
||||
*/
|
||||
public String[] getIndices() {
|
||||
return indices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies what type of requested indices to ignore and how to deal with wildcard expressions.
|
||||
* For example indices that don't exist.
|
||||
*
|
||||
* @return the current behaviour when it comes to index names and wildcard indices expressions
|
||||
*/
|
||||
public IndicesOptions indicesOptions() {
|
||||
return indicesOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies what type of requested indices to ignore and how to deal with wildcard expressions.
|
||||
* For example indices that don't exist.
|
||||
*
|
||||
* @param indicesOptions the desired behaviour regarding indices to ignore and wildcard indices expressions
|
||||
*/
|
||||
public void setIndicesOptions(IndicesOptions indicesOptions) {
|
||||
this.indicesOptions = indicesOptions;
|
||||
}
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.elasticsearch.client.indices;
|
||||
|
||||
import org.elasticsearch.client.core.BroadcastResponse;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
|
||||
|
||||
/**
|
||||
* The response object that will be returned when reloading analyzers
|
||||
*/
|
||||
public class ReloadAnalyzersResponse extends BroadcastResponse {
|
||||
|
||||
private final Map<String, ReloadDetails> reloadDetails;
|
||||
|
||||
ReloadAnalyzersResponse(final Shards shards, Map<String, ReloadDetails> reloadDetails) {
|
||||
super(shards);
|
||||
this.reloadDetails = reloadDetails;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
private static final ConstructingObjectParser<ReloadAnalyzersResponse, Void> PARSER = new ConstructingObjectParser<>("reload_analyzer",
|
||||
true, arg -> {
|
||||
Shards shards = (Shards) arg[0];
|
||||
List<Tuple<String, ReloadDetails>> results = (List<Tuple<String, ReloadDetails>>) arg[1];
|
||||
Map<String, ReloadDetails> reloadDetails = new HashMap<>();
|
||||
for (Tuple<String, ReloadDetails> result : results) {
|
||||
reloadDetails.put(result.v1(), result.v2());
|
||||
}
|
||||
return new ReloadAnalyzersResponse(shards, reloadDetails);
|
||||
});
|
||||
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
private static final ConstructingObjectParser<Tuple<String, ReloadDetails>, Void> ENTRY_PARSER = new ConstructingObjectParser<>(
|
||||
"reload_analyzer.entry", true, arg -> {
|
||||
String index = (String) arg[0];
|
||||
Set<String> nodeIds = new HashSet<>((List<String>) arg[1]);
|
||||
Set<String> analyzers = new HashSet<>((List<String>) arg[2]);
|
||||
return new Tuple<>(index, new ReloadDetails(index, nodeIds, analyzers));
|
||||
});
|
||||
|
||||
static {
|
||||
declareShardsField(PARSER);
|
||||
PARSER.declareObjectArray(constructorArg(), ENTRY_PARSER, new ParseField("reload_details"));
|
||||
ENTRY_PARSER.declareString(constructorArg(), new ParseField("index"));
|
||||
ENTRY_PARSER.declareStringArray(constructorArg(), new ParseField("reloaded_node_ids"));
|
||||
ENTRY_PARSER.declareStringArray(constructorArg(), new ParseField("reloaded_analyzers"));
|
||||
}
|
||||
|
||||
public static ReloadAnalyzersResponse fromXContent(XContentParser parser) {
|
||||
return PARSER.apply(parser, null);
|
||||
}
|
||||
|
||||
public Map<String, ReloadDetails> getReloadedDetails() {
|
||||
return reloadDetails;
|
||||
}
|
||||
|
||||
public static class ReloadDetails {
|
||||
|
||||
private final String indexName;
|
||||
private final Set<String> reloadedIndicesNodes;
|
||||
private final Set<String> reloadedAnalyzers;
|
||||
|
||||
public ReloadDetails(String name, Set<String> reloadedIndicesNodes, Set<String> reloadedAnalyzers) {
|
||||
this.indexName = name;
|
||||
this.reloadedIndicesNodes = reloadedIndicesNodes;
|
||||
this.reloadedAnalyzers = reloadedAnalyzers;
|
||||
}
|
||||
|
||||
public String getIndexName() {
|
||||
return indexName;
|
||||
}
|
||||
|
||||
public Set<String> getReloadedIndicesNodes() {
|
||||
return reloadedIndicesNodes;
|
||||
}
|
||||
|
||||
public Set<String> getReloadedAnalyzers() {
|
||||
return reloadedAnalyzers;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -88,8 +88,6 @@ import org.elasticsearch.client.indices.IndexTemplatesExistRequest;
|
|||
import org.elasticsearch.client.indices.PutComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutMappingRequest;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersRequest;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersResponse;
|
||||
import org.elasticsearch.client.indices.SimulateIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.SimulateIndexTemplateResponse;
|
||||
import org.elasticsearch.client.indices.UnfreezeIndexRequest;
|
||||
|
@ -1996,16 +1994,6 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase {
|
|||
assertTrue(unfreeze.isAcknowledged());
|
||||
}
|
||||
|
||||
public void testReloadAnalyzer() throws IOException {
|
||||
createIndex("test", Settings.EMPTY);
|
||||
RestHighLevelClient client = highLevelClient();
|
||||
|
||||
ReloadAnalyzersResponse reloadResponse = execute(new ReloadAnalyzersRequest("test"), client.indices()::reloadAnalyzers,
|
||||
client.indices()::reloadAnalyzersAsync);
|
||||
assertNotNull(reloadResponse.shards());
|
||||
assertTrue(reloadResponse.getReloadedDetails().containsKey("test"));
|
||||
}
|
||||
|
||||
public void testDeleteAlias() throws IOException {
|
||||
String index = "test";
|
||||
createIndex(index, Settings.EMPTY);
|
||||
|
|
|
@ -57,7 +57,6 @@ import org.elasticsearch.client.indices.IndexTemplatesExistRequest;
|
|||
import org.elasticsearch.client.indices.PutIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutMappingRequest;
|
||||
import org.elasticsearch.client.indices.RandomCreateIndexGenerator;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersRequest;
|
||||
import org.elasticsearch.client.indices.ResizeRequest;
|
||||
import org.elasticsearch.client.indices.rollover.RolloverRequest;
|
||||
import org.elasticsearch.common.CheckedFunction;
|
||||
|
@ -1236,23 +1235,6 @@ public class IndicesRequestConvertersTests extends ESTestCase {
|
|||
Assert.assertThat(request.getEntity(), nullValue());
|
||||
}
|
||||
|
||||
public void testReloadAnalyzers() {
|
||||
String[] indices = RequestConvertersTests.randomIndicesNames(1, 5);
|
||||
StringJoiner endpoint = new StringJoiner("/", "/", "");
|
||||
if (CollectionUtils.isEmpty(indices) == false) {
|
||||
endpoint.add(String.join(",", indices));
|
||||
}
|
||||
ReloadAnalyzersRequest reloadRequest = new ReloadAnalyzersRequest(indices);
|
||||
Map<String, String> expectedParams = new HashMap<>();
|
||||
RequestConvertersTests.setRandomIndicesOptions(reloadRequest::setIndicesOptions, reloadRequest::indicesOptions,
|
||||
expectedParams);
|
||||
Request request = IndicesRequestConverters.reloadAnalyzers(reloadRequest);
|
||||
Assert.assertThat(request.getMethod(), equalTo(HttpPost.METHOD_NAME));
|
||||
Assert.assertThat(request.getEndpoint(), equalTo(endpoint + "/_reload_search_analyzers"));
|
||||
Assert.assertThat(request.getParameters(), equalTo(expectedParams));
|
||||
Assert.assertThat(request.getEntity(), nullValue());
|
||||
}
|
||||
|
||||
public void testDeleteAlias() {
|
||||
DeleteAliasRequest deleteAliasRequest = new DeleteAliasRequest(randomAlphaOfLength(4), randomAlphaOfLength(4));
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@ import org.elasticsearch.client.GetAliasesResponse;
|
|||
import org.elasticsearch.client.RequestOptions;
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
import org.elasticsearch.client.SyncedFlushResponse;
|
||||
import org.elasticsearch.client.core.BroadcastResponse.Shards;
|
||||
import org.elasticsearch.client.core.ShardsAcknowledgedResponse;
|
||||
import org.elasticsearch.client.indices.AnalyzeRequest;
|
||||
import org.elasticsearch.client.indices.AnalyzeResponse;
|
||||
|
@ -85,9 +84,6 @@ import org.elasticsearch.client.indices.PutComponentTemplateRequest;
|
|||
import org.elasticsearch.client.indices.PutIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutComposableIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.PutMappingRequest;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersRequest;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersResponse;
|
||||
import org.elasticsearch.client.indices.ReloadAnalyzersResponse.ReloadDetails;
|
||||
import org.elasticsearch.client.indices.SimulateIndexTemplateRequest;
|
||||
import org.elasticsearch.client.indices.SimulateIndexTemplateResponse;
|
||||
import org.elasticsearch.client.indices.UnfreezeIndexRequest;
|
||||
|
@ -3172,79 +3168,6 @@ public class IndicesClientDocumentationIT extends ESRestHighLevelClientTestCase
|
|||
assertTrue(latch.await(30L, TimeUnit.SECONDS));
|
||||
}
|
||||
|
||||
public void testReloadSearchAnalyzers() throws Exception {
|
||||
RestHighLevelClient client = highLevelClient();
|
||||
{
|
||||
CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("index"), RequestOptions.DEFAULT);
|
||||
assertTrue(createIndexResponse.isAcknowledged());
|
||||
}
|
||||
|
||||
{
|
||||
// tag::reload-analyzers-request
|
||||
ReloadAnalyzersRequest request = new ReloadAnalyzersRequest("index"); // <1>
|
||||
// end::reload-analyzers-request
|
||||
|
||||
// tag::reload-analyzers-request-indicesOptions
|
||||
request.setIndicesOptions(IndicesOptions.strictExpandOpen()); // <1>
|
||||
// end::reload-analyzers-request-indicesOptions
|
||||
|
||||
// tag::reload-analyzers-execute
|
||||
ReloadAnalyzersResponse reloadResponse = client.indices().reloadAnalyzers(request, RequestOptions.DEFAULT);
|
||||
// end::reload-analyzers-execute
|
||||
|
||||
// tag::reload-analyzers-response
|
||||
Shards shards = reloadResponse.shards(); // <1>
|
||||
Map<String, ReloadDetails> reloadDetails = reloadResponse.getReloadedDetails(); // <2>
|
||||
ReloadDetails details = reloadDetails.get("index"); // <3>
|
||||
String indexName = details.getIndexName(); // <4>
|
||||
Set<String> indicesNodes = details.getReloadedIndicesNodes(); // <5>
|
||||
Set<String> analyzers = details.getReloadedAnalyzers(); // <6>
|
||||
// end::reload-analyzers-response
|
||||
assertNotNull(shards);
|
||||
assertEquals("index", indexName);
|
||||
assertEquals(1, indicesNodes.size());
|
||||
assertEquals(0, analyzers.size());
|
||||
|
||||
// tag::reload-analyzers-execute-listener
|
||||
ActionListener<ReloadAnalyzersResponse> listener =
|
||||
new ActionListener<ReloadAnalyzersResponse>() {
|
||||
@Override
|
||||
public void onResponse(ReloadAnalyzersResponse reloadResponse) {
|
||||
// <1>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
// <2>
|
||||
}
|
||||
};
|
||||
// end::reload-analyzers-execute-listener
|
||||
|
||||
// Replace the empty listener by a blocking listener in test
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
listener = new LatchedActionListener<>(listener, latch);
|
||||
|
||||
// tag::reload-analyzers-execute-async
|
||||
client.indices().reloadAnalyzersAsync(request, RequestOptions.DEFAULT, listener); // <1>
|
||||
// end::reload-analyzers-execute-async
|
||||
|
||||
assertTrue(latch.await(30L, TimeUnit.SECONDS));
|
||||
}
|
||||
|
||||
{
|
||||
// tag::reload-analyzers-notfound
|
||||
try {
|
||||
ReloadAnalyzersRequest request = new ReloadAnalyzersRequest("does_not_exist");
|
||||
client.indices().reloadAnalyzers(request, RequestOptions.DEFAULT);
|
||||
} catch (ElasticsearchException exception) {
|
||||
if (exception.status() == RestStatus.BAD_REQUEST) {
|
||||
// <1>
|
||||
}
|
||||
}
|
||||
// end::reload-analyzers-notfound
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void testDeleteAlias() throws Exception {
|
||||
RestHighLevelClient client = highLevelClient();
|
||||
|
|
Loading…
Reference in New Issue