Manages Meilisearch indexes.
Summary
Functions
Triggers compaction of a specific index.
Triggers compaction of a specific index, raising on error.
Creates a new index.
Creates a new index, raising on error.
Deletes an index.
Deletes an index, raising on error.
Retrieves a single index.
Retrieves a single index, raising on error.
Lists all indexes.
Lists all indexes, raising on error.
Gets stats of a specific index.
Gets stats of a specific index, raising on error.
Swaps the contents of two or more indexes.
Swaps the contents of indexes, raising on error.
Updates an index (currently, only the primaryKey can be updated).
Updates an index, raising on error.
Functions
@spec compact(Meili.Client.t() | String.t(), String.t() | nil) :: {:ok, map()} | {:error, Meili.Error.t()}
Triggers compaction of a specific index.
Examples
Meili.Index.compact("movies")
Meili.Index.compact(client, "movies")
@spec compact!(Meili.Client.t() | String.t(), String.t() | nil) :: map() | no_return()
Triggers compaction of a specific index, raising on error.
@spec create( Meili.Client.t() | String.t(), String.t() | Keyword.t() | map(), Keyword.t() | map() ) :: {:ok, map()} | {:error, Meili.Error.t()}
Creates a new index.
Options can be a primary key string, a keyword list, or a map.
Examples
Meili.Index.create("movies")
Meili.Index.create("movies", "id")
Meili.Index.create("movies", primary_key: "id")
Meili.Index.create(client, "movies", primary_key: "id")
@spec create!( Meili.Client.t() | String.t(), String.t() | Keyword.t() | map(), Keyword.t() | map() ) :: map() | no_return()
Creates a new index, raising on error.
@spec delete(Meili.Client.t() | String.t(), String.t() | nil) :: {:ok, map()} | {:error, Meili.Error.t()}
Deletes an index.
Examples
Meili.Index.delete("movies")
Meili.Index.delete(client, "movies")
@spec delete!(Meili.Client.t() | String.t(), String.t() | nil) :: map() | no_return()
Deletes an index, raising on error.
@spec get(Meili.Client.t() | String.t(), String.t() | nil) :: {:ok, map()} | {:error, Meili.Error.t()}
Retrieves a single index.
Examples
Meili.Index.get("movies")
Meili.Index.get(client, "movies")
@spec get!(Meili.Client.t() | String.t(), String.t() | nil) :: map() | no_return()
Retrieves a single index, raising on error.
@spec list(Meili.Client.t() | Keyword.t() | nil, Keyword.t()) :: {:ok, list() | map()} | {:error, Meili.Error.t()}
Lists all indexes.
Supports optional query params:
limit: The maximum number of indexes to return.offset: The number of indexes to skip.
Examples
Meili.Index.list()
Meili.Index.list(limit: 10)
Meili.Index.list(client, limit: 10)
Lists all indexes, raising on error.
@spec stats(Meili.Client.t() | String.t(), String.t() | nil) :: {:ok, map()} | {:error, Meili.Error.t()}
Gets stats of a specific index.
Examples
Meili.Index.stats("movies")
Meili.Index.stats(client, "movies")
@spec stats!(Meili.Client.t() | String.t(), String.t() | nil) :: map() | no_return()
Gets stats of a specific index, raising on error.
@spec swap(Meili.Client.t() | [map()], [map()] | nil) :: {:ok, map()} | {:error, Meili.Error.t()}
Swaps the contents of two or more indexes.
Examples
Meili.Index.swap([%{indexes: ["movies_a", "movies_b"]}])
Meili.Index.swap(client, [%{indexes: ["movies_a", "movies_b"]}])
@spec swap!(Meili.Client.t() | [map()], [map()] | nil) :: map() | no_return()
Swaps the contents of indexes, raising on error.
@spec update( Meili.Client.t() | String.t(), String.t() | Keyword.t() | map(), Keyword.t() | map() ) :: {:ok, map()} | {:error, Meili.Error.t()}
Updates an index (currently, only the primaryKey can be updated).
Examples
Meili.Index.update("movies", "new_id")
Meili.Index.update("movies", primary_key: "new_id")
Meili.Index.update(client, "movies", primary_key: "new_id")
@spec update!( Meili.Client.t() | String.t(), String.t() | Keyword.t() | map(), Keyword.t() | map() ) :: map() | no_return()
Updates an index, raising on error.