Class: Elasticshell::Scopes::Index
Constant Summary
Constants included
from HasName
HasName::FORBIDDEN_NAME_CHARS
Constants included
from HasVerb
HasVerb::VERBS
Instance Attribute Summary collapse
Attributes included from HasName
#name
#client, #last_refresh_at, #path, #scopes
Class Method Summary
collapse
Instance Method Summary
collapse
#completing_scope_path_and_prefix, #completion_proc, #initial_scopes, #refresh, #refresh!, #refreshed?, #request_names, #requests, #requests_matching, #scopes_matching, #to_s
Methods included from HasVerb
#verb, #verb=
Constructor Details
#initialize(name, options = {}) ⇒ Index
Returns a new instance of Index.
11
12
13
14
15
|
# File 'lib/elasticshell/scopes/index.rb', line 11
def initialize name, options={}
self.name = name
@mappings = []
super("/#{self.name}", options)
end
|
Instance Attribute Details
#mappings ⇒ Object
Returns the value of attribute mappings.
9
10
11
|
# File 'lib/elasticshell/scopes/index.rb', line 9
def mappings
@mappings
end
|
Class Method Details
.requests ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/elasticshell/scopes/index.rb', line 17
def self.requests
@requests ||= {
"GET" => {
"_aliases" => "Find the aliases for this index.",
"_status" => "Retrieve the status of this index.",
"_stats" => "Retrieve usage stats for this index.",
"_search" => "Search records within this index.",
"_count" => "Count records within this index."
}
}
end
|
Instance Method Details
#exists? ⇒ Boolean
43
44
45
46
47
|
# File 'lib/elasticshell/scopes/index.rb', line 43
def exists?
return false unless client.connected?
global.refresh
global.scopes.include?(name)
end
|
#fetch_scopes ⇒ Object
57
58
59
60
|
# File 'lib/elasticshell/scopes/index.rb', line 57
def fetch_scopes
@mappings = (client.safely(:get, {:index => name, :op => '_mapping'}, :return => { name => {}}, :log => false)[name] || {}).keys
self.scopes += @mappings
end
|
#global ⇒ Object
29
30
31
|
# File 'lib/elasticshell/scopes/index.rb', line 29
def global
@global ||= Scopes.global(:client => client)
end
|
#mapping(mapping_name, options = {}) ⇒ Object
62
63
64
|
# File 'lib/elasticshell/scopes/index.rb', line 62
def mapping mapping_name, options={}
Scopes.mapping(self.name, mapping_name, options.merge(:client => client))
end
|
#multi? ⇒ Boolean
49
50
51
|
# File 'lib/elasticshell/scopes/index.rb', line 49
def multi?
name.include?(',')
end
|
#reset! ⇒ Object
37
38
39
40
41
|
# File 'lib/elasticshell/scopes/index.rb', line 37
def reset!
@status = nil
@mappings = []
super()
end
|
#single? ⇒ Boolean
53
54
55
|
# File 'lib/elasticshell/scopes/index.rb', line 53
def single?
! multi?
end
|
#status ⇒ Object
33
34
35
|
# File 'lib/elasticshell/scopes/index.rb', line 33
def status
@status ||= client.safely(:get, {:index => name, :op => '_status'}, :return => {"indices" => {name => {}}}, :log => false)
end
|