本文整理汇总了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();
}