Search in sources :

Example 16 with IndicesExistsRequest

use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest in project graylog2-server by Graylog2.

the class IndicesGetAllMessageFieldsTest method GetAllMessageFieldsForIndicesForNonexistingIndexShouldReturnEmptySet.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL)
public void GetAllMessageFieldsForIndicesForNonexistingIndexShouldReturnEmptySet() throws Exception {
    final String[] indexNames = new String[] { "graylog_0" };
    final IndicesExistsResponse response = client.admin().indices().exists(new IndicesExistsRequest("graylog_0")).get();
    assertThat(response.isExists()).isFalse();
    final Map<String, Set<String>> result = indices.getAllMessageFieldsForIndices(indexNames);
    assertThat(result).isNotNull().isEmpty();
}
Also used : Set(java.util.Set) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) IndicesExistsResponse(org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse) IndicesExistsRequest(org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 17 with IndicesExistsRequest

use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest in project beam by apache.

the class ElasticSearchIOTestUtils method deleteIndex.

/** Deletes the given index synchronously. */
static void deleteIndex(String index, Client client) throws Exception {
    IndicesAdminClient indices = client.admin().indices();
    IndicesExistsResponse indicesExistsResponse = indices.exists(new IndicesExistsRequest(index)).get();
    if (indicesExistsResponse.isExists()) {
        indices.prepareClose(index).get();
        indices.delete(Requests.deleteIndexRequest(index)).get();
    }
}
Also used : IndicesExistsResponse(org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse) IndicesAdminClient(org.elasticsearch.client.IndicesAdminClient) IndicesExistsRequest(org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest)

Aggregations

IndicesExistsRequest (org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest)17 Test (org.junit.Test)13 Matchers.containsString (org.hamcrest.Matchers.containsString)9 IndicesExistsResponse (org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse)4 UsingDataSet (com.lordofthejars.nosqlunit.annotation.UsingDataSet)2 SQLTransportIntegrationTest (io.crate.integrationtests.SQLTransportIntegrationTest)2 PartitionName (io.crate.metadata.PartitionName)2 BytesRef (org.apache.lucene.util.BytesRef)2 FailedException (backtype.storm.topology.FailedException)1 TitanException (com.thinkaurelius.titan.core.TitanException)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 ElasticSearchException (org.elasticsearch.ElasticSearchException)1 Alias (org.elasticsearch.action.admin.indices.alias.Alias)1 CreateIndexResponse (org.elasticsearch.action.admin.indices.create.CreateIndexResponse)1 IndicesExistsRequestBuilder (org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder)1 BulkRequestBuilder (org.elasticsearch.action.bulk.BulkRequestBuilder)1 BulkResponse (org.elasticsearch.action.bulk.BulkResponse)1 IndicesAdminClient (org.elasticsearch.client.IndicesAdminClient)1 ImmutableSettings (org.elasticsearch.common.settings.ImmutableSettings)1