Hui v0.9.0 Hui.Query View Source
Hui.Query module provides underpinning HTTP-based request functions for Solr, including:
Link to this section Summary
Functions
Issues a DELETE request to the given url, raising an exception in case of failure
Issues a DELETE request to the given url
Issues a get request of Solr query to a specific endpoint, raising an exception in case of failure
Issues a GET request to the given url, raising an exception in case of failure
Issues a get request of Solr query to a specific endpoint
Issues a GET request to the given url
Issues a HEAD request to the given url, raising an exception in case of failure
Issues a HEAD request to the given url
Issues a OPTIONS request to the given url, raising an exception in case of failure
Issues an OPTIONS request to the given url
Issues a PATCH request to the given url, raising an exception in case of failure
Issues a PATCH request to the given url
Issues a POST request to the given url, raising an exception in case of failure
Issues a POST request to the given url
Callback implementation for HTTPoison.Base.process_headers/1
Callback implementation for HTTPoison.Base.process_request_body/1
Callback implementation for HTTPoison.Base.process_request_headers/1
Callback implementation for HTTPoison.Base.process_request_options/1
Callback implementation for HTTPoison.Base.process_request_params/1
Callback implementation for HTTPoison.Base.process_request_url/1
Callback implementation for HTTPoison.Base.process_response/1
Callback implementation for HTTPoison.Base.process_response_body/1
Callback implementation for HTTPoison.Base.process_response_chunk/1
Callback implementation for HTTPoison.Base.process_response_headers/1
Callback implementation for HTTPoison.Base.process_response_status_code/1
Callback implementation for HTTPoison.Base.process_status_code/1
Callback implementation for HTTPoison.Base.process_url/1
Issues a PUT request to the given url, raising an exception in case of failure
Issues a PUT request to the given url
Issues an HTTP request with the given method to the given url, raising an exception in case of failure
Issues an HTTP request using a Request
struct
Issues an HTTP request with the given method to the given url
Starts HTTPoison and its dependencies
Requests the next message to be streamed for a given HTTPoison.AsyncResponse
Link to this section Types
faceting_struct() :: Hui.Query.Facet.t() | Hui.Query.FacetRange.t() | Hui.Query.FacetInterval.t()
highlighting_struct() :: Hui.Query.Highlight.t() | Hui.Query.HighlighterUnified.t() | Hui.Query.HighlighterOriginal.t() | Hui.Query.HighlighterFastVector.t()
misc_struct() :: Hui.Query.MoreLikeThis.t() | Hui.Query.Suggest.t() | Hui.Query.SpellCheck.t()
querying_struct() :: Hui.Query.Standard.t() | Hui.Query.Common.t() | Hui.Query.DisMax.t()
solr_query() :: Keyword.t() | map() | solr_struct() | [solr_struct()]
solr_struct() :: querying_struct() | faceting_struct() | highlighting_struct() | misc_struct()
Link to this section Functions
delete!(binary(), headers(), Keyword.t()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Issues a DELETE request to the given url, raising an exception in case of failure.
If the request does not fail, the response is returned.
See request!/5
for more detailed information.
delete(binary(), headers(), Keyword.t()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Issues a DELETE request to the given url.
Returns {:ok, response}
if the request is successful, {:error, reason}
otherwise.
See request/5
for more detailed information.
get!(solr_url(), solr_query()) :: HTTPoison.Response.t()
Issues a get request of Solr query to a specific endpoint, raising an exception in case of failure.
If the request does not fail, the response is returned.
See get/2
for more detailed information.
get!(binary(), headers(), Keyword.t()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Issues a GET request to the given url, raising an exception in case of failure.
If the request does not fail, the response is returned.
See request!/5
for more detailed information.
get(solr_url(), solr_query()) :: {:ok, HTTPoison.Response.t()} | {:error, HTTPoison.Error.t()}
Issues a get request of Solr query to a specific endpoint.
The query can be a keyword list or a list of Hui query structs (solr_query/0
).
Example - parameters
url = %Hul.URL{url: "http://..."}
# query via a list of keywords, which are unbound and sent to Solr directly
Hui.Query.get(url, q: "glen cova", facet: "true", "facet.field": ["type", "year"])
# query via Hui structs
alias Hui.Query
Hui.Query.get(url, %Query.DisMax{q: "glen cova"})
Hui.Query.get(url, [%Query.DisMax{q: "glen"}, %Query.Facet{field: ["type", "year"]}])
The use of structs is more idiomatic and succinct. It is bound to qualified Solr fields.
See Hui.URL.t/0
struct about specifying HTTP headers and HTTPoison options
of a request, e.g. timeout
, recv_timeout
, max_redirect
etc.
get(binary(), headers(), Keyword.t()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Issues a GET request to the given url.
Returns {:ok, response}
if the request is successful, {:error, reason}
otherwise.
See request/5
for more detailed information.
head!(binary(), headers(), Keyword.t()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Issues a HEAD request to the given url, raising an exception in case of failure.
If the request does not fail, the response is returned.
See request!/5
for more detailed information.
head(binary(), headers(), Keyword.t()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Issues a HEAD request to the given url.
Returns {:ok, response}
if the request is successful, {:error, reason}
otherwise.
See request/5
for more detailed information.
options!(binary(), headers(), Keyword.t()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Issues a OPTIONS request to the given url, raising an exception in case of failure.
If the request does not fail, the response is returned.
See request!/5
for more detailed information.
options(binary(), headers(), Keyword.t()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Issues an OPTIONS request to the given url.
Returns {:ok, response}
if the request is successful, {:error, reason}
otherwise.
See request/5
for more detailed information.
patch!(binary(), any(), headers(), Keyword.t()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Issues a PATCH request to the given url, raising an exception in case of failure.
If the request does not fail, the response is returned.
See request!/5
for more detailed information.
patch(binary(), any(), headers(), Keyword.t()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Issues a PATCH request to the given url.
Returns {:ok, response}
if the request is successful, {:error, reason}
otherwise.
See request/5
for more detailed information.
post!(binary(), any(), headers(), Keyword.t()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Issues a POST request to the given url, raising an exception in case of failure.
If the request does not fail, the response is returned.
See request!/5
for more detailed information.
post(binary(), any(), headers(), Keyword.t()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Issues a POST request to the given url.
Returns {:ok, response}
if the request is successful, {:error, reason}
otherwise.
See request/5
for more detailed information.
Callback implementation for HTTPoison.Base.process_headers/1
.
Callback implementation for HTTPoison.Base.process_request_body/1
.
Callback implementation for HTTPoison.Base.process_request_headers/1
.
Callback implementation for HTTPoison.Base.process_request_options/1
.
Callback implementation for HTTPoison.Base.process_request_params/1
.
Callback implementation for HTTPoison.Base.process_request_url/1
.
process_response(HTTPoison.Base.response()) :: any()
Callback implementation for HTTPoison.Base.process_response/1
.
Callback implementation for HTTPoison.Base.process_response_body/1
.
Callback implementation for HTTPoison.Base.process_response_chunk/1
.
Callback implementation for HTTPoison.Base.process_response_headers/1
.
Callback implementation for HTTPoison.Base.process_response_status_code/1
.
Callback implementation for HTTPoison.Base.process_status_code/1
.
Callback implementation for HTTPoison.Base.process_url/1
.
put!(binary(), any(), headers(), Keyword.t()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Issues a PUT request to the given url, raising an exception in case of failure.
If the request does not fail, the response is returned.
See request!/5
for more detailed information.
put(binary(), any(), headers(), Keyword.t()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Issues a PUT request to the given url.
Returns {:ok, response}
if the request is successful, {:error, reason}
otherwise.
See request/5
for more detailed information.
request!(atom(), binary(), any(), headers(), Keyword.t()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Issues an HTTP request with the given method to the given url, raising an exception in case of failure.
request!/5
works exactly like request/5
but it returns just the
response in case of a successful request, raising an exception in case the
request fails.
request(HTTPoison.Request.t()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Issues an HTTP request using a Request
struct.
This function returns {:ok, response}
or {:ok, async_response}
if the
request is successful, {:error, reason}
otherwise.
Examples
request = %HTTPoison.Request{
method: :post,
url: "https://my.website.com",
body: "{\"foo\": 3}",
headers: [{"Accept", "application/json"}]
}
request(request)
request(atom(), binary(), any(), headers(), Keyword.t()) :: {:ok, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Issues an HTTP request with the given method to the given url.
This function is usually used indirectly by get/3
, post/4
, put/4
, etc
Args:
method
- HTTP method as an atom (:get
,:head
,:post
,:put
,:delete
, etc.)url
- target url as a binary string or char listbody
- request body. See more belowheaders
- HTTP headers as an orddict (e.g.,[{"Accept", "application/json"}]
)options
- Keyword list of options
Body: see type HTTPoison.Request
Options: see type HTTPoison.Request
This function returns {:ok, response}
or {:ok, async_response}
if the
request is successful, {:error, reason}
otherwise.
Examples
request(:post, "https://my.website.com", "{\"foo\": 3}", [{"Accept", "application/json"}])
Starts HTTPoison and its dependencies.
stream_next(HTTPoison.AsyncResponse.t()) :: {:ok, HTTPoison.AsyncResponse.t()} | {:error, HTTPoison.Error.t()}
Requests the next message to be streamed for a given HTTPoison.AsyncResponse
.
See request!/5
for more detailed information.