Handle error case for search in Document.API?
Anderssorby opened this issue · comments
Regarding this line:
elastic/lib/elastic/document/api.ex
Line 190 in 1e2c7a3
Could we handle the error case for the Document.API.search as well? If for example the index doesn't exist it creates a nasty exception.
Something like:
case result do
{:error, code, error} ->
{:error, code, error}
{:ok, 200, %{"hits" => %{"hits" => hits}}} ->
Enum.map(hits, fn %{"_source" => source, "_id" => id} ->
into_struct(id, source)
end)
end
I can make a PR. Then you can have the option to deal with the errors without breaking existing code.
Yes please do submit a PR for this.