本文整理汇总了Java中io.searchbox.indices.DeleteIndex类的典型用法代码示例。如果您正苦于以下问题:Java DeleteIndex类的具体用法?Java DeleteIndex怎么用?Java DeleteIndex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeleteIndex类属于io.searchbox.indices包,在下文中一共展示了DeleteIndex类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteAll
import io.searchbox.indices.DeleteIndex; //导入依赖的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);
}
}
示例2: builderIndex_OneRecord
import io.searchbox.indices.DeleteIndex; //导入依赖的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");
}
示例3: builderIndex_Bulk
import io.searchbox.indices.DeleteIndex; //导入依赖的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);
}
示例4: delIndex
import io.searchbox.indices.DeleteIndex; //导入依赖的package包/类
@Override
public boolean delIndex(String index) throws Exception {
try {
JestResult result = _exec(new DeleteIndex.Builder(index).build());
return result != null;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
示例5: deleteIndex
import io.searchbox.indices.DeleteIndex; //导入依赖的package包/类
public void deleteIndex() {
try {
if (indexCreated) {
logger.info("Deleting test index {} from ES", indexName);
client.execute(new DeleteIndex.Builder(indexName).build());
}
} catch (IOException e) {
throw new RuntimeException("Could not delete index from ES!", e);
}
}
示例6: deleteIndex
import io.searchbox.indices.DeleteIndex; //导入依赖的package包/类
/**
* The delete index function will take as an argument the index name and will delete the index.
*/
@Override
public final void deleteIndex(String indexName)
{
Action action = new DeleteIndex.Builder(indexName).build();
LOGGER.info("Deleting Elasticsearch index, indexName={}.", indexName);
JestResult result = jestClientHelper.executeAction(action);
LOGGER.info("Deleting Elasticsearch index, indexName={}. result successful is {} ", indexName, result.isSucceeded());
}
示例7: delete
import io.searchbox.indices.DeleteIndex; //导入依赖的package包/类
/**
* Delete the given index and all of its documents.
*
* @param index The name of the index to delete.
*/
public void delete(String index) {
JestResult result = execute(new DeleteIndex.Builder(index).build());
if (!result.isSucceeded()) {
throw new ElasticsearchIndexDeleteException(index, result.getErrorMessage());
}
}
示例8: stop
import io.searchbox.indices.DeleteIndex; //导入依赖的package包/类
/**
* Stop the server.
* @throws Exception
*/
public void stop() throws Exception {
server.stop();
if (ds != null) {
ds.close();
InitialContext ctx = TestUtil.initialContext();
ctx.unbind("java:comp/env/jdbc/ApiManagerDS");
}
if (node != null) {
if ("true".equals(System.getProperty("apiman.test.es-delete-index", "true"))) {
client.execute(new DeleteIndex.Builder("apiman_manager").build());
}
}
}
示例9: deleteIndex
import io.searchbox.indices.DeleteIndex; //导入依赖的package包/类
@Override
public boolean deleteIndex(String indexName) {
Assert.notNull(indexName, "No index defined for delete operation");
return indexExists(indexName) && executeWithAcknowledge(new DeleteIndex.Builder(indexName).build());
}
示例10: dropIdexes
import io.searchbox.indices.DeleteIndex; //导入依赖的package包/类
public void dropIdexes() {
for (String index : getEsIndices(true)) {
log.info("dropping {}", index);
es.execute(new DeleteIndex.Builder(index).build());
}
}
示例11: deleteIndex
import io.searchbox.indices.DeleteIndex; //导入依赖的package包/类
public void deleteIndex() {
execute(new DeleteIndex.Builder(index).build());
}