stretcher 1.7.2 → 1.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/stretcher/server.rb +13 -3
- data/lib/stretcher/version.rb +1 -1
- data/spec/lib/stretcher_server_spec.rb +11 -0
- metadata +2 -2
data/lib/stretcher/server.rb
CHANGED
@@ -115,7 +115,7 @@ module Stretcher
|
|
115
115
|
end
|
116
116
|
|
117
117
|
# Implements the Analyze API
|
118
|
-
#
|
118
|
+
# Ex:
|
119
119
|
# server.analyze("Candles", analyzer: :snowball)
|
120
120
|
# # => #<Hashie::Mash tokens=[#<Hashie::Mash end_offset=7 position=1 start_offset=0 token="candl" type="<ALPHANUM>">]>
|
121
121
|
# as per: http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze.html
|
@@ -124,6 +124,16 @@ module Stretcher
|
|
124
124
|
req.body = text
|
125
125
|
end
|
126
126
|
end
|
127
|
+
|
128
|
+
# Implements the Aliases API
|
129
|
+
# Ex:
|
130
|
+
# server.aliases({actions: {add: {index: :my_index, alias: :my_alias}}})
|
131
|
+
# as per: http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases.html
|
132
|
+
def aliases(body)
|
133
|
+
request(:post, path_uri("/_aliases")) do |req|
|
134
|
+
req.body = body
|
135
|
+
end
|
136
|
+
end
|
127
137
|
|
128
138
|
# Perform a refresh, making all indexed documents available
|
129
139
|
def refresh
|
@@ -151,8 +161,8 @@ module Stretcher
|
|
151
161
|
|
152
162
|
if res.status >= 200 && res.status <= 299
|
153
163
|
res.body
|
154
|
-
elsif res.status
|
155
|
-
err_str = "Error
|
164
|
+
elsif [404, 410].include? res.status
|
165
|
+
err_str = "Error processing request: (#{res.status})! #{res.env[:method]} URL: #{res.env[:url]}"
|
156
166
|
err_str << "\n Resp Body: #{res.body}"
|
157
167
|
raise RequestError::NotFound.new(res), err_str
|
158
168
|
else
|
data/lib/stretcher/version.rb
CHANGED
@@ -25,6 +25,17 @@ describe Stretcher::Server do
|
|
25
25
|
server.stats
|
26
26
|
end
|
27
27
|
|
28
|
+
it "should perform alias operations properly" do
|
29
|
+
# Tear down any leftovers from previous runs
|
30
|
+
server.aliases(actions: [{remove: {alias: :foo_alias}}]) if server.index(:foo_alias).exists?
|
31
|
+
server.index(:foo).delete if server.index(:foo).exists?
|
32
|
+
|
33
|
+
server.index(:foo).create
|
34
|
+
server.aliases(actions: [{add: {index: :foo, alias: :foo_alias}}])
|
35
|
+
|
36
|
+
server.index(:foo_alias).get_settings.should == server.index(:foo).get_settings
|
37
|
+
end
|
38
|
+
|
28
39
|
it "should check the status w/o error" do
|
29
40
|
server.status.ok.should be_true
|
30
41
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stretcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|