Snap.Search (Snap v0.13.0)
View SourcePerforms searches against an ElasticSearch cluster.
Summary
Functions
Runs a count of the documents in an index, using an optional query.
Runs a delete operation on an index, given a query.
Makes a search against an ElasticSearch cluster and parses the response.
Functions
Runs a count of the documents in an index, using an optional query.
Runs a delete operation on an index, given a query.
@spec 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.search(Cluster, "index", query)
IO.inspect(response.took)
Enum.each(response, fn hit -> IO.inspect(hit.score) end)