Class: ElasticRecord::Index
- Inherits:
-
Object
- Object
- ElasticRecord::Index
- 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
Instance Attribute Summary collapse
-
#disabled ⇒ Object
Returns the value of attribute disabled.
-
#model ⇒ Object
Returns the value of attribute model.
Instance Method Summary collapse
- #alias_name ⇒ Object
- #configure(&block) ⇒ Object
- #disable! ⇒ Object
- #enable! ⇒ Object
- #get(end_path, json = nil) ⇒ Object
-
#initialize(model) ⇒ Index
constructor
A new instance of Index.
- #initialize_copy(other) ⇒ Object
- #real_connection ⇒ Object
- #type ⇒ Object
Methods included from Deferred
#connection, #deferred_connection, #disable_deferring!, #enable_deferring!, #reset_deferring!
Methods included from Percolator
#all_percolators, #create_percolator, #delete_percolator, #get_percolator, #percolate, #percolator_exists?, #percolator_index_name, #reset_percolator
Methods included from Warmer
#create_warmer, #delete_warmer, #get_warmer, #warmer_exists?
Methods included from Mapping
#delete_mapping, #get_mapping, #mapping, #mapping=, #update_mapping
Methods included from Settings
#settings, #settings=, #update_settings
Methods included from Manage
#aliased_names, #all_names, #close, #create, #create_and_deploy, #delete, #delete_all, #deploy, #exists?, #open, #refresh, #reset, #type_exists?
Methods included from Documents
#bulk, #bulk_add, #current_bulk_batch, #delete_by_query, #delete_document, #explain, #index_document, #index_record, #record_exists?, #scroll, #search
Constructor Details
#initialize(model) ⇒ Index
Returns a new instance of Index.
45 46 47 48 |
# File 'lib/elastic_record/index.rb', line 45 def initialize(model) @model = model @disabled = false end |
Instance Attribute Details
#disabled ⇒ Object
Returns the value of attribute disabled.
43 44 45 |
# File 'lib/elastic_record/index.rb', line 43 def disabled @disabled end |
#model ⇒ Object
Returns the value of attribute model.
42 43 44 |
# File 'lib/elastic_record/index.rb', line 42 def model @model end |
Instance Method Details
#alias_name ⇒ Object
55 56 57 |
# File 'lib/elastic_record/index.rb', line 55 def alias_name @alias_name ||= model.base_class.name.demodulize.underscore.pluralize end |
#configure(&block) ⇒ Object
75 76 77 |
# File 'lib/elastic_record/index.rb', line 75 def configure(&block) Configurator.new(self).instance_eval(&block) end |
#disable! ⇒ Object
63 64 65 |
# File 'lib/elastic_record/index.rb', line 63 def disable! @disabled = true end |
#enable! ⇒ Object
67 68 69 |
# File 'lib/elastic_record/index.rb', line 67 def enable! @disabled = false end |
#get(end_path, json = nil) ⇒ Object
79 80 81 |
# File 'lib/elastic_record/index.rb', line 79 def get(end_path, json = nil) connection.json_get "/#{alias_name}/#{type}/#{end_path}", json end |
#initialize_copy(other) ⇒ Object
50 51 52 53 |
# File 'lib/elastic_record/index.rb', line 50 def initialize_copy(other) @settings = settings.deep_dup @mapping = mapping.deep_dup end |
#real_connection ⇒ Object
71 72 73 |
# File 'lib/elastic_record/index.rb', line 71 def real_connection model.elastic_connection end |
#type ⇒ Object
59 60 61 |
# File 'lib/elastic_record/index.rb', line 59 def type @type ||= model.base_class.name.demodulize.underscore end |