Class: Elastic::Type
Overview
Add activerecord related index helpers
Instance Attribute Summary
#object
Class Method Summary
collapse
field, fields
nested
included
definition, freeze_definition, #initialize, pre_definition, target=
#as_elastic_document, #as_elastic_source, #fields, #initialize, original_value_occluded?
Class Method Details
.connector ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/elastic/type.rb', line 33
def self.connector
@connector ||= begin
Elastic::Core::Connector.new(
suffix,
definition.as_es_mapping
).tap do |conn|
if Elastic.config.whiny_indices && conn.status != :ready
raise 'elastic index out of sync, try migrating'
end
end
end
end
|
.default_suffix ⇒ Object
13
14
15
|
# File 'lib/elastic/type.rb', line 13
def self.default_suffix
to_s.underscore
end
|
.delete(_object) ⇒ Object
84
85
86
87
|
# File 'lib/elastic/type.rb', line 84
def self.delete(_object)
connector.delete new(_object).as_elastic_document(only_meta: true)
self
end
|
.drop ⇒ Object
93
94
95
96
|
# File 'lib/elastic/type.rb', line 93
def self.drop
connector.drop
self
end
|
.import(_collection, batch_size: nil) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/elastic/type.rb', line 67
def self.import(_collection, batch_size: nil)
batch_size = batch_size || import_batch_size
Commands::ImportIndexDocuments.for(
index: self,
collection: _collection,
batch_size: batch_size
)
self
end
|
.import_batch_size ⇒ Object
25
26
27
|
# File 'lib/elastic/type.rb', line 25
def self.import_batch_size
@import_batch_size || Elastic.config.import_batch_size
end
|
.import_batch_size=(_value) ⇒ Object
29
30
31
|
# File 'lib/elastic/type.rb', line 29
def self.import_batch_size=(_value)
@import_batch_size = _value
end
|
.index(_object) ⇒ Object
79
80
81
82
|
# File 'lib/elastic/type.rb', line 79
def self.index(_object)
connector.index new(_object).as_elastic_document
self
end
|
.index_name ⇒ Object
46
47
48
|
# File 'lib/elastic/type.rb', line 46
def self.index_name
connector.index_name
end
|
.migrate ⇒ Object
50
51
52
53
|
# File 'lib/elastic/type.rb', line 50
def self.migrate
connector.migrate(batch_size: import_batch_size)
self
end
|
.query ⇒ Object
89
90
91
|
# File 'lib/elastic/type.rb', line 89
def self.query
Query.new self
end
|
.refresh ⇒ Object
98
99
100
101
|
# File 'lib/elastic/type.rb', line 98
def self.refresh
connector.refresh
self
end
|
.reindex(verbose: true) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/elastic/type.rb', line 55
def self.reindex(verbose: true)
connector.rollover do
Commands::ImportIndexDocuments.for(
index: self,
verbose: verbose,
batch_size: import_batch_size
)
end
self
end
|
.suffix ⇒ Object
17
18
19
|
# File 'lib/elastic/type.rb', line 17
def self.suffix
@suffix || default_suffix
end
|
.suffix=(_value) ⇒ Object
21
22
23
|
# File 'lib/elastic/type.rb', line 21
def self.suffix=(_value)
@suffix = _value
end
|