     case HTTPoison.get("localhost:9200/idai-field/resource/" <> id) do
 
       {:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
-        %{ _source: %{ resource: resource }} = atomize Poison.decode! body
-        resource
+        Poison.decode!(body)
+        |> atomize
+        |> to_resource
 
       {:ok, %HTTPoison.Response{status_code: 404}} ->
         %{type: "null", identifier: "0"}

        %{type: "null", identifier: "0"}
    end
  end
end
    case HTTPoison.get("localhost:9200/idai-field/resource/_search") do

      {:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
        Poison.decode!(body)
        |> atomize
        |> to_hits
        |> Enum.map(&to_resource/1)

      {:ok, %HTTPoison.Response{status_code: 404}} ->
        []
