當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。