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/analyze.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/mapping_type.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.
- update_mapping
-
Update elastic search’s mapping
Defined Under Namespace
Modules: Analyze, Deferred, Documents, Manage, Mapping, MappingType, Settings Classes: MappingTypeTest, ScrollEnumerator
Constant Summary
Constants included from Mapping
Instance Attribute Summary collapse
-
#disabled ⇒ Object
Returns the value of attribute disabled.
-
#load_from_source ⇒ Object
Returns the value of attribute load_from_source.
-
#model ⇒ Object
Returns the value of attribute model.
-
#partial_updates ⇒ Object
Returns the value of attribute partial_updates.
Attributes included from MappingType
Attributes included from Analyze
Attributes included from Mapping
Instance Method Summary collapse
- #alias_name ⇒ Object
- #alias_name=(name) ⇒ Object
- #disable! ⇒ Object
- #enable! ⇒ Object
- #get(end_path, json = nil) ⇒ Object
-
#initialize(model) ⇒ Index
constructor
A new instance of Index.
- #initialize_copy(other) ⇒ Object
- #load_from_source! ⇒ Object
- #loading_from_source(&block) ⇒ Object
- #real_connection ⇒ Object
Methods included from Deferred
#connection, #deferred_connection, #disable_deferring!, #enable_deferring!, #reset_deferring!
Methods included from Analyze
Methods included from 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
Methods included from Documents
#build_scroll_enumerator, #bulk, #bulk_add, #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.
42 43 44 45 46 |
# File 'lib/elastic_record/index.rb', line 42 def initialize(model) @model = model @disabled = false self.load_from_source = false end |
Instance Attribute Details
#disabled ⇒ Object
Returns the value of attribute disabled.
37 38 39 |
# File 'lib/elastic_record/index.rb', line 37 def disabled @disabled end |
#load_from_source ⇒ Object
Returns the value of attribute load_from_source.
40 41 42 |
# File 'lib/elastic_record/index.rb', line 40 def load_from_source @load_from_source end |
#model ⇒ Object
Returns the value of attribute model.
38 39 40 |
# File 'lib/elastic_record/index.rb', line 38 def model @model end |
#partial_updates ⇒ Object
Returns the value of attribute partial_updates.
39 40 41 |
# File 'lib/elastic_record/index.rb', line 39 def partial_updates @partial_updates end |
Instance Method Details
#alias_name ⇒ Object
56 57 58 |
# File 'lib/elastic_record/index.rb', line 56 def alias_name @alias_name ||= model.base_class.name.demodulize.underscore.pluralize end |
#alias_name=(name) ⇒ Object
52 53 54 |
# File 'lib/elastic_record/index.rb', line 52 def alias_name=(name) @alias_name = name end |
#disable! ⇒ Object
60 61 62 |
# File 'lib/elastic_record/index.rb', line 60 def disable! @disabled = true end |
#enable! ⇒ Object
64 65 66 |
# File 'lib/elastic_record/index.rb', line 64 def enable! @disabled = false end |
#get(end_path, json = nil) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/elastic_record/index.rb', line 84 def get(end_path, json = nil) path = "/#{alias_name}" path += "/#{mapping_type}" path += "/#{end_path}" connection.json_get path, json end |
#initialize_copy(other) ⇒ Object
48 49 50 |
# File 'lib/elastic_record/index.rb', line 48 def initialize_copy(other) @settings = settings.deep_dup end |
#load_from_source! ⇒ Object
68 69 70 71 |
# File 'lib/elastic_record/index.rb', line 68 def load_from_source! self.load_from_source = true model.singleton_class.delegate :find, :find_by, :find_each, :find_in_batches, :first, to: :elastic_search end |
#loading_from_source(&block) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/elastic_record/index.rb', line 73 def loading_from_source(&block) self.load_from_source = true yield ensure self.load_from_source = false end |
#real_connection ⇒ Object
80 81 82 |
# File 'lib/elastic_record/index.rb', line 80 def real_connection model.elastic_connection end |