@Override
    public void removeTask(String workflowId, String taskId) {
        try {
            long startTime = Instant.now().toEpochMilli();
            String docType = StringUtils.isBlank(docTypeOverride) ? TASK_DOC_TYPE : docTypeOverride;

            SearchResult<String> taskSearchResult =
                    searchTasks(
                            String.format(
                                    "(taskId='%s') AND (workflowId='%s')", taskId, workflowId),
                            "*",
                            0,
                            1,
                            null);

            if (taskSearchResult.getTotalHits() == 0) {
                LOGGER.error("Task: {} does not belong to workflow: {}", taskId, workflowId);
                Monitors.error(CLASS_NAME, "removeTask");
                return;
            }

            DeleteRequest request = new DeleteRequest(taskIndexName, docType, taskId);
            DeleteResponse response = elasticSearchClient.delete(request).actionGet();
            long endTime = Instant.now().toEpochMilli();

            if (response.getResult() != DocWriteResponse.Result.DELETED) {
                LOGGER.error(
                        "Index removal failed - task not found by id: {} of workflow: {}",
                        taskId,
                        workflowId);
                Monitors.error(CLASS_NAME, "removeTask");
                return;
            }
            LOGGER.debug(
                    "Time taken {} for removing task:{} of workflow: {}",
                    endTime - startTime,
                    taskId,
                    workflowId);
            Monitors.recordESIndexTime("remove_task", docType, endTime - startTime);
            Monitors.recordWorkerQueueSize(
                    "indexQueue", ((ThreadPoolExecutor) executorService).getQueue().size());
        } catch (Exception e) {
            LOGGER.error(
                    "Failed to remove task: {} of workflow: {} from index", taskId, workflowId, e);
            Monitors.error(CLASS_NAME, "removeTask");
        }
    }
Initializes the indexes templates task_log, message and event, and mappings.
es6-persistence/src/main/java/com/netflix/conductor/es6/dao/index/ElasticSearchDAOV6.java