本文整理汇总了Java中org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder类的典型用法代码示例。如果您正苦于以下问题:Java DeleteIndexRequestBuilder类的具体用法?Java DeleteIndexRequestBuilder怎么用?Java DeleteIndexRequestBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DeleteIndexRequestBuilder类属于org.elasticsearch.action.admin.indices.delete包,在下文中一共展示了DeleteIndexRequestBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDeleteIndex
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; //导入依赖的package包/类
@Test
public void testDeleteIndex() {
//Test data
final String indexName = "index";
final AdminClient adminClient = createMock(AdminClient.class);
final IndicesAdminClient indicesAdminClient = createMock(IndicesAdminClient.class);
final DeleteIndexRequestBuilder deleteIndexRequestBuilder = createMock(DeleteIndexRequestBuilder.class);
final DeleteIndexResponse deleteIndexResponse = createMock(DeleteIndexResponse.class);
//Reset
resetAll();
//Expectations
expect(esClient.admin()).andReturn(adminClient);
expect(adminClient.indices()).andReturn(indicesAdminClient);
expect(indicesAdminClient.prepareDelete(indexName)).andReturn(deleteIndexRequestBuilder);
expect(deleteIndexRequestBuilder.get()).andReturn(deleteIndexResponse);
//Replay
replayAll();
//Run test scenario
final boolean result = elasticsearchClientWrapper.deleteIndex(indexName);
//Verify
verifyAll();
assertEquals(deleteIndexResponse.isAcknowledged(), result);
}
示例2: call
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; //导入依赖的package包/类
@Override
public Observable<Boolean> call(String index) {
Elasticsearch elasticsearch = vertxContext.verticle().elasticsearch();
DeleteIndexRequestBuilder request = elasticsearch.get().admin().indices().prepareDelete(index);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(format("Request %s", Jsonify.toString(request)));
}
return elasticsearch.execute(vertxContext, request, elasticsearch.getDefaultAdminTimeout())
.map(Optional::get)
.doOnNext(response -> {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(format("Response %s", Jsonify.toString(response)));
}
})
.map(AcknowledgedResponse::isAcknowledged);
}
示例3: deleteIndex
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; //导入依赖的package包/类
@Override
public BulkNodeClient deleteIndex(String index) {
if (closed) {
throw new ElasticsearchException("client is closed");
}
if (client == null) {
logger.warn("no client");
return this;
}
if (index == null) {
logger.warn("no index name given to delete index");
return this;
}
DeleteIndexRequestBuilder deleteIndexRequestBuilder =
new DeleteIndexRequestBuilder(client(), DeleteIndexAction.INSTANCE, index);
deleteIndexRequestBuilder.execute().actionGet();
return this;
}
示例4: deleteIndex
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; //导入依赖的package包/类
@Override
public HttpBulkNodeClient deleteIndex(String index) {
if (closed) {
throw new ElasticsearchException("client is closed");
}
if (client == null) {
logger.warn("no client");
return this;
}
if (index == null) {
logger.warn("no index name given to delete index");
return this;
}
DeleteIndexRequestBuilder deleteIndexRequestBuilder =
new DeleteIndexRequestBuilder(client(), DeleteIndexAction.INSTANCE, index);
deleteIndexRequestBuilder.execute().actionGet();
return this;
}
示例5: test
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; //导入依赖的package包/类
@Test
public void test() throws Exception {
try {
DeleteIndexRequestBuilder deleteIndexRequestBuilder = new DeleteIndexRequestBuilder(client("1"), DeleteIndexAction.INSTANCE, "test");
deleteIndexRequestBuilder.execute().actionGet();
} catch (Exception e) {
// ignore
}
IndexRequestBuilder indexRequestBuilder = new IndexRequestBuilder(client("1"), IndexAction.INSTANCE);
indexRequestBuilder
.setIndex("test")
.setType("test")
.setId("1")
.setSource(jsonBuilder().startObject().field("field", "1%2fPJJP3JV2C24iDfEu9XpHBaYxXh%2fdHTbmchB35SDznXO2g8Vz4D7GTIvY54iMiX_149c95f02a8").endObject())
.setRefresh(true)
.execute()
.actionGet();
String doc = client("1").prepareSearch("test")
.setTypes("test")
.setQuery(matchQuery("field", "1%2fPJJP3JV2C24iDfEu9XpHBaYxXh%2fdHTbmchB35SDznXO2g8Vz4D7GTIvY54iMiX_149c95f02a8"))
.execute()
.actionGet()
.getHits().getAt(0).getSourceAsString();
assertEquals(doc, "{\"field\":\"1%2fPJJP3JV2C24iDfEu9XpHBaYxXh%2fdHTbmchB35SDznXO2g8Vz4D7GTIvY54iMiX_149c95f02a8\"}");
}
示例6: deleteIndex
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; //导入依赖的package包/类
public DeleteIndexResponse deleteIndex(final String index,
final BuilderCallback<DeleteIndexRequestBuilder> builder) {
final DeleteIndexResponse actionGet = builder
.apply(client().admin().indices().prepareDelete(index))
.execute().actionGet();
if (!actionGet.isAcknowledged()) {
onFailure("Failed to create " + index + ".", actionGet);
}
return actionGet;
}
示例7: deleteIndex
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; //导入依赖的package包/类
@Override
public synchronized BaseMetricTransportClient deleteIndex(String index) {
if (client == null) {
logger.warn("no client for delete index");
return this;
}
if (index == null) {
logger.warn("no index name given to delete index");
return this;
}
new DeleteIndexRequestBuilder(client(), DeleteIndexAction.INSTANCE, index).execute().actionGet();
return this;
}
示例8: deleteIndex
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; //导入依赖的package包/类
@Override
public void deleteIndex (String indexName) {
if(exists(indexName)){
final DeleteIndexRequestBuilder delIdx = client.admin().indices().prepareDelete(indexName);
delIdx.execute().actionGet();
}
}
示例9: prepareDelete
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; //导入依赖的package包/类
DeleteIndexRequestBuilder prepareDelete() {
logger.info(marker, "Deleting {}", kbId);
return client.admin().indices().prepareDelete(getIndexName());
}
示例10: assertAcked
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; //导入依赖的package包/类
public static void assertAcked(DeleteIndexRequestBuilder builder) {
assertAcked(builder.get());
}
示例11: prepareDelete
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; //导入依赖的package包/类
@Override
public DeleteIndexRequestBuilder prepareDelete(String... indices) {
return new DeleteIndexRequestBuilder(this, DeleteIndexAction.INSTANCE, indices);
}
示例12: cleanupOldIndexes
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; //导入依赖的package包/类
@Override
public void cleanupOldIndexes(String newIndexName, Map<String, Set<String>> indexAliases) {
String[] allIndexes = getAllIndexes();
List<String> allIndexList = Arrays.asList(allIndexes);
if (allIndexList != null && !allIndexList.isEmpty()) {
// Sort newest to oldest so that we can skip the newer indexes when
// deleting.
Collections.sort(allIndexList, (s1, s2) -> s1.compareTo(s2));
// Make sure the newest come first.
Collections.reverse(allIndexList);
int keepLastNumIndexes = 3;
// Map for context-aware counter.
Map<String, Integer> indexCounts = new HashMap<>();
List<String> indexesToDelete = new ArrayList<>();
for (String indexName : allIndexList) {
int lastIndexUnderscore = indexName.lastIndexOf(Char.UNDERSCORE);
if (lastIndexUnderscore < 0) {
continue;
}
String aliasName = indexName.substring(0, lastIndexUnderscore); // TODO
// ...
Integer count = indexCounts.get(aliasName);
if (count == null) {
count = 0;
indexCounts.put(aliasName, count);
}
if (count > keepLastNumIndexes && !isActive(indexName, indexAliases)
&& !indexName.equals(newIndexName)) {
log.info("Deleting inactive index " + indexName);
indexesToDelete.add(indexName);
}
indexCounts.put(aliasName, ++count);
}
if (!indexesToDelete.isEmpty()) {
log.info("Deleting indexes: " + indexesToDelete);
DeleteIndexRequestBuilder deleteIndexRequest = new DeleteIndexRequestBuilder(indicesAdminClient(),
indexesToDelete.toArray(new String[indexesToDelete.size()]));
DeleteIndexResponse deleteResponse = deleteIndexRequest.execute().actionGet();
log.info("DeleteIndexResponse isAcknowledged: " + deleteResponse.isAcknowledged());
}
}
}
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:58,代码来源:DefaultElasticsearchIndexHelper.java
示例13: removeIndices
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; //导入依赖的package包/类
private void removeIndices(IndicesAdminClient indices) {
DeleteIndexRequestBuilder chatsDeleteBuilder = new DeleteIndexRequestBuilder(indices, DeleteIndexAction.INSTANCE, "chats");
DeleteIndexRequestBuilder channelsDeleteBuilder = new DeleteIndexRequestBuilder(indices, DeleteIndexAction.INSTANCE, "channels");
indices.delete(chatsDeleteBuilder.request());
indices.delete(channelsDeleteBuilder.request());
}
示例14: MappingRDFToESServer
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; //导入依赖的package包/类
/**
* Mapping the properties of RDF meta model to Elasticsearch Server
* @param
* @return
*/
public void MappingRDFToESServer() throws IOException, InterruptedException{
String indexName = INDEX_NAME;
String documentType = DOCUMENT_TYPE;
//check if index is exist for a new clean index
IndicesExistsResponse resource = transportClient.admin().indices().prepareExists(indexName).execute().actionGet();
if (resource.isExists()) {
DeleteIndexRequestBuilder deleteIndex = transportClient.admin().indices().prepareDelete(indexName);
deleteIndex.execute().actionGet();
LOGGER.info("Index already exists, creating new clean index...");
}
CreateIndexRequestBuilder createIndexRequestBuilder = transportClient.admin().indices().prepareCreate(indexName);
// construct mapping
XContentBuilder builder = jsonBuilder()
.startObject()
.startObject(documentType)
.startObject("_meta")
.field("Title", "string")
.field("URI", "uri")
.field("Description", "string")
.endObject()
.endObject()
.endObject();
createIndexRequestBuilder.addMapping(documentType, builder);
createIndexRequestBuilder.execute().actionGet();
ResIterator listResources = rdfMetaDataModel.listSubjects();
long documentID = 0;
while (listResources.hasNext())
{
String uri = listResources.next().toString();
String titel = rdfMetaDataModel.listStatements(new ResourceImpl(uri), RDFS.label, (RDFNode) null)
.next().getObject().toString();
String description = rdfMetaDataModel.listStatements(new ResourceImpl(uri), RDFS.comment, (RDFNode) null)
.next().getObject().toString();
documentID++;
// Add documents
IndexRequestBuilder indexRequestBuilder = transportClient.prepareIndex(indexName, documentType, "" + documentID);
// build json object
final XContentBuilder contentBuilder = jsonBuilder().startObject().prettyPrint();
contentBuilder.field("Title", titel)
.field("URI", uri)
.field("Description", description);
indexRequestBuilder.setSource(contentBuilder);
indexRequestBuilder.execute().actionGet();
}
LOGGER.info( "RDF metadatamodel has been successfully mapped to elasticserach server.");
}
示例15: removeIndex
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; //导入依赖的package包/类
public void removeIndex(String index) throws Exception {
DeleteIndexRequestBuilder builder = client.admin().indices().prepareDelete(index);
DeleteIndexResponse response = builder.execute().actionGet();
}