当前位置: 首页>>代码示例>>Java>>正文


Java IndicesAdminClient.prepareExists方法代码示例

本文整理汇总了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;
}
 
开发者ID:ozlerhakan,项目名称:mongolastic,代码行数:21,代码来源:ElasticToMongoProvider.java

示例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));
    }
}
 
开发者ID:ozlerhakan,项目名称:mongolastic,代码行数:14,代码来源:ElasticBulkService.java

示例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;
}
 
开发者ID:ozlerhakan,项目名称:mongolastic,代码行数:16,代码来源:TestMongoToElastic.java

示例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();
}
 
开发者ID:hopshadoop,项目名称:hopsworks,代码行数:21,代码来源:ElasticController.java


注:本文中的org.elasticsearch.client.IndicesAdminClient.prepareExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。