elastomer-client 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0ff6e4010e81c9d42f412ac93cda3448bf3207f
4
- data.tar.gz: da3742dd0d0724df7ab5b51b7ab2aa7ce9bca9e6
3
+ metadata.gz: efb8ef5cb70b5ee2dff9d968876ec9b2412650f2
4
+ data.tar.gz: ef5a5fab5b54be5581cddef9e0741f0cae962341
5
5
  SHA512:
6
- metadata.gz: 251b9765f805d5f01dfd66f49e1899b80301ce2c0dfefce8e026657978335bf95ce2551acca5a3548a9c70098cd4f8da336bb674e671a57080d61b4346933af5
7
- data.tar.gz: 2f397fe5deafd4bcdf17a8826715e2ab3f86870008ae0bfe63d1809aa45c49d1da53fb68f276f750327e5653bbf24d1ceeb250ce568392a7e355f8dfb304a0ba
6
+ metadata.gz: d3d7c0fe1ef38202642a185670511ad10e99bacd8a57c8f02ab03adefa0133fad0485511cb9a7d70251533b58031987454686783930340060dc641914c21a05d
7
+ data.tar.gz: b2f69a64ad1e5c6de4f2a6ded6c00f4dbf3c639340bab1003cd7ad9fc80cfef8522df9bfe0be5c9f1e27fb00f7295c194f331c83228c2881ea60f36bdd99eb5f
@@ -1,16 +1,25 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.1
3
+ - 2.3.3
4
+ env:
5
+ # NOTE: Ancient versions of Elasticsearch have different download URLs
6
+ - ES_VERSION=2.3.5 ES_DOWNLOAD_URL=https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/${ES_VERSION}/elasticsearch-${ES_VERSION}.tar.gz
7
+ - ES_VERSION=5.6.4 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
4
8
 
5
- addons:
6
- apt:
7
- sources:
8
- elasticsearch-2.x
9
- packages:
10
- elasticsearch
9
+ matrix:
10
+ allow_failures:
11
+ - env: ES_VERSION=5.6.4 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
11
12
 
12
- services:
13
- - elasticsearch
13
+ # Configure a specific version of Elasticsearch
14
+ # See: https://docs.travis-ci.com/user/database-setup/#Installing-ElasticSearch-on-trusty-container-based-infrastructure
15
+ install:
16
+ - wget ${ES_DOWNLOAD_URL}
17
+ - tar -xzf elasticsearch-${ES_VERSION}.tar.gz
18
+ - ./elasticsearch-${ES_VERSION}/bin/elasticsearch &
19
+ - bundle install
20
+ - wget --quiet --waitretry=1 --retry-connrefused --timeout=10 --output-document=- http://127.0.0.1:9200
21
+
22
+ script: bundle exec rake test
14
23
 
15
24
  notifications:
16
25
  email: false
@@ -1,6 +1,10 @@
1
+ ## 2.3.0 (2017-11-29)
2
+ - Remove Elasticsearch 1.x and earlier code paths
3
+ - Fix CI and configure an Elasticsearch 5.6 build
4
+
1
5
  ## 2.2.0 (2017-04-29)
2
6
  - Added a `clear_scroll` API
3
- - JSON timestamps include millisecodns by default
7
+ - JSON timestamps include milliseconds by default
4
8
  - Removing Fixnum usage
5
9
 
6
10
  ## 2.1.1 (2016-09-02)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Elastomer Client [![Build Status](https://travis-ci.org/github/elastomer-client.svg)](https://travis-ci.org/github/elastomer-client)
1
+ # Elastomer Client [![Build Status](https://travis-ci.org/github/elastomer-client.svg?branch=master)](https://travis-ci.org/github/elastomer-client)
2
2
 
3
3
  Making a stupid simple Elasticsearch client so your project can be smarter!
4
4
 
@@ -10,7 +10,7 @@ Get started by cloning and running a few scripts:
10
10
  $ git clone https://github.com/github/elastomer-client.git
11
11
  $ cd elastomer-client
12
12
  $ script/bootstrap
13
- $ script/test
13
+ $ rake test
14
14
  ```
15
15
 
16
16
  ## Client
@@ -41,7 +41,6 @@ The event namespace is `request.client.elastomer`.
41
41
  - docs.explain
42
42
  - docs.get
43
43
  - docs.index
44
- - docs.more_like_this
45
44
  - docs.multi_get
46
45
  - docs.multi_termvectors
47
46
  - docs.search
@@ -57,7 +56,6 @@ The event namespace is `request.client.elastomer`.
57
56
  - index.create
58
57
  - index.delete
59
58
  - index.delete_alias
60
- - index.delete_mapping
61
59
  - index.exists
62
60
  - index.flush
63
61
  - index.get_alias
@@ -69,9 +67,7 @@ The event namespace is `request.client.elastomer`.
69
67
  - index.recovery
70
68
  - index.refresh
71
69
  - index.segments
72
- - index.snapshot
73
70
  - index.stats
74
- - index.status
75
71
  - index.update_mapping
76
72
  - index.update_settings
77
73
  - nodes.hot_threads
@@ -24,9 +24,11 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "multi_json", "~> 1.12"
25
25
  spec.add_dependency "semantic", "~> 1.6"
26
26
 
27
- spec.add_development_dependency "bundler", "~> 1.14"
28
- spec.add_development_dependency "activesupport", ">= 3.0"
29
- spec.add_development_dependency "minitest", "~> 4.7"
30
- spec.add_development_dependency "webmock", "~> 2.3"
27
+ spec.add_development_dependency "bundler", "~> 1.14"
28
+ spec.add_development_dependency "activesupport", ">= 3.0"
29
+ spec.add_development_dependency "minitest", "~> 5.10"
30
+ spec.add_development_dependency "minitest-fail-fast", "~> 0.1.0"
31
+ spec.add_development_dependency "webmock", "~> 2.3"
32
+ spec.add_development_dependency "awesome_print", "~> 1.8"
31
33
  spec.add_development_dependency "rake"
32
34
  end
@@ -34,7 +34,7 @@ module Elastomer
34
34
  #
35
35
  # Returns the response as a Hash
36
36
  def health( params = {} )
37
- response = client.get "/_cluster/health{/index}", params.merge(:action => "cluster.health")
37
+ response = client.get "/_cluster/health{/index}", params.merge(action: "cluster.health")
38
38
  response.body
39
39
  end
40
40
 
@@ -52,7 +52,7 @@ module Elastomer
52
52
  #
53
53
  # Returns the response as a Hash
54
54
  def state( params = {} )
55
- response = client.get "/_cluster/state{/metrics}{/indices}", params.merge(:action => "cluster.state")
55
+ response = client.get "/_cluster/state{/metrics}{/indices}", params.merge(action: "cluster.state")
56
56
  response.body
57
57
  end
58
58
 
@@ -67,7 +67,7 @@ module Elastomer
67
67
  #
68
68
  # Returns the response as a Hash
69
69
  def stats( params = {} )
70
- response = client.get "/_cluster/stats", params.merge(:action => "cluster.stats")
70
+ response = client.get "/_cluster/stats", params.merge(action: "cluster.stats")
71
71
  response.body
72
72
  end
73
73
 
@@ -80,7 +80,7 @@ module Elastomer
80
80
  #
81
81
  # Returns the response as a Hash
82
82
  def pending_tasks( params = {} )
83
- response = client.get "/_cluster/pending_tasks", params.merge(:action => "cluster.pending_tasks")
83
+ response = client.get "/_cluster/pending_tasks", params.merge(action: "cluster.pending_tasks")
84
84
  response.body
85
85
  end
86
86
 
@@ -101,7 +101,7 @@ module Elastomer
101
101
  #
102
102
  # Returns the response as a Hash
103
103
  def get_settings( params = {} )
104
- response = client.get "/_cluster/settings", params.merge(:action => "cluster.get_settings")
104
+ response = client.get "/_cluster/settings", params.merge(action: "cluster.get_settings")
105
105
  response.body
106
106
  end
107
107
  alias_method :settings, :get_settings
@@ -117,7 +117,7 @@ module Elastomer
117
117
  #
118
118
  # Returns the response as a Hash
119
119
  def update_settings( body, params = {} )
120
- response = client.put "/_cluster/settings", params.merge(:body => body, :action => "cluster.update_settings")
120
+ response = client.put "/_cluster/settings", params.merge(body: body, action: "cluster.update_settings")
121
121
  response.body
122
122
  end
123
123
 
@@ -131,16 +131,16 @@ module Elastomer
131
131
  #
132
132
  # Examples
133
133
  #
134
- # reroute(:move => { :index => 'test', :shard => 0, :from_node => 'node1', :to_node => 'node2' })
134
+ # reroute(move: { index: 'test', shard: 0, from_node: 'node1', to_node: 'node2' })
135
135
  #
136
136
  # reroute([
137
- # { :move => { :index => 'test', :shard => 0, :from_node => 'node1', :to_node => 'node2' }},
138
- # { :allocate => { :index => 'test', :shard => 1, :node => 'node3' }}
137
+ # { move: { index: 'test', shard: 0, from_node: 'node1', to_node: 'node2' }},
138
+ # { allocate: { index: 'test', shard: 1, node: 'node3' }}
139
139
  # ])
140
140
  #
141
- # reroute(:commands => [
142
- # { :move => { :index => 'test', :shard => 0, :from_node => 'node1', :to_node => 'node2' }},
143
- # { :allocate => { :index => 'test', :shard => 1, :node => 'node3' }}
141
+ # reroute(commands: [
142
+ # { move: { index: 'test', shard: 0, from_node: 'node1', to_node: 'node2' }},
143
+ # { allocate: { index: 'test', shard: 1, node: 'node3' }}
144
144
  # ])
145
145
  #
146
146
  # See https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-reroute.html
@@ -152,12 +152,12 @@ module Elastomer
152
152
  elsif commands.is_a?(Hash)
153
153
  # Array() on a Hash does not do what you think it does - that is why
154
154
  # we are explicitly wrapping the Hash via [commands] here.
155
- body = {:commands => [commands]}
155
+ body = {commands: [commands]}
156
156
  else
157
- body = {:commands => Array(commands)}
157
+ body = {commands: Array(commands)}
158
158
  end
159
159
 
160
- response = client.post "/_cluster/reroute", params.merge(:body => body, :action => "cluster.reroute")
160
+ response = client.post "/_cluster/reroute", params.merge(body: body, action: "cluster.reroute")
161
161
  response.body
162
162
  end
163
163
 
@@ -170,7 +170,7 @@ module Elastomer
170
170
  #
171
171
  # Returns the response as a Hash
172
172
  def shutdown( params = {} )
173
- response = client.post "/_shutdown", params.merge(:action => "cluster.shutdown")
173
+ response = client.post "/_shutdown", params.merge(action: "cluster.shutdown")
174
174
  response.body
175
175
  end
176
176
 
@@ -185,13 +185,13 @@ module Elastomer
185
185
  # Examples
186
186
  #
187
187
  # get_aliases
188
- # get_aliases( :index => 'users' )
188
+ # get_aliases( index: 'users' )
189
189
  #
190
190
  # See https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html
191
191
  #
192
192
  # Returns the response body as a Hash
193
193
  def get_aliases( params = {} )
194
- response = client.get "{/index}/_aliases", params.merge(:action => "cluster.get_aliases")
194
+ response = client.get "{/index}/_aliases", params.merge(action: "cluster.get_aliases")
195
195
  response.body
196
196
  end
197
197
  alias_method :aliases, :get_aliases
@@ -199,18 +199,18 @@ module Elastomer
199
199
  # Perform an aliases action on the cluster. We are just a teensy bit
200
200
  # clever here in that a single action can be given or an array of
201
201
  # actions. This API method will wrap the request in the appropriate
202
- # {:actions => [...]} body construct.
202
+ # {actions: [...]} body construct.
203
203
  #
204
204
  # actions - An action Hash or an Array of action Hashes
205
205
  # params - Parameters Hash
206
206
  #
207
207
  # Examples
208
208
  #
209
- # update_aliases(:add => { :index => 'users-1', :alias => 'users' })
209
+ # update_aliases(add: { index: 'users-1', alias: 'users' })
210
210
  #
211
211
  # update_aliases([
212
- # { :remove => { :index => 'users-1', :alias => 'users' }},
213
- # { :add => { :index => 'users-2', :alias => 'users' }}
212
+ # { remove: { index: 'users-1', alias: 'users' }},
213
+ # { add: { index: 'users-2', alias: 'users' }}
214
214
  # ])
215
215
  #
216
216
  # See https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html
@@ -222,12 +222,12 @@ module Elastomer
222
222
  elsif actions.is_a?(Hash)
223
223
  # Array() on a Hash does not do what you think it does - that is why
224
224
  # we are explicitly wrapping the Hash via [actions] here.
225
- body = {:actions => [actions]}
225
+ body = {actions: [actions]}
226
226
  else
227
- body = {:actions => Array(actions)}
227
+ body = {actions: Array(actions)}
228
228
  end
229
229
 
230
- response = client.post "/_aliases", params.merge(:body => body, :action => "cluster.update_aliases")
230
+ response = client.post "/_aliases", params.merge(body: body, action: "cluster.update_aliases")
231
231
  response.body
232
232
  end
233
233
 
@@ -236,18 +236,7 @@ module Elastomer
236
236
  #
237
237
  # Returns the template definitions as a Hash
238
238
  def templates
239
- # ES 1.x supports state filtering via a path segment called metrics.
240
- # ES 0.90 uses query parameters instead.
241
- if client.semantic_version >= "1.0.0"
242
- h = state(:metrics => "metadata")
243
- else
244
- h = state(
245
- :filter_blocks => true,
246
- :filter_nodes => true,
247
- :filter_routing_table => true,
248
- )
249
- end
250
- h["metadata"]["templates"]
239
+ state(metrics: "metadata").dig("metadata", "templates")
251
240
  end
252
241
 
253
242
  # List all indices currently defined. This is just a convenience method
@@ -255,18 +244,7 @@ module Elastomer
255
244
  #
256
245
  # Returns the indices definitions as a Hash
257
246
  def indices
258
- # ES 1.x supports state filtering via a path segment called metrics.
259
- # ES 0.90 uses query parameters instead.
260
- if client.semantic_version >= "1.0.0"
261
- h = state(:metrics => "metadata")
262
- else
263
- h = state(
264
- :filter_blocks => true,
265
- :filter_nodes => true,
266
- :filter_routing_table => true,
267
- )
268
- end
269
- h["metadata"]["indices"]
247
+ state(metrics: "metadata").dig("metadata", "indices")
270
248
  end
271
249
 
272
250
  # List all nodes currently part of the cluster. This is just a convenience
@@ -275,18 +253,7 @@ module Elastomer
275
253
  #
276
254
  # Returns the nodes definitions as a Hash
277
255
  def nodes
278
- # ES 1.x supports state filtering via a path segment called metrics.
279
- # ES 0.90 uses query parameters instead.
280
- if client.semantic_version >= "1.0.0"
281
- h = state(:metrics => "nodes")
282
- else
283
- h = state(
284
- :filter_blocks => true,
285
- :filter_metadata => true,
286
- :filter_routing_table => true,
287
- )
288
- end
289
- h["nodes"]
256
+ state(metrics: "nodes").dig("nodes")
290
257
  end
291
258
 
292
259
  end
@@ -331,33 +331,6 @@ module Elastomer
331
331
  Percolate
332
332
  =end
333
333
 
334
- # Deprecated - use the More Like This query: https://www.elastic.co/guide/en/elasticsearch/reference/2.3/query-dsl-mlt-query.html
335
- # Search for documents similar to a specific document. The
336
- # document :id is provided as part of the params hash. If the _all field
337
- # is not enabled, :mlt_fields must be passed. A query cannot be present in
338
- # the query body, but other fields like :size and :facets are allowed.
339
- #
340
- # params - Parameters Hash
341
- # :id - the ID of the document
342
- #
343
- # Examples
344
- #
345
- # more_like_this(:mlt_fields => "title", :min_term_freq => 1, :type => "doc1", :id => 1)
346
- #
347
- # # with query hash
348
- # more_like_this({:from => 5, :size => 10}, :mlt_fields => "title",
349
- # :min_term_freq => 1, :type => "doc1", :id => 1)
350
- #
351
- # See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-more-like-this.html
352
- #
353
- # Returns the response body as a hash
354
- def more_like_this( query, params = nil )
355
- query, params = extract_params(query) if params.nil?
356
-
357
- response = client.get "/{index}/{type}/{id}/_mlt", update_params(params, :body => query, :action => "docs.more_like_this")
358
- response.body
359
- end
360
-
361
334
  # Compute a score explanation for a query and a specific document. This
362
335
  # can give useful feedback about why a document matched or didn't match
363
336
  # a query. The document :id is provided as part of the params hash.
@@ -54,7 +54,7 @@ module Elastomer
54
54
  #
55
55
  # Returns the response body as a Hash
56
56
  def create( body, params = {} )
57
- response = client.post "/{index}", update_params(params, :body => body, :action => "index.create")
57
+ response = client.put "/{index}", update_params(params, :body => body, :action => "index.create")
58
58
  response.body
59
59
  end
60
60
 
@@ -130,7 +130,7 @@ module Elastomer
130
130
  #
131
131
  # Returns the response body as a Hash
132
132
  def get_mapping( params = {} )
133
- response = client.get "/{index}{/type}/_mapping", update_params(params, :action => "index.get_mapping")
133
+ response = client.get "/{index}/_mapping{/type}", update_params(params, :action => "index.get_mapping")
134
134
  response.body
135
135
  end
136
136
  alias_method :mapping, :get_mapping
@@ -145,29 +145,11 @@ module Elastomer
145
145
  #
146
146
  # Returns the response body as a Hash
147
147
  def update_mapping( type, body, params = {} )
148
- response = client.put "/{index}/{type}/_mapping", update_params(params, :body => body, :type => type, :action => "index.update_mapping")
148
+ response = client.put "/{index}/_mapping/{type}", update_params(params, :body => body, :type => type, :action => "index.update_mapping")
149
149
  response.body
150
150
  end
151
151
  alias_method :put_mapping, :update_mapping
152
152
 
153
- # DEPRECATED: It is no longer possible to delete the mapping for a type.
154
- # Instead you should delete the index and recreate it with new mappings.
155
- # See https://www.elastic.co/guide/en/elasticsearch/reference/2.3/indices-delete-mapping.html
156
- #
157
- # Delete the mapping identified by `type`. This deletes all documents of
158
- # that type from the index.
159
- #
160
- # type - Name of the mapping to update as a String
161
- # params - Parameters Hash
162
- #
163
- # See https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-mapping.html
164
- #
165
- # Returns the response body as a Hash
166
- def delete_mapping( type, params = {} )
167
- response = client.delete "/{index}/{type}", update_params(params, :type => type, :action => "index.delete_mapping")
168
- response.body
169
- end
170
-
171
153
  # Return the aliases associated with this index.
172
154
  #
173
155
  # params - Parameters Hash
@@ -293,22 +275,6 @@ module Elastomer
293
275
  response.body
294
276
  end
295
277
 
296
- # Deprecated: Explicitly snapshot (backup) one or more indices to the
297
- # gateway. By default this happens periodically (every 1 second) but the
298
- # period can be changed or disabled completely.
299
- #
300
- # This API was removed in ES 1.2.
301
- #
302
- # params - Parameters Hash
303
- #
304
- # See https://www.elastic.co/guide/en/elasticsearch/reference/0.90/indices-gateway-snapshot.html
305
- #
306
- # Returns the response body as a Hash
307
- def snapshot( params = {} )
308
- response = client.post "{/index}/_gateway/snapshot", update_params(params, :action => "index.snapshot")
309
- response.body
310
- end
311
-
312
278
  # Provides insight into ongoing index shard recoveries. Recovery status
313
279
  # may be reported for specific indices, or cluster-wide.
314
280
  #
@@ -355,21 +321,6 @@ module Elastomer
355
321
  response.body
356
322
  end
357
323
 
358
- # Deprecated: Retrieve the status of one or more indices. Recovery and
359
- # snapshot status can be retrieved with parameters.
360
- #
361
- # This API was deprecated in 1.2 and is slated for removal.
362
- #
363
- # params - Parameters Hash
364
- #
365
- # See https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-status.html
366
- #
367
- # Returns the response body as a Hash
368
- def status( params = {} )
369
- response = client.get "{/index}/_status", update_params(params, :action => "index.status")
370
- response.body
371
- end
372
-
373
324
  # Retrieve low level Lucene segments information for shards of one
374
325
  # or more indices.
375
326
  #