rubberband 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTORS +2 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +7 -4
- data/lib/elasticsearch/client/admin_index.rb +22 -1
- data/lib/elasticsearch/client/index.rb +11 -0
- data/lib/elasticsearch/transport/base_protocol.rb +35 -1
- data/lib/elasticsearch/version.rb +1 -1
- data/rubberband.gemspec +2 -1
- data/spec/admin_spec.rb +1 -1
- data/spec/bulk_spec.rb +1 -1
- data/spec/connect_spec.rb +3 -3
- data/spec/index_spec.rb +10 -1
- data/spec/type_spec.rb +1 -1
- metadata +133 -71
data/CONTRIBUTORS
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rubberband (0.1.
|
4
|
+
rubberband (0.1.2)
|
5
5
|
patron
|
6
6
|
yajl-ruby
|
7
7
|
|
@@ -10,7 +10,8 @@ GEM
|
|
10
10
|
specs:
|
11
11
|
diff-lcs (1.1.2)
|
12
12
|
mocha (0.9.12)
|
13
|
-
patron (0.4.
|
13
|
+
patron (0.4.12)
|
14
|
+
rake (0.9.2)
|
14
15
|
rspec (2.5.0)
|
15
16
|
rspec-core (~> 2.5.0)
|
16
17
|
rspec-expectations (~> 2.5.0)
|
@@ -23,7 +24,7 @@ GEM
|
|
23
24
|
simplecov-html (~> 0.4.3)
|
24
25
|
simplecov-html (0.4.3)
|
25
26
|
yajl-ruby (0.8.2)
|
26
|
-
yard (0.
|
27
|
+
yard (0.7.2)
|
27
28
|
|
28
29
|
PLATFORMS
|
29
30
|
ruby
|
@@ -31,7 +32,9 @@ PLATFORMS
|
|
31
32
|
DEPENDENCIES
|
32
33
|
bundler (~> 1.0.0)
|
33
34
|
mocha (~> 0.9.0)
|
35
|
+
patron (~> 0.4.12)
|
36
|
+
rake (~> 0.9.2)
|
34
37
|
rspec (~> 2.0)
|
35
38
|
rubberband!
|
36
39
|
simplecov (>= 0.3.8)
|
37
|
-
yard (
|
40
|
+
yard (>= 0.7.0)
|
@@ -69,6 +69,11 @@ module ElasticSearch
|
|
69
69
|
execute(:update_mapping, indices, type, mapping, options)
|
70
70
|
end
|
71
71
|
|
72
|
+
def delete_mapping(options={})
|
73
|
+
index, type, options = extract_required_scope(options)
|
74
|
+
execute(:delete_mapping, index, type, options)
|
75
|
+
end
|
76
|
+
|
72
77
|
def update_settings(settings, options={})
|
73
78
|
index, type, options = extract_scope(options)
|
74
79
|
execute(:update_settings, index, settings, options)
|
@@ -97,7 +102,7 @@ module ElasticSearch
|
|
97
102
|
indices.collect! { |i| PSEUDO_INDICES.include?(i) ? "_#{i}" : i }
|
98
103
|
execute(:refresh, indices, options)
|
99
104
|
end
|
100
|
-
|
105
|
+
|
101
106
|
# list of indices, or :all
|
102
107
|
# no options
|
103
108
|
# default: default_index if defined, otherwise all
|
@@ -117,6 +122,22 @@ module ElasticSearch
|
|
117
122
|
indices.collect! { |i| PSEUDO_INDICES.include?(i) ? "_#{i}" : i }
|
118
123
|
execute(:optimize, indices, options)
|
119
124
|
end
|
125
|
+
|
126
|
+
def create_river(type, create_options, options={})
|
127
|
+
execute(:create_river, type, create_options, options)
|
128
|
+
end
|
129
|
+
|
130
|
+
def get_river(type, options={})
|
131
|
+
execute(:get_river, type, options)
|
132
|
+
end
|
133
|
+
|
134
|
+
def river_status(type, options={})
|
135
|
+
execute(:river_status, type, options)
|
136
|
+
end
|
137
|
+
|
138
|
+
def delete_river(type=nil, options={})
|
139
|
+
execute(:delete_river, type, options)
|
140
|
+
end
|
120
141
|
end
|
121
142
|
end
|
122
143
|
end
|
@@ -127,6 +127,17 @@ module ElasticSearch
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
end
|
130
|
+
|
131
|
+
# minor multi get support
|
132
|
+
def multi_get(ids, options={})
|
133
|
+
index, type, options = extract_required_scope(options)
|
134
|
+
results = execute(:multi_get, index, type, ids, options)
|
135
|
+
if(results)
|
136
|
+
hits = []
|
137
|
+
results.each { |hit| hits << Hit.new(hit) }
|
138
|
+
hits
|
139
|
+
end
|
140
|
+
end
|
130
141
|
end
|
131
142
|
end
|
132
143
|
end
|
@@ -87,6 +87,18 @@ module ElasticSearch
|
|
87
87
|
handle_error(response) unless response.status == 200
|
88
88
|
encoder.decode(response.body) # {"items => [ {"delete"/"create" => {"_index", "_type", "_id", "ok"}} ] }
|
89
89
|
end
|
90
|
+
|
91
|
+
# Uses a post request so we can send ids in content
|
92
|
+
def multi_get(index, type, ids, options={})
|
93
|
+
# { "docs" = [ {...}, {...}, ...]}
|
94
|
+
results = standard_request(:post, { :index => index, :type => type, :op => "_mget"},
|
95
|
+
options, encoder.encode({"ids" => ids}))['docs']
|
96
|
+
results.each do |hit|
|
97
|
+
unescape_id!(hit)
|
98
|
+
set_encoding!(hit)
|
99
|
+
end
|
100
|
+
results
|
101
|
+
end
|
90
102
|
end
|
91
103
|
|
92
104
|
module IndexAdminProtocol
|
@@ -114,6 +126,10 @@ module ElasticSearch
|
|
114
126
|
standard_request(:get, {:index => index_list, :op => "_mapping"})
|
115
127
|
end
|
116
128
|
|
129
|
+
def delete_mapping(index, type, options={})
|
130
|
+
standard_request(:delete, {:index => index, :type => type, :op => "_mapping"})
|
131
|
+
end
|
132
|
+
|
117
133
|
def update_settings(index, settings, options)
|
118
134
|
standard_request(:put, {:index => index, :op => "_settings"}, options, encoder.encode(settings))
|
119
135
|
end
|
@@ -137,6 +153,24 @@ module ElasticSearch
|
|
137
153
|
def optimize(index_list, options={})
|
138
154
|
standard_request(:post, {:index => index_list, :op => "_optimize"}, options, {})
|
139
155
|
end
|
156
|
+
|
157
|
+
def create_river(type, create_options={}, options={})
|
158
|
+
standard_request(:put, {:index => "_river", :type => type, :op => "_meta"}, options, encoder.encode(create_options))
|
159
|
+
end
|
160
|
+
|
161
|
+
def get_river(type, options={})
|
162
|
+
standard_request(:get, {:index => "_river", :type => type, :op => "_meta"})
|
163
|
+
end
|
164
|
+
|
165
|
+
def river_status(type, options={})
|
166
|
+
standard_request(:get, {:index => "_river", :type => type, :op => "_status"})
|
167
|
+
end
|
168
|
+
|
169
|
+
def delete_river(type, options={})
|
170
|
+
params = {:index => "_river"}
|
171
|
+
params[:type] = type unless type.nil?
|
172
|
+
standard_request(:delete, params)
|
173
|
+
end
|
140
174
|
end
|
141
175
|
|
142
176
|
module ClusterAdminProtocol
|
@@ -170,7 +204,7 @@ module ElasticSearch
|
|
170
204
|
|
171
205
|
def standard_request(*args)
|
172
206
|
response = request(*args)
|
173
|
-
handle_error(response) unless response.status
|
207
|
+
handle_error(response) unless response.status >= 200 && response.status < 300
|
174
208
|
encoder.decode(response.body)
|
175
209
|
end
|
176
210
|
|
data/rubberband.gemspec
CHANGED
@@ -28,8 +28,9 @@ Gem::Specification.new do |s|
|
|
28
28
|
|
29
29
|
s.add_runtime_dependency("patron", [">= 0"])
|
30
30
|
s.add_runtime_dependency("yajl-ruby", [">= 0"])
|
31
|
+
s.add_development_dependency("rake", ["~> 0.9.2"])
|
31
32
|
s.add_development_dependency("rspec", ["~> 2.0"])
|
32
|
-
s.add_development_dependency("yard", ["
|
33
|
+
s.add_development_dependency("yard", [">= 0.7.0"])
|
33
34
|
s.add_development_dependency("bundler", ["~> 1.0.0"])
|
34
35
|
s.add_development_dependency("simplecov", [">= 0.3.8"])
|
35
36
|
s.add_development_dependency("mocha", ["~> 0.9.0"])
|
data/spec/admin_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
3
|
describe "basic ops" do
|
4
4
|
before(:all) do
|
5
5
|
@first_index = 'first-' + Time.now.to_i.to_s
|
6
|
-
@client = ElasticSearch.new('127.0.0.1:9200', :index => @first_index, :type => "tweet")
|
6
|
+
@client = ElasticSearch.new('http://127.0.0.1:9200', :index => @first_index, :type => "tweet")
|
7
7
|
end
|
8
8
|
|
9
9
|
after(:all) do
|
data/spec/bulk_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
3
|
describe "bulk ops" do
|
4
4
|
before(:all) do
|
5
5
|
@index = 'first-' + Time.now.to_i.to_s
|
6
|
-
@client = ElasticSearch.new('127.0.0.1:9200', :index => @index, :type => "tweet")
|
6
|
+
@client = ElasticSearch.new('http://127.0.0.1:9200', :index => @index, :type => "tweet")
|
7
7
|
end
|
8
8
|
|
9
9
|
after(:all) do
|
data/spec/connect_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
3
|
describe "connect" do
|
4
4
|
|
5
5
|
context 'one server' do
|
6
|
-
let(:servers) { '127.0.0.1:9200' }
|
6
|
+
let(:servers) { 'http://127.0.0.1:9200' }
|
7
7
|
|
8
8
|
it 'should connect' do
|
9
9
|
client = ElasticSearch.new(servers)
|
@@ -15,7 +15,7 @@ describe "connect" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
context 'invalid server' do
|
18
|
-
let(:servers) { '0.1.1.1:9200' }
|
18
|
+
let(:servers) { 'http://0.1.1.1:9200' }
|
19
19
|
|
20
20
|
it 'should raise ConnectionFailed' do
|
21
21
|
expect { ElasticSearch.new(servers).nodes_info }.to raise_error(ElasticSearch::ConnectionFailed)
|
@@ -23,7 +23,7 @@ describe "connect" do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
context 'invalid servers' do
|
26
|
-
let(:servers) { ['0.1.1.1:9200', '0.2.2.2:9200'] }
|
26
|
+
let(:servers) { ['http://0.1.1.1:9200', 'http://0.2.2.2:9200'] }
|
27
27
|
|
28
28
|
it 'should raise ConnectionFailed' do
|
29
29
|
expect { ElasticSearch.new(servers).nodes_info }.to raise_error(ElasticSearch::ConnectionFailed)
|
data/spec/index_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
3
|
describe "index ops" do
|
4
4
|
before(:all) do
|
5
5
|
@first_index = 'first-' + Time.now.to_i.to_s
|
6
|
-
@client = ElasticSearch.new('127.0.0.1:9200', :index => @first_index, :type => "tweet")
|
6
|
+
@client = ElasticSearch.new('http://127.0.0.1:9200', :index => @first_index, :type => "tweet")
|
7
7
|
end
|
8
8
|
|
9
9
|
after(:all) do
|
@@ -51,4 +51,13 @@ describe "index ops" do
|
|
51
51
|
@client.refresh
|
52
52
|
@client.count(:term => { :deleted => 'bar'}).should == 0
|
53
53
|
end
|
54
|
+
|
55
|
+
it 'should perform a successful multi get' do
|
56
|
+
@client.index({:foo => "bar"}, :id => "1")
|
57
|
+
@client.index({:foo => "baz"}, :id => "2")
|
58
|
+
@client.index({:foo => "bazbar"}, :id => "3")
|
59
|
+
ids = ["1", "2", "3"]
|
60
|
+
results = @client.multi_get(ids).inject([]) { |r,e| r << e.id }
|
61
|
+
results.should == ids
|
62
|
+
end
|
54
63
|
end
|
data/spec/type_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe "type and index parameters" do
|
|
7
7
|
@second_index = 'second-' + Time.now.to_i.to_s
|
8
8
|
@third_index = 'third-' + Time.now.to_i.to_s
|
9
9
|
@username = 'kimchy' + Time.now.to_i.to_s
|
10
|
-
@client = ElasticSearch.new('127.0.0.1:9200', :index => @first_index, :type => "tweet")
|
10
|
+
@client = ElasticSearch.new('http://127.0.0.1:9200', :index => @first_index, :type => "tweet")
|
11
11
|
@client.index({:user => @username}, :id => 1)
|
12
12
|
@client.index({:user => @username}, :id => 2, :type => "grillo")
|
13
13
|
@client.index({:user => @username}, :id => 3, :type => "cote")
|
metadata
CHANGED
@@ -1,102 +1,156 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubberband
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Grant Rodgers
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2011-07-28 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: patron
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
22
32
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
26
35
|
name: yajl-ruby
|
27
|
-
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
38
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
33
46
|
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rake
|
34
50
|
prerelease: false
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: rspec
|
38
|
-
requirement: &10696040 !ruby/object:Gem::Requirement
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
52
|
none: false
|
40
|
-
requirements:
|
53
|
+
requirements:
|
41
54
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 63
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
- 9
|
60
|
+
- 2
|
61
|
+
version: 0.9.2
|
44
62
|
type: :development
|
63
|
+
version_requirements: *id003
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: rspec
|
45
66
|
prerelease: false
|
46
|
-
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: yard
|
49
|
-
requirement: &10695120 !ruby/object:Gem::Requirement
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
68
|
none: false
|
51
|
-
requirements:
|
69
|
+
requirements:
|
52
70
|
- - ~>
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 2
|
75
|
+
- 0
|
76
|
+
version: "2.0"
|
55
77
|
type: :development
|
78
|
+
version_requirements: *id004
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: yard
|
56
81
|
prerelease: false
|
57
|
-
|
58
|
-
|
82
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
- 7
|
91
|
+
- 0
|
92
|
+
version: 0.7.0
|
93
|
+
type: :development
|
94
|
+
version_requirements: *id005
|
95
|
+
- !ruby/object:Gem::Dependency
|
59
96
|
name: bundler
|
60
|
-
|
97
|
+
prerelease: false
|
98
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
61
99
|
none: false
|
62
|
-
requirements:
|
100
|
+
requirements:
|
63
101
|
- - ~>
|
64
|
-
- !ruby/object:Gem::Version
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 23
|
104
|
+
segments:
|
105
|
+
- 1
|
106
|
+
- 0
|
107
|
+
- 0
|
65
108
|
version: 1.0.0
|
66
109
|
type: :development
|
67
|
-
|
68
|
-
|
69
|
-
- !ruby/object:Gem::Dependency
|
110
|
+
version_requirements: *id006
|
111
|
+
- !ruby/object:Gem::Dependency
|
70
112
|
name: simplecov
|
71
|
-
|
113
|
+
prerelease: false
|
114
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
72
115
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
- 3
|
123
|
+
- 8
|
76
124
|
version: 0.3.8
|
77
125
|
type: :development
|
78
|
-
|
79
|
-
|
80
|
-
- !ruby/object:Gem::Dependency
|
126
|
+
version_requirements: *id007
|
127
|
+
- !ruby/object:Gem::Dependency
|
81
128
|
name: mocha
|
82
|
-
|
129
|
+
prerelease: false
|
130
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
83
131
|
none: false
|
84
|
-
requirements:
|
132
|
+
requirements:
|
85
133
|
- - ~>
|
86
|
-
- !ruby/object:Gem::Version
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
hash: 59
|
136
|
+
segments:
|
137
|
+
- 0
|
138
|
+
- 9
|
139
|
+
- 0
|
87
140
|
version: 0.9.0
|
88
141
|
type: :development
|
89
|
-
|
90
|
-
version_requirements: *10688320
|
142
|
+
version_requirements: *id008
|
91
143
|
description: An ElasticSearch client with ThriftClient-like failover handling.
|
92
|
-
email:
|
144
|
+
email:
|
93
145
|
- grantr@gmail.com
|
94
146
|
executables: []
|
147
|
+
|
95
148
|
extensions: []
|
96
|
-
|
149
|
+
|
150
|
+
extra_rdoc_files:
|
97
151
|
- LICENSE
|
98
152
|
- README.rdoc
|
99
|
-
files:
|
153
|
+
files:
|
100
154
|
- .autotest
|
101
155
|
- .gitignore
|
102
156
|
- .rspec
|
@@ -141,31 +195,39 @@ files:
|
|
141
195
|
- spec/type_spec.rb
|
142
196
|
- vendor/elasticsearch/elasticsearch.thrift
|
143
197
|
homepage: http://github.com/grantr/rubberband
|
144
|
-
licenses:
|
198
|
+
licenses:
|
145
199
|
- Apache v2
|
146
200
|
post_install_message:
|
147
201
|
rdoc_options: []
|
148
|
-
|
202
|
+
|
203
|
+
require_paths:
|
149
204
|
- lib
|
150
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
205
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
206
|
none: false
|
152
|
-
requirements:
|
153
|
-
- -
|
154
|
-
- !ruby/object:Gem::Version
|
155
|
-
|
156
|
-
|
207
|
+
requirements:
|
208
|
+
- - ">="
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
hash: 3
|
211
|
+
segments:
|
212
|
+
- 0
|
213
|
+
version: "0"
|
214
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
215
|
none: false
|
158
|
-
requirements:
|
159
|
-
- -
|
160
|
-
- !ruby/object:Gem::Version
|
161
|
-
|
216
|
+
requirements:
|
217
|
+
- - ">="
|
218
|
+
- !ruby/object:Gem::Version
|
219
|
+
hash: 3
|
220
|
+
segments:
|
221
|
+
- 0
|
222
|
+
version: "0"
|
162
223
|
requirements: []
|
224
|
+
|
163
225
|
rubyforge_project: rubberband
|
164
|
-
rubygems_version: 1.8.
|
226
|
+
rubygems_version: 1.8.6
|
165
227
|
signing_key:
|
166
228
|
specification_version: 3
|
167
229
|
summary: An ElasticSearch client with ThriftClient-like failover handling.
|
168
|
-
test_files:
|
230
|
+
test_files:
|
169
231
|
- spec/admin_spec.rb
|
170
232
|
- spec/bulk_spec.rb
|
171
233
|
- spec/connect_spec.rb
|