Search in sources :

Example 1 with IndexState

use of co.elastic.clients.elasticsearch.indices.IndexState in project elasticsearch-java by elastic.

the class RequestTest method testIndexCreation.

@Test
public void testIndexCreation() throws Exception {
    ElasticsearchAsyncClient asyncClient = new ElasticsearchAsyncClient(client._transport());
    // Ping the server
    assertTrue(client.ping().value());
    // Create an index...
    final CreateIndexResponse createResponse = client.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 : ElasticsearchAsyncClient(co.elastic.clients.elasticsearch.ElasticsearchAsyncClient) GetIndexResponse(co.elastic.clients.elasticsearch.indices.GetIndexResponse) CreateIndexResponse(co.elastic.clients.elasticsearch.indices.CreateIndexResponse) IndexState(co.elastic.clients.elasticsearch.indices.IndexState) Test(org.junit.Test)

Aggregations

ElasticsearchAsyncClient (co.elastic.clients.elasticsearch.ElasticsearchAsyncClient)1 CreateIndexResponse (co.elastic.clients.elasticsearch.indices.CreateIndexResponse)1 GetIndexResponse (co.elastic.clients.elasticsearch.indices.GetIndexResponse)1 IndexState (co.elastic.clients.elasticsearch.indices.IndexState)1 Test (org.junit.Test)1