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

x33g5p2x  于2022-01-28 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(88)

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

Requests.indicesExistsRequest介绍

[英]Creates an indices exists request.
[中]创建一个请求。

代码示例

代码示例来源:origin: brianfrankcooper/YCSB

.exists(Requests.indicesExistsRequest(indexKey)).actionGet()
    .isExists();
if (exists && newIndex) {

代码示例来源:origin: brianfrankcooper/YCSB

.exists(Requests.indicesExistsRequest(indexKey)).actionGet()
        .isExists();
if (exists && newdb) {

代码示例来源:origin: SpringDataElasticsearchDevs/spring-data-elasticsearch

private boolean indexExists(String indexName) {
  return client.admin()
      .indices()
      .exists(indicesExistsRequest(indexName)).actionGet().exists();
}

代码示例来源:origin: dqeasycloud/easy-cloud

@Override
public boolean indexExists(String indexName) {
  return getIndicesAdminClient().exists(indicesExistsRequest(indexName)).actionGet().isExists();
}

代码示例来源:origin: dstl/baleen

private boolean createIndex() {
 if (!esResource
   .getClient()
   .admin()
   .indices()
   .exists(Requests.indicesExistsRequest(index))
   .actionGet()
   .isExists()) {
  esResource
    .getClient()
    .admin()
    .indices()
    .create(Requests.createIndexRequest(index))
    .actionGet();
  return true;
 }
 return false;
}

代码示例来源:origin: dstl/baleen

@Override
public boolean createIndex() {
 if (!esResource
   .getClient()
   .admin()
   .indices()
   .exists(Requests.indicesExistsRequest(index))
   .actionGet()
   .isExists()) {
  esResource
    .getClient()
    .admin()
    .indices()
    .create(Requests.createIndexRequest(index))
    .actionGet();
  return true;
 }
 return false;
}

代码示例来源:origin: dstl/baleen

/**
 * Create an index in Elasticsearch. If necessary, this function should check whether a new index
 * is required.
 *
 * @return true if a new index has been created, false otherwise
 */
public boolean createIndex() {
 if (!esResource
   .getClient()
   .admin()
   .indices()
   .exists(Requests.indicesExistsRequest(index))
   .actionGet()
   .isExists()) {
  esResource
    .getClient()
    .admin()
    .indices()
    .create(Requests.createIndexRequest(index))
    .actionGet();
  return true;
 }
 return false;
}

代码示例来源:origin: dstl/baleen

/**
 * Create an index in Elasticsearch. If necessary, this function should check whether a new index
 * is required.
 *
 * @return true if a new index has been created, false otherwise
 */
public boolean createIndex() {
 if (!esResource
   .getClient()
   .admin()
   .indices()
   .exists(Requests.indicesExistsRequest(index))
   .actionGet()
   .isExists()) {
  esResource
    .getClient()
    .admin()
    .indices()
    .create(Requests.createIndexRequest(index))
    .actionGet();
  return true;
 }
 return false;
}

代码示例来源:origin: SeaseLtd/rated-ranking-evaluator

final JsonNode esconfig = mapper.readTree(indexShapeFile);
if (proxy.admin().indices().exists(indicesExistsRequest(indexName)).actionGet().isExists()) {
  proxy.admin().indices().delete(deleteIndexRequest(indexName)).actionGet();

代码示例来源:origin: dstl/baleen

private void setMapping(final String index) throws IOException {
 // Create index (if needed)
 final IndicesAdminClient indices = esResource.getClient().admin().indices();
 if (!indices.exists(Requests.indicesExistsRequest(index)).actionGet().isExists()) {
  // We must submit all the mappings at once for parent child
  indices
    .prepareCreate(index)
    .addMapping(documentType, createDocumentMapping(XContentFactory.jsonBuilder()))
    .addMapping(mentionType, createMentionMapping(XContentFactory.jsonBuilder()))
    .addMapping(entityType, createEntityMapping(XContentFactory.jsonBuilder()))
    .addMapping(relationType, createRelationMapping(XContentFactory.jsonBuilder()))
    .execute()
    .actionGet();
 }
}

代码示例来源:origin: apache/streams

@BeforeClass
public void prepareTestPersistUpdater() throws Exception {
 testConfiguration = new ComponentConfigurator<>(ElasticsearchWriterConfiguration.class).detectConfiguration("ElasticsearchPersistUpdaterIT");
 testClient = ElasticsearchClientManager.getInstance(testConfiguration).client();
 ClusterHealthRequest clusterHealthRequest = Requests.clusterHealthRequest();
 ClusterHealthResponse clusterHealthResponse = testClient.admin().cluster().health(clusterHealthRequest).actionGet();
 assertNotEquals(clusterHealthResponse.getStatus(), ClusterHealthStatus.RED);
 IndicesExistsRequest indicesExistsRequest = Requests.indicesExistsRequest(testConfiguration.getIndex());
 IndicesExistsResponse indicesExistsResponse = testClient.admin().indices().exists(indicesExistsRequest).actionGet();
 assertTrue(indicesExistsResponse.isExists());
}

代码示例来源:origin: apache/streams

@BeforeClass
public void prepareTestParentChildPersistUpdater() throws Exception {
 testConfiguration = new ComponentConfigurator<>(ElasticsearchWriterConfiguration.class).detectConfiguration( "ElasticsearchParentChildUpdaterIT");
 testClient = ElasticsearchClientManager.getInstance(testConfiguration).client();
 ClusterHealthRequest clusterHealthRequest = Requests.clusterHealthRequest();
 ClusterHealthResponse clusterHealthResponse = testClient.admin().cluster().health(clusterHealthRequest).actionGet();
 assertNotEquals(clusterHealthResponse.getStatus(), ClusterHealthStatus.RED);
 IndicesExistsRequest indicesExistsRequest = Requests.indicesExistsRequest(testConfiguration.getIndex());
 IndicesExistsResponse indicesExistsResponse = testClient.admin().indices().exists(indicesExistsRequest).actionGet();
 assertTrue(indicesExistsResponse.isExists());
 Reflections reflections = new Reflections(new ConfigurationBuilder()
   .setUrls(ClasspathHelper.forPackage("org.apache.streams.pojo.json"))
   .setScanners(new SubTypesScanner()));
 objectTypes = reflections.getSubTypesOf(ActivityObject.class);
 Path testdataDir = Paths.get("target/dependency/activitystreams-testdata");
 files = Files.list(testdataDir).collect(Collectors.toList());
}

代码示例来源:origin: apache/streams

@BeforeClass
public void prepareTestPersistWriter() throws Exception {
 testConfiguration = new ComponentConfigurator<>(ElasticsearchWriterConfiguration.class).detectConfiguration("ElasticsearchPersistWriterIT");
 testClient = ElasticsearchClientManager.getInstance(testConfiguration).client();
 ClusterHealthRequest clusterHealthRequest = Requests.clusterHealthRequest();
 ClusterHealthResponse clusterHealthResponse = testClient.admin().cluster().health(clusterHealthRequest).actionGet();
 assertNotEquals(clusterHealthResponse.getStatus(), ClusterHealthStatus.RED);
 IndicesExistsRequest indicesExistsRequest = Requests.indicesExistsRequest(testConfiguration.getIndex());
 IndicesExistsResponse indicesExistsResponse = testClient.admin().indices().exists(indicesExistsRequest).actionGet();
 if(indicesExistsResponse.isExists()) {
  DeleteIndexRequest deleteIndexRequest = Requests.deleteIndexRequest(testConfiguration.getIndex());
  DeleteIndexResponse deleteIndexResponse = testClient.admin().indices().delete(deleteIndexRequest).actionGet();
  assertTrue(deleteIndexResponse.isAcknowledged());
 }
}

代码示例来源:origin: apache/streams

@BeforeClass
public void prepareTestParentChildPersistWriter() throws Exception {
 testConfiguration = new ComponentConfigurator<>(ElasticsearchWriterConfiguration.class).detectConfiguration("ElasticsearchParentChildWriterIT");
 testClient = ElasticsearchClientManager.getInstance(testConfiguration).client();
 ClusterHealthRequest clusterHealthRequest = Requests.clusterHealthRequest();
 ClusterHealthResponse clusterHealthResponse = testClient.admin().cluster().health(clusterHealthRequest).actionGet();
 assertNotEquals(clusterHealthResponse.getStatus(), ClusterHealthStatus.RED);
 IndicesExistsRequest indicesExistsRequest = Requests.indicesExistsRequest(testConfiguration.getIndex());
 IndicesExistsResponse indicesExistsResponse = testClient.admin().indices().exists(indicesExistsRequest).actionGet();
 if (indicesExistsResponse.isExists()) {
  DeleteIndexRequest deleteIndexRequest = Requests.deleteIndexRequest(testConfiguration.getIndex());
  DeleteIndexResponse deleteIndexResponse = testClient.admin().indices().delete(deleteIndexRequest).actionGet();
  assertTrue(deleteIndexResponse.isAcknowledged());
 }
 PutIndexTemplateRequestBuilder putTemplateRequestBuilder = testClient.admin().indices().preparePutTemplate("mappings");
 URL templateURL = ElasticsearchParentChildWriterIT.class.getResource("/ActivityChildObjectParent.json");
 ObjectNode template = MAPPER.readValue(templateURL, ObjectNode.class);
 String templateSource = MAPPER.writeValueAsString(template);
 putTemplateRequestBuilder.setSource(templateSource);
 testClient.admin().indices().putTemplate(putTemplateRequestBuilder.request()).actionGet();
 Reflections reflections = new Reflections(new ConfigurationBuilder()
  .setUrls(ClasspathHelper.forPackage("org.apache.streams.pojo.json"))
  .setScanners(new SubTypesScanner()));
 objectTypes = reflections.getSubTypesOf(ActivityObject.class);
 Path testdataDir = Paths.get("target/dependency/activitystreams-testdata");
 files = Files.list(testdataDir).collect(Collectors.toList());
 assert( files.size() > 0);
}

代码示例来源:origin: apache/streams

@Test
public void testParentChildPersistWriter() throws Exception {
 IndicesExistsRequest indicesExistsRequest = Requests.indicesExistsRequest(testConfiguration.getIndex());
 IndicesExistsResponse indicesExistsResponse = testClient.admin().indices().exists(indicesExistsRequest).actionGet();
 if(indicesExistsResponse.isExists()) {

代码示例来源:origin: apache/streams

@Test
public void testPersistUpdater() throws Exception {
 IndicesExistsRequest indicesExistsRequest = Requests.indicesExistsRequest(testConfiguration.getIndex());
 IndicesExistsResponse indicesExistsResponse = testClient.admin().indices().exists(indicesExistsRequest).actionGet();
 assertTrue(indicesExistsResponse.isExists());

相关文章