Class: Peek::Views::Elasticsearch
- Inherits:
-
View
- Object
- View
- Peek::Views::Elasticsearch
- Defined in:
- lib/peek/views/elasticsearch.rb
Instance Method Summary collapse
- #active_primary_shards ⇒ Object
- #active_replica_shards ⇒ Object
- #active_shards ⇒ Object
- #context ⇒ Object
-
#initialize(options = {}) ⇒ Elasticsearch
constructor
A new instance of Elasticsearch.
- #number_of_replicas ⇒ Object
- #number_of_shards ⇒ Object
- #results ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Elasticsearch
Returns a new instance of Elasticsearch.
6 7 8 9 10 11 12 13 14 |
# File 'lib/peek/views/elasticsearch.rb', line 6 def initialize = {} @index = .fetch(:index, nil) if defined?($stretch) @client = $stretch else raise "$stretch must be defined!" end end |
Instance Method Details
#active_primary_shards ⇒ Object
20 21 22 |
# File 'lib/peek/views/elasticsearch.rb', line 20 def active_primary_shards index_health["active_primary_shards"] end |
#active_replica_shards ⇒ Object
24 25 26 |
# File 'lib/peek/views/elasticsearch.rb', line 24 def active_replica_shards active_shards - active_primary_shards end |
#active_shards ⇒ Object
28 29 30 |
# File 'lib/peek/views/elasticsearch.rb', line 28 def active_shards index_health["active_shards"] end |
#context ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/peek/views/elasticsearch.rb', line 40 def context { :index => @index, :primary => active_primary_shards, :replica => active_replica_shards, :inactive_primary => (number_of_shards - active_primary_shards), :inactive_replica => (number_of_replicas - active_replica_shards), } end |
#number_of_replicas ⇒ Object
36 37 38 |
# File 'lib/peek/views/elasticsearch.rb', line 36 def number_of_replicas index_health["number_of_replicas"] * number_of_shards end |
#number_of_shards ⇒ Object
32 33 34 |
# File 'lib/peek/views/elasticsearch.rb', line 32 def number_of_shards index_health["number_of_shards"] end |
#results ⇒ Object
50 51 52 |
# File 'lib/peek/views/elasticsearch.rb', line 50 def results { :status => status } end |
#status ⇒ Object
16 17 18 |
# File 'lib/peek/views/elasticsearch.rb', line 16 def status index_health["status"] end |