Class: ROM::Elasticsearch::Gateway
- Inherits:
-
Gateway
- Object
- Gateway
- ROM::Elasticsearch::Gateway
- Defined in:
- lib/rom/elasticsearch/gateway.rb
Overview
Elasticsearch gateway
Instance Attribute Summary collapse
- #client ⇒ Object readonly
- #url ⇒ Object readonly
Instance Method Summary collapse
-
#dataset(index) ⇒ Dataset
(also: #[])
Get a dataset by its :index name.
-
#dataset?(index) ⇒ Boolean
(also: #index?)
Return true if a dataset with the given :index exists.
-
#initialize(uri, log: false) ⇒ Gateway
constructor
private
A new instance of Gateway.
Constructor Details
#initialize(uri, log: false) ⇒ Gateway
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Gateway.
54 55 56 57 |
# File 'lib/rom/elasticsearch/gateway.rb', line 54 def initialize(uri, log: false) @url = URI.parse(uri) @client = ::Elasticsearch::Client.new(url: url, log: log) end |
Instance Attribute Details
#client ⇒ Object (readonly)
51 52 53 |
# File 'lib/rom/elasticsearch/gateway.rb', line 51 def client @client end |
#url ⇒ Object (readonly)
47 48 49 |
# File 'lib/rom/elasticsearch/gateway.rb', line 47 def url @url end |
Instance Method Details
#dataset(index) ⇒ Dataset Also known as: []
Get a dataset by its :index name
78 79 80 81 |
# File 'lib/rom/elasticsearch/gateway.rb', line 78 def dataset(index) idx_name = IndexName[index] Dataset.new(client, params: { index: idx_name.to_sym, type: idx_name.type }) end |
#dataset?(index) ⇒ Boolean Also known as: index?
Return true if a dataset with the given :index exists
66 67 68 |
# File 'lib/rom/elasticsearch/gateway.rb', line 66 def dataset?(index) client.indices.exists?(index: index) end |