Tasks

Overview

Some light operations like updating search index mapping schema or changing configuration of search query finishes instantly, but heavier, time-consuming operations like indexing or document import are being processed asynchronously. In asynchronous operation the job is placed into the queue and process duration depends on queue load, index data volume, operation type. To check job status whether the dispatched process is still in-progress or already finished you can use tasks feature. Each task is associated with related search index and it can be filtered by using batchKey or dateFrom parameters.

How to get batchKey of task

Request to asynchronous action endpoint will return response with batchKey that you can use to filter index tasks and check the progress of the exact task group.

Request example for reindex action:

POST /v1/indices/0339ade3-6f70-4d3b-be18-eec79a350d89/reindex

Response:

{
  "success": true,
  "batchKey": "reindex-1537374221028-f5q"
}

How to get all existing tasks for search index Docs

To retrieve list of all tasks for specific search index, you need to send HTTP GET request to /v1/indices/{indexId}/tasks endpoint. Additionally, you can filter results with query parameters dateFrom and batchKey.

Request example:

GET /v1/indices/0339ade3-6f70-4d3b-be18-eec79a350d89/tasks?dateFrom=2021-01-01T17:30:00&batchKey=reindex-1537374221028-f5q

Query parameters:

  • dateFrom - date filter to return records that were created after the given date. ISO format.
  • batchKey - task grouping key, same key can be assigned to the multiple tasks of the same operation

Response example:

[
  {
    "id": "28f5262c-6d64-45b8-8203-6c87f7eb7d4a",
    "actionType": "reindex",
    "batchKey": "reindex-1537374221028-f5q",
    "status": "FINISHED",
    "createdAt": "2021-01-21T10:10:10.000Z",
    "updatedAt": "2021-01-21T10:10:11.000Z",
    "errors": []
  }
]

Action types

  • documents-import - queued job of document import or document replacement action. This task is finished when documents are imported into the search index.
  • document-reindex-end - queued job of document replacement action. This task is finished when all existing documents of the search index are replaced with the documents provided in document replacement request(s).
  • suggestions-import - queued job of suggestions import action. This task is finished when custom suggestions are imported into the search index.
  • synonym-update - queued job of create new synonyms or delete existing synonyms actions. This task is finished when new synonyms are imported into the search index or specified synonyms are removed.
  • reindex-to-other-index-end - queued job of search index reindex action. This task is finished when all documents and configuration of the source search index are moved into the temporary search index and it is ready to use.
  • suggestions-generate - queued job of generate suggestions action. This task is finished when suggestions are generated and placed into the suggestion search index based on data and configuration of the source search index.

Possible task statuses

  • CREATED - task is created and placed in the queue, it is waiting for its turn to be processed
  • IN_PROGRESS - task is in progress and will be finished shortly
  • FINISHED - the progress of task is finished
  • FAILED - the task was interrupted with error, check the details of failure in errors response parameter