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
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
# File lib/elastic/enterprise-search/client.rb, line 43 def app_search(options = {}) @app_search ||= Elastic::EnterpriseSearch::AppSearch::Client.new( host: host, http_auth: options[:http_auth], transport: @transport ) end
# 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
# File lib/elastic/enterprise-search/client.rb, line 90 def http_auth @options[:http_auth] || { user: 'elastic', password: 'changeme' } end
# File lib/elastic/enterprise-search/client.rb, line 94 def http_auth=(http_auth) @options[:http_auth] = http_auth end
# File lib/elastic/enterprise-search/client.rb, line 98 def log @options[:log] || false end
# File lib/elastic/enterprise-search/client.rb, line 102 def logger @options[:logger] end
# File lib/elastic/enterprise-search/client.rb, line 82 def open_timeout @options[:open_timeout] || DEFAULT_TIMEOUT end
# File lib/elastic/enterprise-search/client.rb, line 86 def overall_timeout (@options[:overall_timeout] || DEFAULT_TIMEOUT).to_f end
# 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
# File lib/elastic/enterprise-search/client.rb, line 35 def workplace_search(options = {}) @workplace_search ||= Elastic::EnterpriseSearch::WorkplaceSearch::Client.new( host: host, http_auth: options[:http_auth], transport: @transport ) end