Open Anderssorby opened 4 years ago
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.
Regarding this line: https://github.com/radar/elastic/blob/1e2c7a3fe7b28bfa6cc574b10fd7bc6dca3dadfa/lib/elastic/document/api.ex#L190
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.