Task Management

Solr offers a task management framework, that allows users to monitor (and even cancel) certain types of long-running tasks. Queries are the only type of "task" currently supported, but additional types may be added in the future.

Registering Tasks for Task Management

Task-tracking and management is an opt-in feature: tracking must be explicitly enabled on each individual task. For queries (the only type of "task" currently supported), this is done by specifying the canCancel boolean flag as a query-parameter. A value of true enables task-management; false (the default) leaves it disabled.

Solr will assign each task a UUID for tracking purposes. Users may override this if desired with an arbitrary string of their choice using the queryUUID query-parameter. (Users are responsible for ensuring that any queryUUID values they provide are unique and don’t conflict with other running tasks.) This UUID, whether generated or provided by the user, can then be used to track or cancel the task.

Task Management Operations

Task management interface supports the following types of operations:

  1. List all currently running cancellable tasks.

  2. Cancel a specific task.

  3. Query the status of a specific task.

Listing All Active Cancellable Tasks

To list all the active cancellable tasks currently running, please use the following syntax:

V1 API

curl -X GET "http://localhost:8983/solr/collectionName/tasks/list"
bash

V2 API

curl -X GET "http://localhost:8983/v2/collections/collectionName/tasks/list"
bash

Sample Response

{
  "responseHeader":{
    "status":0,
    "QTime":16},
  "taskList":[
    "0,"q=weight_i:[0+TO+200]&canCancel=true&queryUUID=0",
    "5","q=weight_i:[0+TO+200]&canCancel=true&queryUUID=5",
    "4bcd27bb-0792-4512-a699-532fa7878bd3","q=weight_i:[0+TO+200]&canCancel=true"]}

Cancelling An Active Cancellable Task

To cancel an active task, please use the following syntax:

V1 API

curl -X GET "http://localhost:8983/solr/collectionName/tasks/cancel?queryUUID=5"
bash

V2 API

curl -X GET "http://localhost:8983/v2/collections/collectionName/tasks/cancel?queryUUID=5"
bash

Sample Response

If the task UUID was found and successfully cancelled:

{
  "responseHeader":{
    "status":0,
    "QTime":26},
  "status":"Query with queryID 5 cancelled successfully",
  "responseCode":200}

If the task UUID was not found

{
  "responseHeader":{
    "status":0,
    "QTime":24},
  "status":"Query with queryID 5 not found",
  "responseCode":404}

Check Status of a Specific Task

To check the status of a specific task, please use the following syntax:

V1 API

curl -X GET "http://localhost:8983/solr/collectionName/tasks/list?taskUUID=5"
bash

V2 API

curl -X GET "http://localhost:8983/v2/collections/collectionName/tasks/list?taskUUID=5"
bash

taskUUID Parameter

taskUUID parameter can be used to specify a task UUID whose status can be checked.

Sample Response

{
  "responseHeader":{
    "status":0,
    "QTime":16},
  "taskStatus":"id:5, status: active"}