class Elasticord::Client::Base

Attributes

elastic_search_client[R]
entity[R]
index[R]
type[R]

Public Class Methods

new(elastic_search_client, entity, index, type) click to toggle source
# File lib/elasticord/client/base.rb, line 12
def initialize(elastic_search_client, entity, index, type)
  @elastic_search_client, @entity, @index, @type =
    elastic_search_client, entity, index, type
end

Public Instance Methods

create(attributes = {}) click to toggle source
# File lib/elasticord/client/base.rb, line 19
def create(attributes = {})
  result = Client::Create.one \
    elastic_search_client, index, type, attributes

  return false unless result

  attributes[:id] ||= result['_id']

  entity.new(attributes)
end
delete_all() click to toggle source
# File lib/elasticord/client/base.rb, line 46
def delete_all
  Client::Delete.all(elastic_search_client, index)
end
get(id) click to toggle source
# File lib/elasticord/client/base.rb, line 30
def get(id)
  result = Client::Get.one(elastic_search_client, index, type, id)

  return false unless result

  entity.new(result.merge({ 'id' => id }))
end
none() click to toggle source
# File lib/elasticord/client/base.rb, line 42
def none
  Client::SearchBuilder.new(elastic_search_client, entity, index, type)
end
refresh_index() click to toggle source
# File lib/elasticord/client/base.rb, line 50
def refresh_index
  Client::Index.refresh(elastic_search_client, index)
end