use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse 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();
}
use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse in project graylog2-server by Graylog2.
the class IndexCreatingDatabaseOperation method insert.
@Override
public void insert(InputStream dataScript) {
waitForGreenStatus();
final IndicesAdminClient indicesAdminClient = client.admin().indices();
for (String index : indexes) {
final IndicesExistsResponse indicesExistsResponse = indicesAdminClient.prepareExists(index).execute().actionGet();
if (indicesExistsResponse.isExists()) {
client.admin().indices().prepareDelete(index).execute().actionGet();
}
final Messages messages = new Messages(client, new MetricRegistry());
final Indices indices = new Indices(client, new IndexMapping(), messages, mock(NodeId.class), new NullAuditEventSender());
if (!indices.create(index, indexSet)) {
throw new IllegalStateException("Couldn't create index " + index);
}
}
databaseOperation.insert(dataScript);
}
use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse 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();
}
}
use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse in project fess by codelibs.
the class FessEsClient method existsIndex.
public boolean existsIndex(final String indexName) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
boolean exists = false;
try {
final IndicesExistsResponse response = client.admin().indices().prepareExists(indexName).execute().actionGet(fessConfig.getIndexSearchTimeout());
exists = response.isExists();
} catch (final Exception e) {
// ignore
}
return exists;
}
use of org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse in project play2-elasticsearch by cleverage.
the class IndexService method existsIndex.
/**
* Test if an indice Exists
* @return true if exists
*/
public static boolean existsIndex(String indexName) {
Client client = IndexClient.client;
AdminClient admin = client.admin();
IndicesAdminClient indices = admin.indices();
IndicesExistsRequestBuilder indicesExistsRequestBuilder = indices.prepareExists(indexName);
IndicesExistsResponse response = indicesExistsRequestBuilder.execute().actionGet();
return response.isExists();
}
Aggregations