org.elasticsearch.client.IndicesAdminClient.prepareExists()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中org.elasticsearch.client.IndicesAdminClient.prepareExists()方法的一些代码示例,展示了IndicesAdminClient.prepareExists()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IndicesAdminClient.prepareExists()方法的具体详情如下:
包路径:org.elasticsearch.client.IndicesAdminClient
类名称:IndicesAdminClient
方法名:prepareExists

IndicesAdminClient.prepareExists介绍

[英]Indices exists.
[中]指数存在。

代码示例

代码示例来源:origin: loklak/loklak_server

public void createIndexIfNotExists(String indexName, final int shards, final int replicas) {
  // create an index if not existent
  if (!this.elasticsearchClient.admin().indices().prepareExists(indexName).execute().actionGet().isExists()) {
    Settings.Builder settings = Settings.builder()
        .put("number_of_shards", shards)
        .put("number_of_replicas", replicas);
    this.elasticsearchClient.admin().indices().prepareCreate(indexName)
      .setSettings(settings)
      .setUpdateAllTypes(true)
      .execute().actionGet();
  } else {
    //LOGGER.debug("Index with name {} already exists", indexName);
  }
}

代码示例来源:origin: richardwilly98/elasticsearch-river-mongodb

public static long getIndexCount(Client client, MongoDBRiverDefinition definition) {
  if (client.admin().indices().prepareExists(definition.getIndexName()).get().isExists()) {
    if (definition.isImportAllCollections()) {
      return client.prepareCount(definition.getIndexName()).execute().actionGet().getCount();
    } else {
      if (client.admin().indices().prepareTypesExists(definition.getIndexName()).setTypes(definition.getTypeName()).get()
          .isExists()) {
        return client.prepareCount(definition.getIndexName()).setTypes(definition.getTypeName()).get().getCount();
      }
    }
  }
  return 0;
}

代码示例来源:origin: pentaho/pentaho-kettle

IndicesExistsRequestBuilder indicesExistBld = admin.indices().prepareExists( tempMeta.getIndex() );
IndicesExistsResponse indicesExistResponse = indicesExistBld.execute().get();
if ( !indicesExistResponse.isExists() ) {

代码示例来源:origin: richardwilly98/elasticsearch-river-mongodb

if (!esClient.admin().indices().prepareExists(definition.getIndexName()).get().isExists()) {
  esClient.admin().indices().prepareCreate(definition.getIndexName()).get();

代码示例来源:origin: yacy/yacy_grid_mcp

/**
 * create a new index. This method must be called to ensure that an elasticsearch index is available and can be used.
 * @param indexName
 * @param shards
 * @param replicas
 * @throws NoNodeAvailableException in case that no elasticsearch server can be contacted.
 */
public void createIndexIfNotExists(String indexName, final int shards, final int replicas) throws NoNodeAvailableException {
  // create an index if not existent
  if (!this.elasticsearchClient.admin().indices().prepareExists(indexName).execute().actionGet().isExists()) {
    Settings.Builder settings = Settings.builder()
        .put("number_of_shards", shards)
        .put("number_of_replicas", replicas);
    this.elasticsearchClient.admin().indices().prepareCreate(indexName)
      .setSettings(settings)
      .setUpdateAllTypes(true)
      .execute().actionGet();
  } else {
    //LOGGER.debug("Index with name {} already exists", indexName);
  }
}

代码示例来源:origin: fr.pilato.elasticsearch/elasticsearch-beyonder

/**
 * Check if an index already exists
 * @param client Elasticsearch client
 * @param index Index name
 * @return true if index already exists
 */
@Deprecated
public static boolean isIndexExist(Client client, String index) {
  return client.admin().indices().prepareExists(index).get().isExists();
}

代码示例来源:origin: dadoonet/elasticsearch-beyonder

/**
 * Check if an index already exists
 * @param client Elasticsearch client
 * @param index Index name
 * @return true if index already exists
 */
@Deprecated
public static boolean isIndexExist(Client client, String index) {
  return client.admin().indices().prepareExists(index).get().isExists();
}

代码示例来源:origin: Stratio/Decision

@Override
public Boolean check() throws Exception {
  try {
    getClient().admin().indices().prepareExists(elasticSearchClusterName).execute();
    return true;
  } catch (Exception e) {
    return false;
  }
}

代码示例来源:origin: eshioji/trident-tutorial

private static void createIndex(Client client) {
  boolean exist = client.admin().indices().prepareExists("hackaton").execute().actionGet().isExists();
  if (!exist) {
    client.admin().indices().prepareCreate("hackaton").execute().actionGet();
  }
}

代码示例来源:origin: harbby/presto-connectors

@Override
public boolean existsTable(SchemaTableName schemaTableName)
{
  return client.admin().indices().prepareExists(schemaTableName.getTableName())
      .execute().actionGet().isExists();
}

代码示例来源:origin: jaibeermalik/searchanalytics-bigdata

@Override
public boolean isIndexExists(final String indexName) {
  return searchClientService.getClient().admin().indices()
      .prepareExists(indexName).get().isExists();
}

代码示例来源:origin: com.blossom-project/blossom-core-common

/**
 * Initialize the index in the Elasticsearch cluster with the current settings.
 */
@PostConstruct
public void initializeIndex() {
 if (!this.client.admin().indices().prepareExists(index).get().isExists()) {
  this.client.admin().indices().prepareCreate(index).setSource(settings).get();
 }
}

代码示例来源:origin: com.strapdata.elasticsearch.test/framework

/**
 * Returns <code>true</code> iff the given index exists otherwise <code>false</code>
 */
protected boolean indexExists(String index) {
  IndicesExistsResponse actionGet = client().admin().indices().prepareExists(index).execute().actionGet();
  return actionGet.isExists();
}

代码示例来源:origin: ff4j/ff4j

private void initNativeClient() {
  esClient = NodeBuilder.nodeBuilder().client(true).node().client();
  boolean indexExists = esClient.admin().indices().prepareExists(indexName).execute().actionGet().isExists();
  if (indexExists) {
    esClient.admin().indices().prepareDelete(indexName).execute().actionGet();
  }
  esClient.admin().indices().prepareCreate(indexName).execute().actionGet();
}

代码示例来源:origin: harbby/presto-connectors

@Override
public boolean existsTable(SchemaTableName schemaTableName)
{
  return client.admin().indices().prepareExists(schemaTableName.getTableName())
      .execute().actionGet().isExists();
}

代码示例来源:origin: tlrx/elasticsearch-test

@Override
public Boolean execute(Client client) throws ElasticsearchException {
  if ((index != null) && (type != null) && (id != null)) {
    // Check if a document exists
    GetResponse response = client.prepareGet(index, type, id).setRefresh(true).execute().actionGet();
    return response.isExists();
  } else {
    // Check if index exists
    IndicesExistsResponse response = client.admin().indices().prepareExists(index).execute().actionGet();
    return response.isExists();
  }
}

代码示例来源:origin: com.github.tlrx/elasticsearch-test

@Override
public Boolean execute(Client client) throws ElasticsearchException {
  if ((index != null) && (type != null) && (id != null)) {
    // Check if a document exists
    GetResponse response = client.prepareGet(index, type, id).setRefresh(true).execute().actionGet();
    return response.isExists();
  } else {
    // Check if index exists
    IndicesExistsResponse response = client.admin().indices().prepareExists(index).execute().actionGet();
    return response.isExists();
  }
}

代码示例来源:origin: org.sonatype.nexus/nexus-repository

private void deleteIndex(final String indexName) {
 bulkProcessor.flush(); // make sure dangling requests don't resurrect this index
 IndicesAdminClient indices = indicesAdminClient();
 if (indices.prepareExists(indexName).execute().actionGet().isExists()) {
  indices.prepareDelete(indexName).execute().actionGet();
 }
}

代码示例来源:origin: jloisel/elastic-crud

@After
 public void after() {
  final IndicesAdminClient indices = client.admin().indices();
  if(indices.prepareExists(INDEX).execute().actionGet().isExists()) {
   indices.prepareDelete(INDEX).execute().actionGet();
  }
 }
}

代码示例来源:origin: jloisel/elastic-crud

@After
 public void after() {
  final IndicesAdminClient indices = client.admin().indices();
  if(indices.prepareExists(INDEX).execute().actionGet().isExists()) {
   indices.prepareDelete(INDEX).execute().actionGet();
  }
 }
}

相关文章

微信公众号

最新文章

更多

IndicesAdminClient类方法