dewey

Types

pub opaque type Client
pub type DeweyError {
  JSONDecodeError(err: json.DecodeError)
  APIError(
    message: String,
    code: String,
    error_type: String,
    link: String,
  )
  UnexpectedAPIError
}

Constructors

  • JSONDecodeError(err: json.DecodeError)
  • APIError(
      message: String,
      code: String,
      error_type: String,
      link: String,
    )
  • UnexpectedAPIError

A record containing the response from the Get Documents endpoint.

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#get-documents-with-post

pub type DocumentsResponse(document_type) {
  DocumentsResponse(
    results: List(document_type),
    offset: Int,
    limit: Int,
    total: Int,
  )
}

Constructors

  • DocumentsResponse(
      results: List(document_type),
      offset: Int,
      limit: Int,
      total: Int,
    )

A collection of options when using the Get Documents endpoint.

These options are outlined at: https://www.meilisearch.com/docs/reference/api/documents#body

pub type GetDocumentsOptions {
  GetDocumentsOptions(
    offset: Int,
    limit: Int,
    fields: option.Option(List(String)),
    filter: option.Option(String),
    retrieve_vectors: Bool,
    sort: option.Option(String),
    ids: option.Option(List(String)),
  )
}

Constructors

A collection of documents, much like a table in MySQL or a collection in MongoDB.

Indexes are outlined further at: https://www.meilisearch.com/docs/learn/getting_started/indexes

pub type Index {
  Index(
    uid: String,
    created_at: timestamp.Timestamp,
    updated_at: timestamp.Timestamp,
    primary_key: String,
  )
}

Constructors

pub type Operation(data_type) =
  #(
    request.Request(String),
    fn(response.Response(String)) -> Result(data_type, DeweyError),
  )
pub type ParseResponseFunc(data_type) =
  fn(response.Response(String)) -> Result(data_type, DeweyError)

Collection of Search Parameter records for adjusting the search functionality.

Keep in mind that some of these parameters change the structure of the documents returned. You will have to adjust your document decoder function to account for the changes caused. For this reason, it is important to read through the search API documentation to understand how each parameter can affect the document return type.

For more details visit this link: https://www.meilisearch.com/docs/reference/api/search#search-parameters

pub type SearchParam {
  SearchOffset(offset: Int)
  SearchLimit(limit: Int)
  SearchHitsPerPage(hits: Int)
  SearchPage(page_num: Int)
  SearchFilter(filter: String)
  SearchDistinctAttribute(attribute: String)
  SearchAttributesToRetrieve(attributes: List(String))
  SearchAttributesToCrop(attributes: List(String))
  SearchCropLength(length: Int)
  SearchCropMarker(marker: String)
  SearchAttributesToHighlight(attributes: List(String))
  SearchHighlightPreTag(pre_tag: String)
  SearchHighlighPostTag(post_tag: String)
  SearchShowMatchesPosition(show_matches_position: Bool)
  SearchSortAttributes(attributes: List(String))
  SearchMatchingStrategy(strategy: String)
  SearchShowRankingScore(show_ranking_score: Bool)
  SearchShowRankingScoreDetails(show_ranking_score_details: Bool)
  SearchRankingScoreThreshold(threshold: Float)
  SearchAttributesToSearchOn(attributes: List(String))
  SearchVector(vector: List(Float))
  SearchRetrieveVectors(retrieve_vectors: Bool)
  SearchLocales(locales: List(String))
}

Constructors

  • SearchOffset(offset: Int)
  • SearchLimit(limit: Int)
  • SearchHitsPerPage(hits: Int)
  • SearchPage(page_num: Int)
  • SearchFilter(filter: String)
  • SearchDistinctAttribute(attribute: String)
  • SearchAttributesToRetrieve(attributes: List(String))
  • SearchAttributesToCrop(attributes: List(String))
  • SearchCropLength(length: Int)
  • SearchCropMarker(marker: String)
  • SearchAttributesToHighlight(attributes: List(String))
  • SearchHighlightPreTag(pre_tag: String)
  • SearchHighlighPostTag(post_tag: String)
  • SearchShowMatchesPosition(show_matches_position: Bool)
  • SearchSortAttributes(attributes: List(String))
  • SearchMatchingStrategy(strategy: String)
  • SearchShowRankingScore(show_ranking_score: Bool)
  • SearchShowRankingScoreDetails(show_ranking_score_details: Bool)
  • SearchRankingScoreThreshold(threshold: Float)
  • SearchAttributesToSearchOn(attributes: List(String))
  • SearchVector(vector: List(Float))
  • SearchRetrieveVectors(retrieve_vectors: Bool)
  • SearchLocales(locales: List(String))
pub type SearchResponse(document_type) {
  SearchResponse(
    hits: List(document_type),
    offset: Int,
    limit: Int,
    estimated_total_hits: option.Option(Int),
    total_hits: option.Option(Int),
    total_pages: option.Option(Int),
    hits_per_page: option.Option(Int),
    processing_time_ms: Int,
    query: String,
    request_uid: String,
  )
}

Constructors

  • SearchResponse(
      hits: List(document_type),
      offset: Int,
      limit: Int,
      estimated_total_hits: option.Option(Int),
      total_hits: option.Option(Int),
      total_pages: option.Option(Int),
      hits_per_page: option.Option(Int),
      processing_time_ms: Int,
      query: String,
      request_uid: String,
    )

A summarized version of the Task type, returned as a response to endpoints that create a Task object. To retrieve a more detailed look at a task use the get_task function.

pub type SummarizedTask {
  SummarizedTask(
    task_uid: Int,
    index_uid: option.Option(String),
    status: TaskStatus,
    task_type: TaskType,
    enqueued_at: timestamp.Timestamp,
  )
}

Constructors

pub type Swap {
  Swap(swapped_indexes: #(String, String), rename: Bool)
}

Constructors

  • Swap(swapped_indexes: #(String, String), rename: Bool)

A detailed description of a task generated by asynchronous endpoints.

pub type Task {
  Task(
    uid: Int,
    index_uid: option.Option(String),
    batch_uid: Int,
    status: TaskStatus,
    task_type: TaskType,
    canceled_by: option.Option(Int),
    details: option.Option(TaskDetails),
    error: option.Option(TaskError),
    enqueued_at: timestamp.Timestamp,
    started_at: option.Option(timestamp.Timestamp),
    finished_at: option.Option(timestamp.Timestamp),
  )
}

Constructors

A record describing the details of a specific task.

pub type TaskDetails {
  DocumentAdditionOrUpdateDetails(
    received_documents: Int,
    indexed_documents: option.Option(Int),
  )
  DocumentDeletionDetails(
    provided_ids: Int,
    original_filter: option.Option(String),
    deleted_documents: option.Option(Int),
  )
  IndexCreationOrUpdateDetails(
    primary_key: option.Option(String),
  )
  IndexDeletionDetails(deleted_documents: option.Option(Int))
  IndexSwapDetails(swaps: List(Swap))
  SettingsUpdateDetails(
    ranking_rules: option.Option(List(String)),
    distinct_attribute: option.Option(String),
    searchable_attributes: option.Option(List(String)),
    displayed_attributes: option.Option(List(String)),
    sortable_attributes: option.Option(List(String)),
    stop_words: option.Option(List(String)),
  )
  DumpCreationDetails(dump_uid: option.Option(String))
  TaskCancelationDetails(
    matched_tasks: Int,
    canceled_tasks: option.Option(Int),
    original_filter: String,
  )
  TaskDeletionDetails(
    matched_tasks: Int,
    deleted_tasks: option.Option(Int),
    original_filter: String,
  )
}

Constructors

  • DocumentAdditionOrUpdateDetails(
      received_documents: Int,
      indexed_documents: option.Option(Int),
    )
  • DocumentDeletionDetails(
      provided_ids: Int,
      original_filter: option.Option(String),
      deleted_documents: option.Option(Int),
    )
  • IndexCreationOrUpdateDetails(primary_key: option.Option(String))
  • IndexDeletionDetails(deleted_documents: option.Option(Int))
  • IndexSwapDetails(swaps: List(Swap))
  • SettingsUpdateDetails(
      ranking_rules: option.Option(List(String)),
      distinct_attribute: option.Option(String),
      searchable_attributes: option.Option(List(String)),
      displayed_attributes: option.Option(List(String)),
      sortable_attributes: option.Option(List(String)),
      stop_words: option.Option(List(String)),
    )
  • DumpCreationDetails(dump_uid: option.Option(String))
  • TaskCancelationDetails(
      matched_tasks: Int,
      canceled_tasks: option.Option(Int),
      original_filter: String,
    )
  • TaskDeletionDetails(
      matched_tasks: Int,
      deleted_tasks: option.Option(Int),
      original_filter: String,
    )

An error message that can accompany a failed task.

pub type TaskError {
  TaskError(
    message: String,
    code: String,
    error_type: String,
    link: String,
  )
}

Constructors

  • TaskError(
      message: String,
      code: String,
      error_type: String,
      link: String,
    )

The current status of a task.

pub type TaskStatus {
  Enqueued
  Processing
  Succeeded
  Failed
  Canceled
  UnexpectedTaskStatus
}

Constructors

  • Enqueued
  • Processing
  • Succeeded
  • Failed
  • Canceled
  • UnexpectedTaskStatus

The type of task.

pub type TaskType {
  IndexCreation
  IndexUpdate
  IndexDeletion
  IndexSwap
  DocumentAdditionOrUpdate
  DocumentDeletion
  SettingsUpdate
  DumpCreation
  TaskCancelation
  TaskDeletion
  UpgradeDatabase
  DocumentEdition
  SnapshotCreation
  UnexpectedTaskType
}

Constructors

  • IndexCreation
  • IndexUpdate
  • IndexDeletion
  • IndexSwap
  • DocumentAdditionOrUpdate
  • DocumentDeletion
  • SettingsUpdate
  • DumpCreation
  • TaskCancelation
  • TaskDeletion
  • UpgradeDatabase
  • DocumentEdition
  • SnapshotCreation
  • UnexpectedTaskType
pub type TasksParam {
  TasksByUIDs(List(Int))
  TasksByBatchUIDs(List(Int))
  TasksByStatuses(List(TaskStatus))
  TasksByTypes(List(TaskType))
  TasksByIndexUIDs(List(String))
  TasksLimit(Int)
  TasksFromTaskUID(Int)
  TasksInReverse(Bool)
  TasksBeforeEnqueuedAt(timestamp.Timestamp)
  TasksAfterEnqueuedAt(timestamp.Timestamp)
  TasksBeforeStartedAt(timestamp.Timestamp)
  TasksAfterStartedAt(timestamp.Timestamp)
  TasksBeforeFinishedAt(timestamp.Timestamp)
  TasksAfterFinishedAt(timestamp.Timestamp)
}

Constructors

Values

pub fn add_or_replace_documents(
  client: Client,
  index_uid: String,
  documents: List(document_type),
  document_encoder: fn(document_type) -> json.Json,
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    SummarizedTask,
    DeweyError,
  ),
)

Returns an Operation record for the Add or Replace Documents endpoint.

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#add-or-replace-documents

pub fn add_or_update_documents(
  client: Client,
  index_uid: String,
  documents: List(document_type),
  document_encoder: fn(document_type) -> json.Json,
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    SummarizedTask,
    DeweyError,
  ),
)

Returns an Operation record for the Add or Update Documents endpoint.

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#add-or-update-documents

pub fn cancel_tasks(
  client: Client,
  params: List(TasksParam),
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    SummarizedTask,
    DeweyError,
  ),
)
pub fn create_index(
  client: Client,
  index_uid: String,
  primary_key: option.Option(String),
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    SummarizedTask,
    DeweyError,
  ),
)

Returns an Operation record for the Create Index endpoint

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/indexes#create-an-index

pub fn default_get_documents_options() -> GetDocumentsOptions

A function returning the default set of options for the Get Documents endpoint.

These options are outlined at: https://www.meilisearch.com/docs/reference/api/documents#body

pub fn delete_all_documents(
  client: Client,
  index_uid: String,
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    SummarizedTask,
    DeweyError,
  ),
)

Returns an Operation record for the Delete All Documents endpoint.

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#delete-all-documents

pub fn delete_all_tasks(
  client: Client,
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    SummarizedTask,
    DeweyError,
  ),
)
pub fn delete_documents_by_batch(
  client: Client,
  index_uid: String,
  batch: List(String),
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    SummarizedTask,
    DeweyError,
  ),
)

Returns an Operation record for the Delete Documents by Batch endpoint.

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#delete-documents-by-batch

pub fn delete_documents_by_filter(
  client: Client,
  index_uid: String,
  filter: String,
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    SummarizedTask,
    DeweyError,
  ),
)

Returns an Operation record for the Delete Documents by Filter endpoint.

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#delete-documents-by-filter

pub fn delete_index(
  client: Client,
  index_uid: String,
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    SummarizedTask,
    DeweyError,
  ),
)

Returns an Operation record for the Delete Index endpoint.

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/indexes#delete-an-index

pub fn delete_one_document(
  client: Client,
  index_uid: String,
  document_id: String,
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    SummarizedTask,
    DeweyError,
  ),
)

Returns an Operation record for the Delete One Document endpoint.

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#delete-one-document

pub fn delete_tasks(
  client: Client,
  params: List(TasksParam),
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    SummarizedTask,
    DeweyError,
  ),
)
pub fn get_all_indexes(
  client: Client,
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(List(Index), DeweyError),
)

Returns an Operation record for the Get All Indexes endpoint

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/indexes#list-all-indexes

pub fn get_documents(
  client: Client,
  index_uid: String,
  options: GetDocumentsOptions,
  documents_decoder: decode.Decoder(document_type),
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    DocumentsResponse(document_type),
    DeweyError,
  ),
)

Returns an Operation record for the Get Documents endpoint.

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#get-documents-with-post

pub fn get_one_document(
  client: Client,
  index_uid: String,
  document_id: String,
  document_decoder: decode.Decoder(document_type),
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    document_type,
    DeweyError,
  ),
)

Returns an Operation record for the Get One Document endpoint.

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/documents#get-one-document

pub fn get_one_index(
  client: Client,
  index_uid: String,
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(Index, DeweyError),
)

Returns an Operation record for the Get One Index endpoint

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/indexes#get-one-index

pub fn get_one_task(
  client: Client,
  task_uid: Int,
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(Task, DeweyError),
)
pub fn get_tasks(
  client: Client,
  params: List(TasksParam),
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(List(Task), DeweyError),
)
pub fn new_client(
  url: String,
  api_key: String,
) -> Result(Client, Nil)
pub fn rename_indexes(
  client: Client,
  index_uids_to_swap: List(#(String, String)),
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    SummarizedTask,
    DeweyError,
  ),
)

Returns an Operation record for the Swap Indexes endpoint, utilizing the rename parameter.

This function includes the rename parameter within the request body, meaning that the first index_uid will be renamed to the second index_uid listed (assuming the second uid does not exist).

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/indexes#swap-indexes

pub fn search(
  client: Client,
  index_uid: String,
  query: String,
  document_decoder: decode.Decoder(document_type),
  params: List(SearchParam),
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    SearchResponse(document_type),
    DeweyError,
  ),
)

Returns an Operation record for the Search endpoint

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/search#search-in-an-index-with-post

pub fn swap_indexes(
  client: Client,
  index_uids_to_swap: List(#(String, String)),
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    SummarizedTask,
    DeweyError,
  ),
)

Returns an Operation record for the Swap Indexes endpoint

This function does not include the rename parameter, and therefore does not rename indexes when the second index does not exist. To rename indexes, use the rename_indexes function instead.

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/indexes#swap-indexes

pub fn update_index(
  client: Client,
  index_uid: String,
  new_primary_key: option.Option(String),
) -> #(
  request.Request(String),
  fn(response.Response(String)) -> Result(
    SummarizedTask,
    DeweyError,
  ),
)

Returns an Operation record for the Update Index endpoint

This endpoint is outlined at: https://www.meilisearch.com/docs/reference/api/indexes#update-an-index

Search Document