Hui v0.10.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 get request of Solr query to a specific endpoint

Issues a POST update request to a specific Solr endpoint, for data indexing and deletion

Link to this section Types

Link to this section Functions

Link to this function get(solr_url, solr_query) View Source
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.

Link to this function post(solr_url, solr_query) View Source
post(solr_url(), solr_update_query()) ::
  {:ok, HTTPoison.Response.t()} | {:error, HTTPoison.Error.t()}

Issues a POST update request to a specific Solr endpoint, for data indexing and deletion.