Last active
July 21, 2022 19:18
-
-
Save rugyoga/419e1821847ebd3ec2752b8463f0083f to your computer and use it in GitHub Desktop.
Perform one ES query and return the resulting hits in a Stream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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