Java Code Examples for org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest#indicesOptions()

The following examples show how to use org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest#indicesOptions() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DropTableTask.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
private void deleteESIndex(String indexOrAlias) {
    DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indexOrAlias);
    deleteIndexRequest.putHeader(LoginUserContext.USER_INFO_KEY, this.getParamContext().getLoginUserContext());
    if (tableInfo.isPartitioned()) {
        deleteIndexRequest.indicesOptions(IndicesOptions.lenientExpandOpen());
    }
    deleteIndexAction.execute(deleteIndexRequest, new ActionListener<DeleteIndexResponse>() {
        @Override
        public void onResponse(DeleteIndexResponse response) {
            if (!response.isAcknowledged()) {
                warnNotAcknowledged(String.format(Locale.ENGLISH, "dropping table '%s'", tableInfo.ident().fqn()));
            }
            result.set(SUCCESS_RESULT);
        }

        @Override
        public void onFailure(Throwable e) {
            if (tableInfo.isPartitioned()) {
                logger.warn("Could not (fully) delete all partitions of {}. " +
                        "Some orphaned partitions might still exist, " +
                        "but are not accessible.", e, tableInfo.ident().fqn());
            }
            if (ifExists && e instanceof IndexNotFoundException) {
                result.set(TaskResult.ZERO);
            } else {
                result.setException(e);
            }
        }
    });
}
 
Example 2
Source File: RestDeleteIndexAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(Strings.splitStringByCommaToArray(request.param("index")));
    deleteIndexRequest.timeout(request.paramAsTime("timeout", deleteIndexRequest.timeout()));
    deleteIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteIndexRequest.masterNodeTimeout()));
    deleteIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, deleteIndexRequest.indicesOptions()));
    client.admin().indices().delete(deleteIndexRequest, new AcknowledgedRestListener<DeleteIndexResponse>(channel));
}
 
Example 3
Source File: ElasticSearchService.java    From pybbs with GNU Affero General Public License v3.0 5 votes vote down vote up
public boolean deleteIndex() {
    try {
        if (this.instance() == null) return false;
        DeleteIndexRequest request = new DeleteIndexRequest(name);
        request.indicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN);
        AcknowledgedResponse response = client.indices().delete(request, RequestOptions.DEFAULT);
        return response.isAcknowledged();
    } catch (IOException e) {
        log.error(e.getMessage());
        return false;
    }
}
 
Example 4
Source File: DeletePlanner.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void executeOrFail(DependencyCarrier executor,
    PlannerContext plannerContext,
    RowConsumer consumer,
    Row params,
    SubQueryResults subQueryResults) {

    WhereClause where = detailedQuery.toBoundWhereClause(
        table.tableInfo(),
        executor.functions(),
        params,
        subQueryResults,
        plannerContext.transactionContext()
    );
    if (!where.partitions().isEmpty() && !where.hasQuery()) {
        DeleteIndexRequest request = new DeleteIndexRequest(where.partitions().toArray(new String[0]));
        request.indicesOptions(IndicesOptions.lenientExpandOpen());
        executor.transportActionProvider().transportDeleteIndexAction()
            .execute(request, new OneRowActionListener<>(consumer, o -> new Row1(-1L)));
        return;
    }

    ExecutionPlan executionPlan = deleteByQuery(table, plannerContext, where);
    NodeOperationTree nodeOpTree = NodeOperationTreeGenerator.fromPlan(executionPlan, executor.localNodeId());
    executor.phasesTaskFactory()
        .create(plannerContext.jobId(), Collections.singletonList(nodeOpTree))
        .execute(consumer, plannerContext.transactionContext());
}
 
Example 5
Source File: DeletePartitions.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void executeOrFail(DependencyCarrier dependencies,
                          PlannerContext plannerContext,
                          RowConsumer consumer,
                          Row params,
                          SubQueryResults subQueryResults) {
    ArrayList<String> indexNames = getIndices(
        plannerContext.transactionContext(), dependencies.functions(), params, subQueryResults);
    DeleteIndexRequest request = new DeleteIndexRequest(indexNames.toArray(new String[0]));
    request.indicesOptions(IndicesOptions.lenientExpandOpen());
    dependencies.transportActionProvider().transportDeleteIndexAction()
        .execute(request, new OneRowActionListener<>(consumer, r -> Row1.ROW_COUNT_UNKNOWN));
}