Skip to content

Instantly share code, notes, and snippets.

@rugyoga
Last active July 21, 2022 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rugyoga/624e0a90503c34cf87e3836d85d5f705 to your computer and use it in GitHub Desktop.
Save rugyoga/624e0a90503c34cf87e3836d85d5f705 to your computer and use it in GitHub Desktop.
Use Stream.iterate to process a Stream of ES result sets
@spec streamer(ES.query_t()) :: {:ok, Enumerable.t()} | {:error, any}
def streamer(initial) do
{:ok,
initial
|> search()
|> Stream.iterate(fn previous -> search(Query.update(initial, previous)) end)
}
rescue
error -> {:error, error}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment