• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IndicesExists类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.searchbox.indices.IndicesExists的典型用法代码示例。如果您正苦于以下问题:Java IndicesExists类的具体用法?Java IndicesExists怎么用?Java IndicesExists使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IndicesExists类属于io.searchbox.indices包,在下文中一共展示了IndicesExists类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: validateIndex

import io.searchbox.indices.IndicesExists; //导入依赖的package包/类
public void validateIndex(String indexName) {
        try {
            IndicesExists indicesExistsRequest = new IndicesExists.Builder(indexName).build();
            logger.debug("created indexExistsRequests: {}", indicesExistsRequest);
            JestResult existsResult = client.execute(indicesExistsRequest);
            logger.debug("indexExistsRequests result: {}", existsResult);
            if (!existsResult.isSucceeded()) {
                Settings settings = Settings.builder()
//                        .put("index.analysis.analyzer.default.type", "keyword")
                        .put("index.store.type", "mmapfs")
                        .build();
                CreateIndex createIndexRequest = new CreateIndex.Builder(indexName).settings(settings).build();
                execute(createIndexRequest);
                //TODO: Make this work. Using the above "keyword" configuration in the meantime.
                PutMapping putMapping = new PutMapping.Builder(indexName, "_default_", STRING_NOT_ANALYZED).build();
                execute(putMapping);
                logger.info("created index with settings: {}, indexName: {}, putMapping: {}", settings, indexName, putMapping);
            }
        } catch (IOException e) {
            logger.error("failed to connect to elastic cluster", e);
        }
    }
 
开发者ID:unipop-graph,项目名称:unipop,代码行数:23,代码来源:ElasticClient.java


示例2: createIndex

import io.searchbox.indices.IndicesExists; //导入依赖的package包/类
@Override
public boolean createIndex() {
	JestClient client = esrResource.getClient();
	
	try{
		JestResult result = client.execute(new IndicesExists.Builder(index).build());
		if(result.getResponseCode() != 200){
			client.execute(new CreateIndex.Builder(index).build());
			
			return true;
		}
	}catch(IOException ioe){
		getMonitor().error("Unable to create index", ioe);
	}
	
	return false;
}
 
开发者ID:dstl,项目名称:baleen,代码行数:18,代码来源:ElasticsearchRest.java


示例3: deleteAll

import io.searchbox.indices.IndicesExists; //导入依赖的package包/类
@Override
public void deleteAll() throws IOException {
  // Delete the index, if it exists.
  JestResult result = client.execute(new IndicesExists.Builder(indexName).build());
  if (result.isSucceeded()) {
    result = client.execute(new DeleteIndex.Builder(indexName).build());
    if (!result.isSucceeded()) {
      throw new IOException(
          String.format("Failed to delete index %s: %s", indexName, result.getErrorMessage()));
    }
  }

  // Recreate the index.
  result = client.execute(new CreateIndex.Builder(indexName).settings(getMappings()).build());
  if (!result.isSucceeded()) {
    String error =
        String.format("Failed to create index %s: %s", indexName, result.getErrorMessage());
    throw new IOException(error);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:21,代码来源:AbstractElasticIndex.java


示例4: builderIndex_OneRecord

import io.searchbox.indices.IndicesExists; //导入依赖的package包/类
public void builderIndex_OneRecord(String json, boolean cleanBeforeInsert) {
  long start = System.currentTimeMillis();
  try {
    if (cleanBeforeInsert) {
      jestHttpClient.execute(new DeleteIndex(new DeleteIndex.Builder(_esIndexName)));
    }
    JestResult jestResult = jestHttpClient.execute(new IndicesExists.Builder(_esIndexName).build());
    if (!jestResult.isSucceeded()) {
      jestHttpClient.execute(new CreateIndex.Builder(_esIndexName).build());
    }

    Index index = new Index.Builder(json)
    .index(_esIndexName)
    .type(_esTypeName)
    .build();
    jestHttpClient.execute(index);
    //            jestHttpClient.shutdownClient();
  } catch (Exception e) {
    e.printStackTrace();
  }
  long end = System.currentTimeMillis();
  LOG.info("->> One Record(default id): time for create index --> " + (end - start) + " milliseconds"); 
}
 
开发者ID:faustineinsun,项目名称:WiseCrowdRec,代码行数:24,代码来源:JestElasticsearchManipulator.java


示例5: builderIndex_Bulk

import io.searchbox.indices.IndicesExists; //导入依赖的package包/类
public void builderIndex_Bulk(List<Entity> entityList, boolean cleanBeforeInsert) {
  int nRecords = entityList.size();
  long start = System.currentTimeMillis();
  try {
    if (cleanBeforeInsert) {
      jestHttpClient.execute(new DeleteIndex(new DeleteIndex.Builder(_esIndexName)));
    }
    JestResult jestResult = jestHttpClient.execute(new IndicesExists.Builder(_esIndexName).build());
    if (!jestResult.isSucceeded()) {
      jestHttpClient.execute(new CreateIndex.Builder(_esIndexName).build());
    }


    SerializeBeans2JSON sb2json = new SerializeBeans2JSON(); 
    Bulk.Builder bulkBuilder = new Bulk.Builder();
    for (int i = 0; i < nRecords; i++) {
      Index index = new Index
          .Builder(sb2json.serializeBeans2JSON(entityList.get(i)))
      .index(_esIndexName)
      .type(_esTypeName)
      .id(entityList.get(i).getEntityID())
      .build();
      bulkBuilder.addAction(index);
    }
    jestHttpClient.execute(bulkBuilder.build());
  } catch (Exception e) {
    e.printStackTrace();
  }
  long end = System.currentTimeMillis();
  LOG.info("->> Bulk: total time for create index --> " + (end - start) + " milliseconds, # of records: " + nRecords); 
}
 
开发者ID:faustineinsun,项目名称:WiseCrowdRec,代码行数:32,代码来源:JestElasticsearchManipulator.java


示例6: indexExists

import io.searchbox.indices.IndicesExists; //导入依赖的package包/类
private boolean indexExists(String index) {
  Action action = new IndicesExists.Builder(index).build();
  try {
    JestResult result = client.execute(action);
    return result.isSucceeded();
  } catch (IOException e) {
    throw new ConnectException(e);
  }
}
 
开发者ID:confluentinc,项目名称:kafka-connect-elasticsearch,代码行数:10,代码来源:ElasticsearchWriter.java


示例7: isIndexExists

import io.searchbox.indices.IndicesExists; //导入依赖的package包/类
@Override
public final boolean isIndexExists(String indexName)
{
    Action action = new IndicesExists.Builder(indexName).build();
    JestResult result = jestClientHelper.executeAction(action);

    return result.isSucceeded();
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:9,代码来源:IndexFunctionsDaoImpl.java


示例8: createIndex

import io.searchbox.indices.IndicesExists; //导入依赖的package包/类
/**
 * 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() {
	JestClient client = esrResource.getClient();
	try {
		JestResult result = client.execute(new IndicesExists.Builder(index).build());
		if (result.getResponseCode() != 200) {
			client.execute(new CreateIndex.Builder(index).build());
			return true;
		}
	} catch (IOException ioe) {
		getMonitor().error("Unable to create index", ioe);
	}
	return false;
}
 
开发者ID:dstl,项目名称:baleen,代码行数:20,代码来源:ElasticsearchTemplateRecordConsumer.java


示例9: init

import io.searchbox.indices.IndicesExists; //导入依赖的package包/类
@PostConstruct
public void init() throws Exception {
    log.info("Instantiating jestSearchIndexingService...");
    log.info(String.format("Checking if %s needs to be created", LOCATION_INDEX_NAME));
    IndicesExists indicesExists = new IndicesExists.Builder(LOCATION_INDEX_NAME).build();
    JestResult r = jestClient.execute(indicesExists);

    if (!r.isSucceeded()) {
        log.info("Index does not exist. Creating index...");
        // create new index (if u have this in elasticsearch.yml and prefer
        // those defaults, then leave this out
        ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();
        settings.put("number_of_shards", 1);
        settings.put("number_of_replicas", 0);

        CreateIndex.Builder builder = new CreateIndex.Builder(LOCATION_INDEX_NAME);
        builder.settings(settings.build().getAsMap());
        CreateIndex createIndex = builder.build();

        log.info(createIndex.toString());

        jestClient.execute(createIndex);

        log.info("Index created");
    } else {
        log.info("Index already exist!");
    }
}
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:29,代码来源:SearchIndexingServiceImpl.java


示例10: initialize

import io.searchbox.indices.IndicesExists; //导入依赖的package包/类
/**
 * Called to initialize the storage.
 */
@Override
public void initialize() {
    try {
        esClient.execute(new Health.Builder().build());
        // TODO Do we need a loop to wait for all nodes to join the cluster?
        Action<JestResult> action = new IndicesExists.Builder(getIndexName()).build();
        JestResult result = esClient.execute(action);
        if (! result.isSucceeded()) {
            createIndex(getIndexName());
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:18,代码来源:EsStorage.java


示例11: initializeClient

import io.searchbox.indices.IndicesExists; //导入依赖的package包/类
/**
 * Called to initialize the storage.
 * @param client the jest client
 * @param indexName the name of the ES index to initialize
 * @param defaultIndexName the default ES index - used to determine which -settings.json file to use
 */
protected void initializeClient(JestClient client, String indexName, String defaultIndexName) {
    try {
        client.execute(new Health.Builder().build());
        Action<JestResult> action = new IndicesExists.Builder(indexName).build();
        JestResult result = client.execute(action);
        if (!result.isSucceeded()) {
            createIndex(client, indexName, defaultIndexName + "-settings.json"); //$NON-NLS-1$
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:apiman,项目名称:apiman,代码行数:19,代码来源:AbstractClientFactory.java


示例12: indexExists

import io.searchbox.indices.IndicesExists; //导入依赖的package包/类
@Override
public boolean indexExists(String indexName) {
	return executeWithAcknowledge(new IndicesExists.Builder(indexName).build());
}
 
开发者ID:VanRoy,项目名称:spring-data-jest,代码行数:5,代码来源:JestElasticsearchTemplate.java


示例13: exists

import io.searchbox.indices.IndicesExists; //导入依赖的package包/类
@Override
protected boolean exists(String indexName) {
    IndicesExists indicesExists = new IndicesExists.Builder(indexName).build();
    JestResult result = execute(indicesExists, true);
    return result.getJsonObject().get("found").getAsBoolean();
}
 
开发者ID:nebula-plugins,项目名称:gradle-metrics-plugin,代码行数:7,代码来源:HttpESMetricsDispatcher.java


示例14: exists

import io.searchbox.indices.IndicesExists; //导入依赖的package包/类
/**
 * Check if the given index exists.
 * 
 * @param index the name of the index
 * @return true if the index exists.
 */
public boolean exists(String index) {
  return execute(new IndicesExists.Builder(index).build()).isSucceeded();
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:10,代码来源:ElasticsearchDao.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Modulo类代码示例发布时间:2022-05-22
下一篇:
Java Stable类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap