Meilisearch.Documents (meilisearch v0.20.0) View Source
Collection of functions used to manage documents.
Link to this section Summary
Functions
Add document(s) to given index.
Add document(s) to given index.
Delete one or more documents based on id in a given index.
Delete all documents in given index.
Get one document by id.
List documents in given index.
Link to this section Functions
Specs
add_or_replace(String.t(), [any()], Keyword.t()) :: Meilisearch.HTTP.response()
Add document(s) to given index.
If an exisiting document (based on primary key) is given it will be replaced.
Examples
iex> Meilisearch.Documents.add_or_replace("meilisearch_test", %{
"id" => 2,
"tagline" => "You'll never go in the water again",
"title" => "Jaws"
})
{:ok, %{"updateId" => 1}}
iex> Meilisearch.Documents.add_or_replace(
"meilisearch_test",
[
%{
"id" => 6,
"tagline" => "Who ya gonna call?",
"title" => "Ghostbusters"
},
%{
"id" => 5,
"tagline" => "Be Afraid. Be very afraid.",
"title" => "The Fly"
}
]
)
{:ok, %{"updateId" => 1}}
Specs
Add document(s) to given index.
If an exisiting document (based on primary key) is given it will be updated with provided values.
Examples
iex> Meilisearch.Documents.add_or_update("meilisearch_test", %{
"id" => 2,
"tagline" => "You'll never go in the water again",
"title" => "Jaws"
})
{:ok, %{"updateId" => 1}}
iex> Meilisearch.Documents.add_or_update(
"meilisearch_test",
[
%{
"id" => 6,
"tagline" => "Who ya gonna call?",
"title" => "Ghostbusters"
},
%{
"id" => 5,
"tagline" => "Be Afraid. Be very afraid.",
"title" => "The Fly"
}
]
)
{:ok, %{"updateId" => 1}}
Specs
Delete one or more documents based on id in a given index.
Example
iex> Meilisearch.Documents.delete("meilisearch_test", 1)
{:ok, %{"updateId" => 0}}
iex> Meilisearch.Documents.delete("meilisearch_test", [1,2,3,4])
{:ok, %{"updateId" => 0}}
Specs
Delete all documents in given index.
Example
iex> Meilisearch.Documents.delete_all("meilisearch_test")
{:ok, %{"updateId" => 0}}
Specs
get(String.t(), String.t()) :: Meilisearch.HTTP.response()
Get one document by id.
Example
iex> Meilisearch.Documents.get("meilisearch_test", 1)
{:ok,
%{
"id" => 1,
"tagline" => "In space no one can hear you scream",
"title" => "Alien"
}}
Specs
list(String.t(), Keyword.t()) :: Meilisearch.HTTP.response()
List documents in given index.
Options
offset
Number of documents to skip. Defaults to0
limit
Maximum number of documents returned. Defaults to20
Examples
iex> Meilisearch.Documents.list("meilisearch_test")
{:ok,
[
%{
"id" => 2,
"tagline" => "You'll never go in the water again",
"title" => "Jaws"
},
%{
"id" => 1,
"tagline" => "In space no one can hear you scream",
"title" => "Alien"
}
]
}
iex> Meilisearch.Documents.get("meilisearch_test", limit: 2, offset: 4)
{:ok,
[
%{
"id" => 6,
"tagline" => "Who ya gonna call?",
"title" => "Ghostbusters"
},
%{
"id" => 5,
"tagline" => "Be Afraid. Be very afraid.",
"title" => "The Fly"
}
]
}