Search in sources :

Example 31 with DeleteIndexRequest

use of org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest in project sonarqube by SonarSource.

the class EsTester method deleteIndexIfExists.

private static void deleteIndexIfExists(String name) {
    try {
        AcknowledgedResponse response = ES_REST_CLIENT.nativeClient().indices().delete(new DeleteIndexRequest(name), RequestOptions.DEFAULT);
        checkState(response.isAcknowledged(), "Fail to drop the index " + name);
    } catch (ElasticsearchStatusException e) {
        if (e.status().getStatus() == 404) {
        // ignore, index not found
        } else {
            throw e;
        }
    } catch (IOException e) {
        throw new IllegalStateException("Could not delete index", e);
    }
}
Also used : AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) IOException(java.io.IOException) ElasticsearchStatusException(org.elasticsearch.ElasticsearchStatusException)

Example 32 with DeleteIndexRequest

use of org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest in project elasticsearch-skywalker by jprante.

the class AbstractNodeTest method deleteIndices.

@AfterMethod
public void deleteIndices() {
    try {
        // clear test index
        client("1").admin().indices().delete(new DeleteIndexRequest().indices(INDEX)).actionGet();
    } catch (IndexMissingException e) {
    // ignore
    }
    closeNode("1");
    closeAllNodes();
}
Also used : DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) IndexMissingException(org.elasticsearch.indices.IndexMissingException) AfterMethod(org.testng.annotations.AfterMethod)

Example 33 with DeleteIndexRequest

use of org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest in project pancm_project by xuwujing.

the class EsHighLevelRestTest1 method deleteIndex.

/**
 * 删除索引
 *
 * @throws IOException
 */
private static void deleteIndex() throws IOException {
    String index = "userindex";
    DeleteIndexRequest request = new DeleteIndexRequest(index);
    // 同步删除
    client.indices().delete(request, RequestOptions.DEFAULT);
    System.out.println("删除索引库成功!" + index);
}
Also used : DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)

Example 34 with DeleteIndexRequest

use of org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest in project crate by crate.

the class AlterTableOperation method deleteIndex.

private CompletableFuture<Long> deleteIndex(String... indexNames) {
    DeleteIndexRequest request = new DeleteIndexRequest(indexNames);
    FutureActionListener<AcknowledgedResponse, Long> listener = new FutureActionListener<>(r -> 0L);
    transportDeleteIndexAction.execute(request, listener);
    return listener;
}
Also used : AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) FutureActionListener(io.crate.action.FutureActionListener)

Example 35 with DeleteIndexRequest

use of org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest in project crate by crate.

the class DeleteAllPartitions method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier executor, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
    if (partitions.isEmpty()) {
        consumer.accept(InMemoryBatchIterator.of(new Row1(0L), SentinelRow.SENTINEL), null);
    } else {
        /*
             * table is partitioned, in case of concurrent "delete from partitions"
             * it could be that some partitions are already deleted,
             * so ignore it if some are missing
             */
        DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(partitions().toArray(new String[0])).indicesOptions(IndicesOptions.lenientExpandOpen());
        executor.transportActionProvider().transportDeleteIndexAction().execute(deleteIndexRequest, new OneRowActionListener<>(consumer, r -> Row1.ROW_COUNT_UNKNOWN));
    }
}
Also used : DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) InMemoryBatchIterator(io.crate.data.InMemoryBatchIterator) RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) List(java.util.List) Row(io.crate.data.Row) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) IndicesOptions(org.elasticsearch.action.support.IndicesOptions) OneRowActionListener(io.crate.execution.support.OneRowActionListener) SentinelRow(io.crate.data.SentinelRow) Row1(io.crate.data.Row1) Row1(io.crate.data.Row1) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)

Aggregations

DeleteIndexRequest (org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)37 IOException (java.io.IOException)15 DeleteIndexResponse (org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse)15 CreateIndexRequest (org.elasticsearch.action.admin.indices.create.CreateIndexRequest)13 IndicesExistsRequest (org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest)12 PutMappingResponse (org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse)9 ArrayList (java.util.ArrayList)6 AcknowledgedResponse (org.elasticsearch.action.support.master.AcknowledgedResponse)6 List (java.util.List)5 Row1 (io.crate.data.Row1)3 OneRowActionListener (io.crate.execution.support.OneRowActionListener)3 BulkRequest (org.elasticsearch.action.bulk.BulkRequest)3 MultiGetRequest (org.elasticsearch.action.get.MultiGetRequest)3 MultiSearchRequest (org.elasticsearch.action.search.MultiSearchRequest)3 SearchRequest (org.elasticsearch.action.search.SearchRequest)3 FutureActionListener (io.crate.action.FutureActionListener)2 Row (io.crate.data.Row)2 RowConsumer (io.crate.data.RowConsumer)2 DependencyCarrier (io.crate.planner.DependencyCarrier)2 Plan (io.crate.planner.Plan)2