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

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

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

IndicesAdminClient.prepareGetIndex介绍

[英]Get index metadata for particular indices.
[中]获取特定索引的索引元数据。

代码示例

代码示例来源:origin: SonarSource/sonarqube

private List<String> loadExistingIndicesExceptMetadata(Collection<Index> definitions) {
  Set<String> definedNames = definitions.stream().map(IndexDefinition.Index::getName).collect(Collectors.toSet());
  return Arrays.stream(client.nativeClient().admin().indices().prepareGetIndex().get().getIndices())
   .filter(definedNames::contains)
   .filter(index -> !MetadataIndexDefinition.INDEX_TYPE_METADATA.getIndex().equals(index))
   .collect(Collectors.toList());
 }
}

代码示例来源:origin: NLPchina/elasticsearch-sql

type = indexAndType[1];
indexRequestBuilder = client.admin().indices().prepareGetIndex();

代码示例来源:origin: Netflix/conductor

private void updateLogIndexName() {
  this.logIndexName = this.logIndexPrefix + "_" + SIMPLE_DATE_FORMAT.format(new Date());
  try {
    elasticSearchClient.admin()
      .indices()
      .prepareGetIndex()
      .addIndices(logIndexName)
      .execute()
      .actionGet();
  } catch (IndexNotFoundException infe) {
    try {
      elasticSearchClient.admin()
        .indices()
        .prepareCreate(logIndexName)
        .execute()
        .actionGet();
    } catch (ResourceAlreadyExistsException ilee) {
      // no-op
    } catch (Exception e) {
      logger.error("Failed to update log index name: {}", logIndexName, e);
    }
  }
}

代码示例来源:origin: Netflix/conductor

private void addIndex(String indexName) {
  try {
    elasticSearchClient.admin()
      .indices()
      .prepareGetIndex()
      .addIndices(indexName)
      .execute()
      .actionGet();
  } catch (IndexNotFoundException infe) {
    try {
      elasticSearchClient.admin()
        .indices()
        .prepareCreate(indexName)
        .execute()
        .actionGet();
    } catch (ResourceAlreadyExistsException done) {
      // no-op
    }
  }
}

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

private Set<String> getIndices(String indexPattern) {
    return new HashSet<String>(asList(client.admin().indices().prepareGetIndex().addIndices(indexPattern).get().indices()));
  }
}

代码示例来源:origin: SonarSource/sonarqube

@Override
protected void after() {
 if (isCustom) {
  // delete non-core indices
  String[] existingIndices = SHARED_NODE.client().admin().indices().prepareGetIndex().get().getIndices();
  Stream.of(existingIndices)
   .filter(i -> !CORE_INDICES_NAMES.contains(i))
   .forEach(EsTester::deleteIndexIfExists);
 }
 BulkIndexer.delete(client(), new IndexType("_all", ""), client().prepareSearch("_all").setQuery(matchAllQuery()));
}

代码示例来源:origin: kiegroup/appformer

@Override
public List<String> getIndices() {
  String[] indices = this.getClient().admin().indices().prepareGetIndex().get().getIndices();
  return Arrays.asList(indices).stream().filter(index -> !index.startsWith(".")).collect(Collectors.toList());
}

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

@Override
public Set<String> getTableNames(String schema)
{
  requireNonNull(schema, "schema is null");
  String[] indexs = client.admin().indices().prepareGetIndex().get().indices();
  return ImmutableSet.copyOf(indexs);
}

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

@Override
public Set<String> getTableNames(String schema)
{
  requireNonNull(schema, "schema is null");
  String[] indexs = client.admin().indices().prepareGetIndex().get().indices();
  return ImmutableSet.copyOf(indexs);
}

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

@Override
public Set<String> getTableNames(String schema)
{
  requireNonNull(schema, "schema is null");
  String[] indexs = client.admin().indices().prepareGetIndex().get().indices();
  return ImmutableSet.copyOf(indexs);
}

代码示例来源:origin: org.uberfire/uberfire-metadata-backend-elasticsearch

@Override
public List<String> getIndices() {
  String[] indices = this.getClient().admin().indices().prepareGetIndex().get().getIndices();
  return Arrays.asList(indices).stream().filter(index -> !index.startsWith(".")).collect(Collectors.toList());
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

private List<String> loadExistingIndicesExceptMetadata(Collection<Index> definitions) {
  Set<String> definedNames = definitions.stream().map(Index::getName).collect(Collectors.toSet());
  return Arrays.stream(client.nativeClient().admin().indices().prepareGetIndex().get().getIndices())
   .filter(definedNames::contains)
   .filter(index -> !MetadataIndexDefinition.INDEX_TYPE_METADATA.getIndex().equals(index))
   .collect(Collectors.toList());
 }
}

代码示例来源:origin: timschlechter/swagger-for-elasticsearch

@Override
  public List<String> call() throws Exception {
    List<String> allIndices = new ArrayList<String>();
    allIndices.add("_all");
    allIndices.addAll(
      asList(client.admin().indices()
          .prepareGetIndex()
          .get()
          .getIndices()
      )
    );
    Collections.sort(allIndices);
    return allIndices;
  }
}

代码示例来源:origin: com.github.cafdataprocessing/corepolicy-condition-engine

private void ensureIndex(boolean createIfAbsent) throws IOException {
  GetIndexResponse indexResponse = getElasticClient()
      .admin()
      .indices()
      .prepareGetIndex()
      .get(elasticsearchProperties.getElasticsearchSearchTimeout());
  if (Arrays.asList(indexResponse.getIndices()).stream().anyMatch(i -> i.equalsIgnoreCase(policyIndexName))) {
    ensureIndexAvailable();
    return;
  }
  if (!createIfAbsent) {
    String error = MessageFormat.format("Failed to ensure that the index \"{0}\" exists in Elasticsearch", policyIndexName);
    logger.error(error);
    throw new RuntimeException(error);
  }
  logger.warn("Index \"{}\" does not exist in Elasticsearch. Creating index...", policyIndexName);
  try {
    createIndex();
  } catch (IndexAlreadyExistsException e) {
    logger.warn("Index \"{}\" was found to exist during creation attempt.", policyIndexName);
  }
  ensureIndex(false);
}

代码示例来源:origin: org.nlpcn/elasticsearch-sql

type = indexAndType[1];
indexRequestBuilder = client.admin().indices().prepareGetIndex();

代码示例来源:origin: gitchennan/elasticsearch-query-toolkit

private ImmutableMap<String, IndexState> newIndicesStateCacheInstance(TransportClient client) {
    try {
      ImmutableMap.Builder<String, IndexState> cacheBuilder = ImmutableMap.<String, IndexState>builder();
      GetIndexResponse getIndexResponse = client.admin().indices().prepareGetIndex().execute().actionGet();
      ClusterHealthResponse clusterHealthResponse = client.admin().cluster().prepareHealth(getIndexResponse.indices()).execute().actionGet();
      for (String index : clusterHealthResponse.getIndices().keySet()) {
        ClusterHealthStatus indexStatus = clusterHealthResponse.getIndices().get(index).getStatus();
        cacheBuilder.put(index, IndexState.newIndexState(index, IndexState.IndexStatus.fromString(indexStatus.name())));
      }
      indicesStateCacheMissing = false;
      return cacheBuilder.build();
    }
    catch (Exception ex) {
      EsPersistLogger.warn(this, "Failed to get index state.", ex);
      indicesStateCacheMissing = true;
      return ImmutableMap.<String, IndexState>builder().build();
    }
  }
}

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

public static Index resolveIndex(String index) {
  GetIndexResponse getIndexResponse = client().admin().indices().prepareGetIndex().setIndices(index).get();
  assertTrue("index " + index + " not found", getIndexResponse.getSettings().containsKey(index));
  String uuid = getIndexResponse.getSettings().get(index).get(IndexMetaData.SETTING_INDEX_UUID);
  return new Index(index, uuid);
}

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

public Index resolveIndex(String index) {
  GetIndexResponse getIndexResponse = client().admin().indices().prepareGetIndex().setIndices(index).get();
  assertTrue("index " + index + " not found", getIndexResponse.getSettings().containsKey(index));
  String uuid = getIndexResponse.getSettings().get(index).get(IndexMetaData.SETTING_INDEX_UUID);
  return new Index(index, uuid);
}

代码示例来源:origin: visallo/vertexium

public void dropIndices() throws Exception {
  String[] indices = runner.admin().indices().prepareGetIndex().execute().get().indices();
  for (String index : indices) {
    if (index.startsWith(ES_INDEX_NAME) || index.startsWith(ES_EXTENDED_DATA_INDEX_NAME_PREFIX)) {
      LOGGER.info("deleting test index: %s", index);
      runner.admin().indices().prepareDelete(index).execute().actionGet();
    }
  }
}

代码示例来源:origin: visallo/vertexium

public void clearIndices(Elasticsearch5SearchIndex searchIndex) throws Exception {
  String[] indices = runner.admin().indices().prepareGetIndex().execute().get().indices();
  for (String index : indices) {
    if (index.startsWith(ES_INDEX_NAME) || index.startsWith(ES_EXTENDED_DATA_INDEX_NAME_PREFIX)) {
      LOGGER.info("clearing test index: %s", index);
      BulkByScrollResponse response = DeleteByQueryAction.INSTANCE.newRequestBuilder(searchIndex.getClient())
          .source(index)
          .get();
      LOGGER.info("removed %d documents", response.getDeleted());
    }
  }
}

相关文章

微信公众号

最新文章

更多

IndicesAdminClient类方法