Snap.Search (Snap v0.3.0) View Source
Performs searches against an ElasticSearch cluster.
Link to this section Summary
Functions
Makes a search against an ElasticSearch cluster and parses the response.
Link to this section Functions
Link to this function
search(cluster, index_or_alias, query, params \\ [], headers \\ [], opts \\ [])
View SourceSpecs
search( cluster :: module(), index_or_alias :: String.t(), query :: map(), params :: Keyword.t(), headers :: Keyword.t(), opts :: Keyword.t() ) :: {:ok, Snap.SearchResponse.t()} | Snap.Cluster.error()
Makes a search against an ElasticSearch cluster and parses the response.
Performs a search against an index using a POST request, and parses the
response into a Snap.SearchResponse
.
Snap.SearchResponse
implements Enumerable
, so you can count and iterate
directly on the struct.
Examples
query = %{query: %{match_all: %{}}}
{:ok, response} = Snap.Search(Cluster, "index", query)
IO.inspect(response.took)
Enum.each(fn hit -> IO.inspect(hit._score) end)