Manages Meilisearch documents in an index.
Summary
Functions
Adds or replaces documents in an index.
Adds or replaces documents in an index, raising on error.
Adds or updates documents in an index.
Adds or updates documents in an index, raising on error.
Deletes a single document by its ID.
Deletes a single document by its ID, raising on error.
Deletes all documents in an index.
Deletes all documents in an index, raising on error.
Deletes a batch of documents by their IDs.
Deletes a batch of documents by their IDs, raising on error.
Edits documents using update functions/queries.
Edits documents, raising on error.
Gets a single document by its ID.
Gets a single document by its ID, raising on error.
Lists documents in an index.
Lists documents in an index, raising on error.
Functions
@spec add_or_replace( Meili.Client.t() | String.t(), String.t() | [map()], [map()] | Keyword.t(), Keyword.t() ) :: {:ok, map()} | {:error, Meili.Error.t()}
Adds or replaces documents in an index.
Options:
primary_keyorprimaryKey: Explicit primary key for the index.
Examples
documents = [%{id: 1, title: "Star Wars"}]
Meili.Document.add_or_replace("movies", documents)
Meili.Document.add_or_replace(client, "movies", documents, primary_key: "id")
@spec add_or_replace!( Meili.Client.t() | String.t(), String.t() | [map()], [map()] | Keyword.t(), Keyword.t() ) :: map() | no_return()
Adds or replaces documents in an index, raising on error.
@spec add_or_update( Meili.Client.t() | String.t(), String.t() | [map()], [map()] | Keyword.t(), Keyword.t() ) :: {:ok, map()} | {:error, Meili.Error.t()}
Adds or updates documents in an index.
Options:
primary_keyorprimaryKey: Explicit primary key for the index.
Examples
documents = [%{id: 1, title: "Star Wars (Updated)"}]
Meili.Document.add_or_update("movies", documents)
Meili.Document.add_or_update(client, "movies", documents, primary_key: "id")
@spec add_or_update!( Meili.Client.t() | String.t(), String.t() | [map()], [map()] | Keyword.t(), Keyword.t() ) :: map() | no_return()
Adds or updates documents in an index, raising on error.
@spec delete( Meili.Client.t() | String.t(), String.t() | integer(), String.t() | integer() | nil ) :: {:ok, map()} | {:error, Meili.Error.t()}
Deletes a single document by its ID.
Examples
Meili.Document.delete("movies", "123")
Meili.Document.delete(client, "movies", "123")
@spec delete!( Meili.Client.t() | String.t(), String.t() | integer(), String.t() | integer() | nil ) :: map() | no_return()
Deletes a single document by its ID, raising on error.
@spec delete_all(Meili.Client.t() | String.t(), String.t() | nil) :: {:ok, map()} | {:error, Meili.Error.t()}
Deletes all documents in an index.
Examples
Meili.Document.delete_all("movies")
Meili.Document.delete_all(client, "movies")
@spec delete_all!(Meili.Client.t() | String.t(), String.t() | nil) :: map() | no_return()
Deletes all documents in an index, raising on error.
@spec delete_batch(Meili.Client.t() | String.t(), String.t() | list(), list() | nil) :: {:ok, map()} | {:error, Meili.Error.t()}
Deletes a batch of documents by their IDs.
Examples
Meili.Document.delete_batch("movies", ["123", "456"])
Meili.Document.delete_batch(client, "movies", ["123", "456"])
@spec delete_batch!(Meili.Client.t() | String.t(), String.t() | list(), list() | nil) :: map() | no_return()
Deletes a batch of documents by their IDs, raising on error.
@spec edit( Meili.Client.t() | String.t(), String.t() | map(), map() | Keyword.t(), Keyword.t() ) :: {:ok, map()} | {:error, Meili.Error.t()}
Edits documents using update functions/queries.
Examples
queries = %{function: "doc.price = doc.price * 0.9"}
Meili.Document.edit("movies", queries)
Meili.Document.edit(client, "movies", queries)
@spec edit!( Meili.Client.t() | String.t(), String.t() | map(), map() | Keyword.t(), Keyword.t() ) :: map() | no_return()
Edits documents, raising on error.
@spec get( Meili.Client.t() | String.t(), String.t() | integer(), String.t() | integer() | Keyword.t(), Keyword.t() ) :: {:ok, map()} | {:error, Meili.Error.t()}
Gets a single document by its ID.
Options
fields: A list of fields to return, or a comma-separated string.
Examples
Meili.Document.get("movies", "123")
Meili.Document.get(client, "movies", "123", fields: ["title"])
@spec get!( Meili.Client.t() | String.t(), String.t() | integer(), String.t() | integer() | Keyword.t(), Keyword.t() ) :: map() | no_return()
Gets a single document by its ID, raising on error.
@spec list(Meili.Client.t() | String.t(), String.t() | Keyword.t(), Keyword.t()) :: {:ok, map()} | {:error, Meili.Error.t()}
Lists documents in an index.
Options
limit: Max number of documents to return.offset: Number of documents to skip.fields: A list of fields to return, or a comma-separated string.filter: A filter expression to filter results.
Examples
Meili.Document.list("movies", limit: 10)
Meili.Document.list(client, "movies", limit: 10, fields: ["id", "title"])
@spec list!(Meili.Client.t() | String.t(), String.t() | Keyword.t(), Keyword.t()) :: map() | no_return()
Lists documents in an index, raising on error.