Class: ElasticSearchClient
- Inherits:
-
Object
- Object
- ElasticSearchClient
- Defined in:
- lib/mas/elastic_search_client.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
-
#initialize ⇒ ElasticSearchClient
constructor
A new instance of ElasticSearchClient.
- #search(path, json = '') ⇒ Object
- #store(path, json) ⇒ Object
Constructor Details
#initialize ⇒ ElasticSearchClient
Returns a new instance of ElasticSearchClient.
4 5 6 7 |
# File 'lib/mas/elastic_search_client.rb', line 4 def initialize @index = "rad_#{Rails.env}" @server = ENV.fetch('BONSAI_URL', 'http://localhost:9200') end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
2 3 4 |
# File 'lib/mas/elastic_search_client.rb', line 2 def index @index end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
2 3 4 |
# File 'lib/mas/elastic_search_client.rb', line 2 def server @server end |
Instance Method Details
#search(path, json = '') ⇒ Object
14 15 16 |
# File 'lib/mas/elastic_search_client.rb', line 14 def search(path, json = '') http.post(uri_for(path), body: json) end |
#store(path, json) ⇒ Object
9 10 11 12 |
# File 'lib/mas/elastic_search_client.rb', line 9 def store(path, json) res = http.put(uri_for(path), json: json) res.status.ok? end |