Module: Elastic::Stats::ElasticClient

Included in:
KS, NaiveBayes::Predictor, NaiveBayes::Set
Defined in:
lib/elastic/stats/elastic_client.rb

Overview

Module to set up and manage the Elasticsearch client

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clientObject



10
11
12
# File 'lib/elastic/stats/elastic_client.rb', line 10

def client
  @client ||= Elasticsearch::Client.new client_options
end

#indexObject

Returns the value of attribute index.



8
9
10
# File 'lib/elastic/stats/elastic_client.rb', line 8

def index
  @index
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/elastic/stats/elastic_client.rb', line 8

def type
  @type
end

Instance Method Details

#analyze(options = {}) ⇒ Object



26
27
28
# File 'lib/elastic/stats/elastic_client.rb', line 26

def analyze(options = {})
  client.indices.analyze({ index: index, type: type }.merge(options))
end

#client_optionsObject



14
15
16
# File 'lib/elastic/stats/elastic_client.rb', line 14

def client_options
  @client_options ||= default_options
end

#client_options=(options = {}) ⇒ Object



18
19
20
# File 'lib/elastic/stats/elastic_client.rb', line 18

def client_options=(options = {})
  client_options.update(options)
end

#search(options = {}) ⇒ Object



22
23
24
# File 'lib/elastic/stats/elastic_client.rb', line 22

def search(options = {})
  client.search({ index: index, type: type }.merge(options))
end