Search in sources :

Example 1 with IndexState

use of org.opensearch.client.opensearch.indices.IndexState in project opensearch-java by opensearch-project.

the class IndicesClientIT method testCreateIndex.

public void testCreateIndex() throws Exception {
    OpenSearchAsyncClient asyncClient = new OpenSearchAsyncClient(highLevelClient()._transport());
    CreateIndexResponse createResponse = highLevelClient().indices().create(b -> b.index("my-index"));
    assertTrue(createResponse.acknowledged());
    assertTrue(createResponse.shardsAcknowledged());
    // Find info about it, using the async client
    CompletableFuture<GetIndexResponse> futureResponse = asyncClient.indices().get(b -> b.index("my-index"));
    GetIndexResponse response = futureResponse.get(10, TimeUnit.SECONDS);
    Map<String, IndexState> indices = response.result();
    assertEquals(1, indices.size());
    assertNotNull(indices.get("my-index"));
}
Also used : OpenSearchAsyncClient(org.opensearch.client.opensearch.OpenSearchAsyncClient) GetIndexResponse(org.opensearch.client.opensearch.indices.GetIndexResponse) CreateIndexResponse(org.opensearch.client.opensearch.indices.CreateIndexResponse) IndexState(org.opensearch.client.opensearch.indices.IndexState)

Example 2 with IndexState

use of org.opensearch.client.opensearch.indices.IndexState in project opensearch-java by opensearch-project.

the class RequestTest method testIndexCreation.

@Test
public void testIndexCreation() throws Exception {
    OpenSearchAsyncClient asyncClient = new OpenSearchAsyncClient(highLevelClient()._transport());
    // Ping the server
    assertTrue(highLevelClient().ping().value());
    // Create an index...
    final CreateIndexResponse createResponse = highLevelClient().indices().create(b -> b.index("my-index"));
    assertTrue(createResponse.acknowledged());
    assertTrue(createResponse.shardsAcknowledged());
    // Find info about it, using the async client
    CompletableFuture<GetIndexResponse> futureResponse = asyncClient.indices().get(b -> b.index("my-index"));
    GetIndexResponse response = futureResponse.get(10, TimeUnit.SECONDS);
    Map<String, IndexState> indices = response.result();
    assertEquals(1, indices.size());
    assertNotNull(indices.get("my-index"));
}
Also used : OpenSearchAsyncClient(org.opensearch.client.opensearch.OpenSearchAsyncClient) GetIndexResponse(org.opensearch.client.opensearch.indices.GetIndexResponse) CreateIndexResponse(org.opensearch.client.opensearch.indices.CreateIndexResponse) IndexState(org.opensearch.client.opensearch.indices.IndexState) Test(org.junit.Test)

Aggregations

OpenSearchAsyncClient (org.opensearch.client.opensearch.OpenSearchAsyncClient)2 CreateIndexResponse (org.opensearch.client.opensearch.indices.CreateIndexResponse)2 GetIndexResponse (org.opensearch.client.opensearch.indices.GetIndexResponse)2 IndexState (org.opensearch.client.opensearch.indices.IndexState)2 Test (org.junit.Test)1