Skip to content

Instantly share code, notes, and snippets.

@rugyoga
Last active July 21, 2022 19:18
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/419e1821847ebd3ec2752b8463f0083f to your computer and use it in GitHub Desktop.
Save rugyoga/419e1821847ebd3ec2752b8463f0083f to your computer and use it in GitHub Desktop.
Perform one ES query and return the resulting hits in a Stream
@spec stream_one(ES.query_t(), ES.index_t(), ES.consumer_t()) :: {:ok, any()} | {:error, any()}
def stream_one(query, index, consumer) do
query
|> search(index)
|> HTTP.on_200(fn body -> consumer.(body["hits"]["hits"]) end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment