class Peek::Views::Elasticsearch

Public Class Methods

new(options = {}) click to toggle source
# File lib/peek/views/elasticsearch.rb, line 6
def initialize options = {}
  @index = options.fetch(:index, nil)

  if defined?($stretch)
    @client = $stretch
  else
    raise "$stretch must be defined!"
  end
end

Public Instance Methods

active_primary_shards() click to toggle source
# File lib/peek/views/elasticsearch.rb, line 20
def active_primary_shards
  index_health["active_primary_shards"]
end
active_replica_shards() click to toggle source
# File lib/peek/views/elasticsearch.rb, line 24
def active_replica_shards
  active_shards - active_primary_shards
end
active_shards() click to toggle source
# File lib/peek/views/elasticsearch.rb, line 28
def active_shards
  index_health["active_shards"]
end
context() click to toggle source
# 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() click to toggle source
# File lib/peek/views/elasticsearch.rb, line 36
def number_of_replicas
  index_health["number_of_replicas"] * number_of_shards
end
number_of_shards() click to toggle source
# File lib/peek/views/elasticsearch.rb, line 32
def number_of_shards
  index_health["number_of_shards"]
end
results() click to toggle source
# File lib/peek/views/elasticsearch.rb, line 50
def results
  { :status => status }
end
status() click to toggle source
# File lib/peek/views/elasticsearch.rb, line 16
def status
  index_health["status"]
end

Private Instance Methods

index_health() click to toggle source
# File lib/peek/views/elasticsearch.rb, line 55
def index_health
  @index_health ||= @client.cluster.health(:indices => @index)["indices"][@index]
end