本文整理匯總了Java中org.elasticsearch.client.IndicesAdminClient.prepareExists方法的典型用法代碼示例。如果您正苦於以下問題:Java IndicesAdminClient.prepareExists方法的具體用法?Java IndicesAdminClient.prepareExists怎麽用?Java IndicesAdminClient.prepareExists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.elasticsearch.client.IndicesAdminClient
的用法示例。
在下文中一共展示了IndicesAdminClient.prepareExists方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getCount
import org.elasticsearch.client.IndicesAdminClient; //導入方法依賴的package包/類
@Override
public long getCount() {
long count = 0;
IndicesAdminClient admin = elastic.getClient().admin().indices();
IndicesExistsRequestBuilder builder = admin.prepareExists(config.getMisc().getDindex().getName());
if (builder.execute().actionGet().isExists()) {
SearchResponse countResponse = elastic.getClient().prepareSearch(config.getMisc().getDindex().getName())
.setTypes(config.getMisc().getCtype().getName())
.setSearchType(SearchType.QUERY_THEN_FETCH)
.setSize(0)
.execute().actionGet();
count = countResponse.getHits().getTotalHits();
} else {
logger.info("Index/Type does not exist or does not contain the record");
System.exit(-1);
}
logger.info("Elastic Index/Type count: " + count);
return count;
}
示例2: dropDataSet
import org.elasticsearch.client.IndicesAdminClient; //導入方法依賴的package包/類
@Override
public void dropDataSet() {
final String indexName = config.getMisc().getDindex().getAs();
IndicesAdminClient admin = client.getClient().admin().indices();
IndicesExistsRequestBuilder builder = admin.prepareExists(indexName);
if (builder.execute().actionGet().isExists()) {
DeleteIndexResponse delete = admin.delete(new DeleteIndexRequest(indexName)).actionGet();
if (delete.isAcknowledged())
logger.info(String.format("The current index %s was deleted.", indexName));
else
logger.info(String.format("The current index %s was not deleted.", indexName));
}
}
示例3: getCount
import org.elasticsearch.client.IndicesAdminClient; //導入方法依賴的package包/類
public long getCount(ElasticConfiguration elastic, YamlConfiguration config) {
IndicesAdminClient admin = elastic.getClient().admin().indices();
IndicesExistsRequestBuilder builder = admin.prepareExists(config.getMisc().getDindex().getAs());
assertThat(builder.execute().actionGet().isExists(), is(true));
elastic.getClient().admin().indices().flush(new FlushRequest(config.getMisc().getDindex().getAs())).actionGet();
SearchResponse response = elastic.getClient().prepareSearch(config.getMisc().getDindex().getAs())
.setTypes(config.getMisc().getCtype().getAs())
.setSearchType(SearchType.QUERY_THEN_FETCH)
.setSize(0)
.execute().actionGet();
long count = response.getHits().getTotalHits();
return count;
}
示例4: indexExists
import org.elasticsearch.client.IndicesAdminClient; //導入方法依賴的package包/類
/**
* Checks if a given index exists in elastic
* <p/>
* @param client
* @param indexName
* @return
*/
private boolean indexExists(Client client, String indexName) {
AdminClient admin = client.admin();
IndicesAdminClient indices = admin.indices();
IndicesExistsRequestBuilder indicesExistsRequestBuilder = indices.
prepareExists(indexName);
IndicesExistsResponse response = indicesExistsRequestBuilder
.execute()
.actionGet();
return response.isExists();
}