Manages and monitors asynchronous Meilisearch tasks.
Summary
Functions
Cancels one or more tasks based on filters.
Cancels tasks, raising on error.
Deletes one or more finished tasks based on filters.
Deletes finished tasks, raising on error.
Retrieves details of a single task.
Retrieves details of a single task, raising on error.
Lists all tasks.
Lists all tasks, raising on error.
Waits for a task to succeed or fail.
Waits for a task to succeed or fail, raising a Meili.Error on failure or timeout.
Functions
@spec cancel(Meili.Client.t() | Keyword.t() | nil, Keyword.t()) :: {:ok, map()} | {:error, Meili.Error.t()}
Cancels one or more tasks based on filters.
Examples
Meili.Task.cancel(statuses: [:enqueued, :processing])
Meili.Task.cancel(client, index_uids: ["movies"])
@spec cancel!(Meili.Client.t() | Keyword.t() | nil, Keyword.t()) :: map() | no_return()
Cancels tasks, raising on error.
@spec delete(Meili.Client.t() | Keyword.t() | nil, Keyword.t()) :: {:ok, map()} | {:error, Meili.Error.t()}
Deletes one or more finished tasks based on filters.
Examples
Meili.Task.delete(statuses: [:succeeded, :failed])
Meili.Task.delete(client, uids: [1, 2, 3])
@spec delete!(Meili.Client.t() | Keyword.t() | nil, Keyword.t()) :: map() | no_return()
Deletes finished tasks, raising on error.
@spec get(Meili.Client.t() | integer() | String.t(), integer() | String.t() | nil) :: {:ok, map()} | {:error, Meili.Error.t()}
Retrieves details of a single task.
Examples
Meili.Task.get(12)
Meili.Task.get(client, 12)
@spec get!(Meili.Client.t() | integer() | String.t(), integer() | String.t() | nil) :: map() | no_return()
Retrieves details of a single task, raising on error.
@spec list(Meili.Client.t() | Keyword.t() | nil, Keyword.t()) :: {:ok, map()} | {:error, Meili.Error.t()}
Lists all tasks.
Supports options for filtering and pagination. List values are automatically joined as comma-separated strings.
Options
limit: Max tasks to return.from: Start task uid.uids: List or comma-separated string of task uids.statuses: List or comma-separated string of statuses.types: List or comma-separated string of types.index_uids/indexUids: List or comma-separated string of index uids.
Examples
Meili.Task.list(statuses: [:succeeded, :failed])
Meili.Task.list(client, limit: 10)
@spec list!(Meili.Client.t() | Keyword.t() | nil, Keyword.t()) :: map() | no_return()
Lists all tasks, raising on error.
@spec wait_for_task( Meili.Client.t() | integer() | String.t(), integer() | String.t() | Keyword.t(), Keyword.t() ) :: {:ok, map()} | {:error, :timeout | Meili.Error.t()}
Waits for a task to succeed or fail.
Options
timeout: Maximum time in milliseconds to wait (default:5000).interval: Milliseconds to sleep between polls (default:50).
Examples
{:ok, task} = Meili.Task.wait_for_task(12)
{:ok, task} = Meili.Task.wait_for_task(client, 12, timeout: 10_000)
@spec wait_for_task!( Meili.Client.t() | integer() | String.t(), integer() | String.t() | Keyword.t(), Keyword.t() ) :: map() | no_return()
Waits for a task to succeed or fail, raising a Meili.Error on failure or timeout.
If the task completes but has a status of "failed", it raises a Meili.Error
constructed from the task's inner error.
Examples
task = Meili.Task.wait_for_task!(12)
task = Meili.Task.wait_for_task!(client, 12, timeout: 10_000)