Client documentation

Client is a base struct, that parse hosts and create connections to Elastic cluster. After initialization it can be passed to api methods to perform requests.

Example

using ElasticsearchClient

client = ElasticsearchClient.Client(host=(host="localhost", port=9200, scheme="http"))

perform_request(client, "GET", "/_search")
ElasticsearchClient.ElasticTransport.ClientType

ElasticSearch client. Handling hosts configuration, verify elasticsearch and delegate requests to Transport

function Client(;http_client::Module, kwargs...)

Create a client connected to an Elastic cluster.

Possible arguments

  • http_client::Module: A module that implement request method. Maybe useful if you need custom http layers. HTTP.jl used bu default.
  • hosts: Single host passed as a String, Dict or NamedTuple, or multiple hosts passed as an Array; host, url, urls keys are also valid
  • serializer: Function to serialise the body to JSON. JSON.json by default
  • deserializer: Function to deserialise response body to Dict. JSON.parse by default
  • resurrect_after::Integer: After how many seconds a dead connection should be tried again
  • reload_connection::Bool: Reload connections after X requests (false by default)
  • randomize_hosts::Bool: Shuffle connections on initialization and reload (false by default)
  • sniffer_timeout::Integer: Timeout for reloading connections in seconds (1 by default)
  • retry_on_failure::Bool: Retry X times when request fails before raising and exception (false by default)
  • delay_on_retry::Integer: Delay in milliseconds between each retry (0 by default)
  • retry_on_status::Vector{Integer}: Retry when specific status codes are returned
  • reload_on_failure::Bool: Reload connections after failure (false by default)
  • request_timeout::Integer: The request timeout to be passed to transport in options
  • transport_options: Options to be passed to Connection. Now work only headers option
  • selector::Connections.AbstractSelector A struct type of selector strategy.
  • send_get_body_as: Specify the HTTP method to use for GET requests with a body. (Default: GET)
  • compression Whether to compress requests. Gzip compression will be used. The default is false. Responses will automatically be inflated if they are compressed.
source
ElasticsearchClient.ElasticTransport.perform_requestFunction

Low-level request to Elastic cluster.

Arguments

  • client::ElasticTransport.Client
  • method::String
  • path::String: elastic endpoint. Must start with /

Keyword arguments

  • params::Dict: Query params
  • body::Union{Nothing, Dict}: HTTP body, default Nothing
  • headers::Union{Nothing, Dict}: HTTP headers. They are merged with default headers. Default Nothing
source