View Source Meilisearch.Document (meilisearch_ex v1.1.2)

Manipulate Meilisearch documents. Documents are not parsed into anything and are returned as plain maps with string keys. Document API

Link to this section Summary

Functions

Create or update a Documents into an Index in your Meilisearch instance. Meilisearch documentation

Create or update a Documents into an Index in your Meilisearch instance. Meilisearch documentation

Delete all Documents of an Index in your Meilisearch instance. Meilisearch documentation

Delete a batch of Documents of an Index in your Meilisearch instance. Meilisearch documentation

Delete one Documents of an Index in your Meilisearch instance. Meilisearch documentation

Get an Document of an Index in your Meilisearch instance. Meilisearch documentation

List Documents of an Index of your Meilisearch instance. Meilisearch documentation

Link to this section Types

@type document_id() :: String.t() | integer()
@type t() :: map()

Link to this section Functions

Link to this function

create_or_replace(client, index_uid, params)

View Source
@spec create_or_replace(Tesla.Client.t(), String.t(), [t()] | t()) ::
  {:ok, Meilisearch.SummarizedTask.t()} | {:error, Meilisearch.Client.error()}

Create or update a Documents into an Index in your Meilisearch instance. Meilisearch documentation

examples

Examples

iex> client = Meilisearch.Client.new(endpoint: "http://localhost:7700", key: "master_key_test")
iex> Meilisearch.Document.create_or_replace(client, "movies", [%{id: 25684, title: "American Ninja 5"}])
{:ok, %{
  taskUid: 0,
  indexUid: "movies",
  status: :enqueued,
  type: :documentAdditionOrUpdate,
  enqueuedAt: ~U[2021-08-12 10:00:00]
}}
Link to this function

create_or_update(client, index_uid, params)

View Source
@spec create_or_update(Tesla.Client.t(), String.t(), [t()] | t()) ::
  {:ok, Meilisearch.SummarizedTask.t()} | {:error, Meilisearch.Client.error()}

Create or update a Documents into an Index in your Meilisearch instance. Meilisearch documentation

examples

Examples

iex> client = Meilisearch.Client.new(endpoint: "http://localhost:7700", key: "master_key_test")
iex> Meilisearch.Document.create_or_update(client, "movies", [%{id: 25684, title: "American Ninja 5"}])
{:ok, %{
  taskUid: 0,
  indexUid: "movies",
  status: :enqueued,
  type: :documentAdditionOrUpdate,
  enqueuedAt: ~U[2021-08-12 10:00:00]
}}
Link to this function

delete_all(client, index_uid)

View Source
@spec delete_all(Tesla.Client.t(), String.t()) ::
  {:ok, Meilisearch.SummarizedTask.t()} | {:error, Meilisearch.Client.error()}

Delete all Documents of an Index in your Meilisearch instance. Meilisearch documentation

examples

Examples

iex> client = Meilisearch.Client.new(endpoint: "http://localhost:7700", key: "master_key_test")
iex> Meilisearch.Document.delete_all(client, "movies")
{:ok, %{
  taskUid: 0,
  indexUid: "movies",
  status: :enqueued,
  type: :documentDeletion,
  enqueuedAt: ~U[2021-08-12 10:00:00]
}}
Link to this function

delete_batch(client, index_uid, document_ids)

View Source
@spec delete_batch(Tesla.Client.t(), String.t(), [document_id()]) ::
  {:ok, Meilisearch.SummarizedTask.t()} | {:error, Meilisearch.Client.error()}

Delete a batch of Documents of an Index in your Meilisearch instance. Meilisearch documentation

examples

Examples

iex> client = Meilisearch.Client.new(endpoint: "http://localhost:7700", key: "master_key_test")
iex> Meilisearch.Document.delete_batch(client, "movies", [25684, 12435])
{:ok, %{
  taskUid: 0,
  indexUid: "movies",
  status: :enqueued,
  type: :documentDeletion,
  enqueuedAt: ~U[2021-08-12 10:00:00]
}}
Link to this function

delete_one(client, index_uid, document_id)

View Source
@spec delete_one(Tesla.Client.t(), String.t(), document_id()) ::
  {:ok, Meilisearch.SummarizedTask.t()} | {:error, Meilisearch.Client.error()}

Delete one Documents of an Index in your Meilisearch instance. Meilisearch documentation

examples

Examples

iex> client = Meilisearch.Client.new(endpoint: "http://localhost:7700", key: "master_key_test")
iex> Meilisearch.Document.delete_one(client, "movies", 25684)
{:ok, %{
  taskUid: 0,
  indexUid: "movies",
  status: :enqueued,
  type: :documentDeletion,
  enqueuedAt: ~U[2021-08-12 10:00:00]
}}
Link to this function

get(client, index_uid, document_id)

View Source
@spec get(Tesla.Client.t(), String.t(), document_id()) ::
  {:ok, t()} | {:error, Meilisearch.Client.error()}

Get an Document of an Index in your Meilisearch instance. Meilisearch documentation

examples

Examples

iex> client = Meilisearch.Client.new(endpoint: "http://localhost:7700", key: "master_key_test")
iex> Meilisearch.Document.get(client, "movies", 25684)
{:ok, %{
  "id" => 25684,
  "title" => "American Ninja 5"
}}
Link to this function

list(client, index_uid, opts \\ [])

View Source
@spec list(Tesla.Client.t(), String.t(),
  offset: integer(),
  limit: integer(),
  fields: [String.t()]
) ::
  {:ok, Meilisearch.Pagination.t(t())} | {:error, Meilisearch.Client.error()}

List Documents of an Index of your Meilisearch instance. Meilisearch documentation

examples

Examples

iex> client = Meilisearch.Client.new(endpoint: "http://localhost:7700", key: "master_key_test")
iex> Meilisearch.Document.list(client, "movies", limit: 20, offset: 0)
{:ok, %{offset: 0, limit: 20, total: 1, results: [%{
  "id" => 2001,
  "title" => "2001: A Space Odyssey"
}]}}