Class: ElasticRecord::Index

Inherits:
Object
  • Object
show all
Includes:
Deferred, Documents, Manage, Mapping, Percolator, Settings, Warmer
Defined in:
lib/elastic_record/index.rb,
lib/elastic_record/index/manage.rb,
lib/elastic_record/index/warmer.rb,
lib/elastic_record/index/mapping.rb,
lib/elastic_record/index/deferred.rb,
lib/elastic_record/index/settings.rb,
lib/elastic_record/index/documents.rb,
lib/elastic_record/index/percolator.rb,
lib/elastic_record/index/configurator.rb

Overview

ElasticRecord::Index provides access to elastic search’s API. It is accessed with Widget.elastic_index. The methods provided are:

create

Create a new index that is not aliased

create_and_deploy

Create a new index and alias it

reset

Delete all aliased indexes and deploy a new one

refresh

Call the refresh API

exists?(index_name)

Returns if the index exists

get_mapping

Returns the mapping currently stored by elastic search.

put_mapping

Update elastic search’s mapping

Defined Under Namespace

Modules: Deferred, Documents, Manage, Mapping, Percolator, Settings, Warmer Classes: Configurator, ScanSearch

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Deferred

#connection, #deferred_connection, #disable_deferring!, #enable_deferring!, #reset_deferring!

Methods included from Percolator

#all_percolators, #create_percolator, #create_percolator_index, #delete_percolator, #delete_percolator_index, #get_percolator, #percolate, #percolator_exists?, #percolator_name, #reset_percolators

Methods included from Warmer

#create_warmer, #delete_warmer, #get_warmer, #warmer_exists?

Methods included from Mapping

#get_mapping, #mapping, #mapping=, #update_mapping

Methods included from Settings

#settings, #settings=, #update_settings

Methods included from Manage

#aliased_names, #all_names, #create, #create_and_deploy, #delete, #delete_all, #deploy, #exists?, #refresh, #reset, #type_exists?

Methods included from Documents

#bulk, #bulk_add, #create_scan_search, #current_bulk_batch, #delete_by_query, #delete_document, #explain, #index_document, #index_record, #record_exists?, #scroll, #search, #update_document, #update_record

Constructor Details

#initialize(model) ⇒ Index

Returns a new instance of Index.



48
49
50
51
# File 'lib/elastic_record/index.rb', line 48

def initialize(model)
  @model = model
  @disabled = false
end

Instance Attribute Details

#disabledObject

Returns the value of attribute disabled.



44
45
46
# File 'lib/elastic_record/index.rb', line 44

def disabled
  @disabled
end

#has_percolatorObject

Returns the value of attribute has_percolator.



45
46
47
# File 'lib/elastic_record/index.rb', line 45

def has_percolator
  @has_percolator
end

#modelObject

Returns the value of attribute model.



42
43
44
# File 'lib/elastic_record/index.rb', line 42

def model
  @model
end

#partial_updatesObject

Returns the value of attribute partial_updates.



46
47
48
# File 'lib/elastic_record/index.rb', line 46

def partial_updates
  @partial_updates
end

Instance Method Details

#alias_nameObject



62
63
64
# File 'lib/elastic_record/index.rb', line 62

def alias_name
  @alias_name ||= model.base_class.name.demodulize.underscore.pluralize
end

#alias_name=(name) ⇒ Object



58
59
60
# File 'lib/elastic_record/index.rb', line 58

def alias_name=(name)
  @alias_name = name
end

#configure(&block) ⇒ Object



86
87
88
# File 'lib/elastic_record/index.rb', line 86

def configure(&block)
  Configurator.new(self).instance_eval(&block)
end

#disable!Object



74
75
76
# File 'lib/elastic_record/index.rb', line 74

def disable!
  @disabled = true
end

#enable!Object



78
79
80
# File 'lib/elastic_record/index.rb', line 78

def enable!
  @disabled = false
end

#get(end_path, json = nil) ⇒ Object



90
91
92
# File 'lib/elastic_record/index.rb', line 90

def get(end_path, json = nil)
  connection.json_get "/#{alias_name}/#{type}/#{end_path}", json
end

#initialize_copy(other) ⇒ Object



53
54
55
56
# File 'lib/elastic_record/index.rb', line 53

def initialize_copy(other)
  @settings = settings.deep_dup
  @mapping = mapping.deep_dup
end

#real_connectionObject



82
83
84
# File 'lib/elastic_record/index.rb', line 82

def real_connection
  model.elastic_connection
end

#typeObject



70
71
72
# File 'lib/elastic_record/index.rb', line 70

def type
  @type ||= model.base_class.name.demodulize.underscore
end

#type=(name) ⇒ Object



66
67
68
# File 'lib/elastic_record/index.rb', line 66

def type=(name)
  @type = name
end