class Elastic::EnterpriseSearch::Client

API client for the Elastic Enterprise Search API. This is the main client from which the Workplace Search and App Search clients inherit.

Constants

DEFAULT_TIMEOUT

Public Class Methods

new(options = {}) click to toggle source

Create a new Elastic::EnterpriseSearch::Client client

@param options [Hash] a hash of configuration options that will override what is set on the Elastic::EnterpriseSearch class. @option options [String] :host Enterprise Search host @option options [Hash] :basic_auth a username and password for Basic Authentication @option options [Numeric] :overall_timeout overall timeout for requests in seconds (default: 15s) @option options [Numeric] :open_timeout the number of seconds Net::HTTP (default: 15s) will wait while opening a connection before raising a Timeout::Error @option options [String] :proxy url of proxy to use, ex: “localhost:8888” @option options [Boolean] :log Use the default logger (disabled by default) @option arguments [Object] :logger An instance of a Logger-compatible object @option enable_meta_header [Boolean] :enable_meta_header Enable sending the meta data header to Cloud.

(Default: true)
# File lib/elastic/enterprise-search/client.rb, line 63
def initialize(options = {})
  @options = options
  @transport = transport
end

Public Instance Methods

host() click to toggle source
# File lib/elastic/enterprise-search/client.rb, line 106
def host
  return DEFAULT_HOST unless @options[:host]

  raise URI::InvalidURIError unless @options[:host] =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/

  @options[:host]
end
http_auth() click to toggle source
# File lib/elastic/enterprise-search/client.rb, line 90
def http_auth
  @options[:http_auth] || { user: 'elastic', password: 'changeme' }
end
http_auth=(http_auth) click to toggle source
# File lib/elastic/enterprise-search/client.rb, line 94
def http_auth=(http_auth)
  @options[:http_auth] = http_auth
end
log() click to toggle source
# File lib/elastic/enterprise-search/client.rb, line 98
def log
  @options[:log] || false
end
logger() click to toggle source
# File lib/elastic/enterprise-search/client.rb, line 102
def logger
  @options[:logger]
end
open_timeout() click to toggle source
# File lib/elastic/enterprise-search/client.rb, line 82
def open_timeout
  @options[:open_timeout] || DEFAULT_TIMEOUT
end
overall_timeout() click to toggle source
# File lib/elastic/enterprise-search/client.rb, line 86
def overall_timeout
  (@options[:overall_timeout] || DEFAULT_TIMEOUT).to_f
end
transport() click to toggle source
# File lib/elastic/enterprise-search/client.rb, line 68
def transport
  @options[:transport] ||
    Elasticsearch::Client.new(
      host: host,
      log: log,
      logger: logger,
      request_timeout: overall_timeout,
      transport_options: {
        request: { open_timeout: open_timeout }
      },
      enable_meta_header: @options[:enable_meta_header] || true
    )
end