Skip to content

Commit

Permalink
Removing _reload_search_analyzers related changes since the related x…
Browse files Browse the repository at this point in the history
…-pack support is removed (opensearch-project#48)

Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
setiah authored and peternied committed Mar 13, 2021
1 parent eb49365 commit f2a90be
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 319 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
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;
Expand Down Expand Up @@ -1837,30 +1835,6 @@ public Cancellable deleteIndexTemplateAsync(DeleteComposableIndexTemplateRequest
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
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;
Expand Down Expand Up @@ -806,15 +805,6 @@ static Request deleteIndexTemplate(DeleteComposableIndexTemplateRequest deleteIn
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())
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@
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;
Expand Down Expand Up @@ -1996,16 +1994,6 @@ public void testFreezeAndUnfreeze() throws IOException {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
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;
Expand Down Expand Up @@ -1236,23 +1235,6 @@ public void testDeleteTemplateRequest() {
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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
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;
Expand Down Expand Up @@ -85,9 +84,6 @@
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;
Expand Down Expand Up @@ -3172,79 +3168,6 @@ public void onFailure(Exception e) {
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();
Expand Down

0 comments on commit f2a90be

Please sign in to comment.