elastomer-client 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.overcommit.yml +5 -0
- data/.rubocop.yml +83 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -2
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/elastomer-client.gemspec +4 -2
- data/lib/elastomer/client.rb +42 -37
- data/lib/elastomer/client/bulk.rb +2 -2
- data/lib/elastomer/client/cluster.rb +19 -19
- data/lib/elastomer/client/delete_by_query.rb +7 -7
- data/lib/elastomer/client/docs.rb +81 -24
- data/lib/elastomer/client/errors.rb +2 -2
- data/lib/elastomer/client/index.rb +65 -29
- data/lib/elastomer/client/multi_percolate.rb +127 -0
- data/lib/elastomer/client/multi_search.rb +2 -2
- data/lib/elastomer/client/nodes.rb +4 -4
- data/lib/elastomer/client/percolator.rb +77 -0
- data/lib/elastomer/client/repository.rb +7 -7
- data/lib/elastomer/client/scroller.rb +14 -14
- data/lib/elastomer/client/snapshot.rb +9 -9
- data/lib/elastomer/client/template.rb +3 -3
- data/lib/elastomer/client/warmer.rb +5 -16
- data/lib/elastomer/core_ext/time.rb +1 -1
- data/lib/elastomer/middleware/encode_json.rb +5 -5
- data/lib/elastomer/middleware/opaque_id.rb +3 -3
- data/lib/elastomer/middleware/parse_json.rb +5 -5
- data/lib/elastomer/notifications.rb +4 -4
- data/lib/elastomer/version.rb +1 -1
- data/script/bootstrap +2 -0
- data/script/console +5 -5
- data/test/assertions.rb +26 -24
- data/test/client/bulk_test.rb +111 -111
- data/test/client/cluster_test.rb +58 -58
- data/test/client/delete_by_query_test.rb +53 -53
- data/test/client/docs_test.rb +279 -203
- data/test/client/errors_test.rb +1 -1
- data/test/client/index_test.rb +143 -109
- data/test/client/multi_percolate_test.rb +130 -0
- data/test/client/multi_search_test.rb +30 -28
- data/test/client/nodes_test.rb +30 -29
- data/test/client/percolator_test.rb +52 -0
- data/test/client/repository_test.rb +23 -23
- data/test/client/scroller_test.rb +40 -40
- data/test/client/snapshot_test.rb +15 -15
- data/test/client/stubbed_client_test.rb +15 -15
- data/test/client/template_test.rb +10 -10
- data/test/client/warmer_test.rb +18 -18
- data/test/client_test.rb +53 -53
- data/test/core_ext/time_test.rb +12 -12
- data/test/middleware/encode_json_test.rb +20 -20
- data/test/middleware/opaque_id_test.rb +10 -10
- data/test/middleware/parse_json_test.rb +14 -14
- data/test/notifications_test.rb +32 -32
- data/test/test_helper.rb +24 -24
- metadata +38 -2
@@ -60,7 +60,7 @@ module Elastomer
|
|
60
60
|
@client = client
|
61
61
|
@query = query
|
62
62
|
@params = params
|
63
|
-
@response_stats = {
|
63
|
+
@response_stats = { "took" => 0, "_indices" => { "_all" => {} }, "failures" => [] }
|
64
64
|
end
|
65
65
|
|
66
66
|
attr_reader :client, :query, :params, :response_stats
|
@@ -95,9 +95,9 @@ module Elastomer
|
|
95
95
|
# item - A bulk response item
|
96
96
|
def accumulate(item)
|
97
97
|
item = item["delete"]
|
98
|
-
(@response_stats[
|
99
|
-
@response_stats[
|
100
|
-
@response_stats[
|
98
|
+
(@response_stats["_indices"][item["_index"]] ||= {}).merge!(categorize(item)) { |_, n, m| n + m }
|
99
|
+
@response_stats["_indices"]["_all"].merge!(categorize(item)) { |_, n, m| n + m }
|
100
|
+
@response_stats["failures"] << item unless is_ok? item["status"]
|
101
101
|
end
|
102
102
|
|
103
103
|
# Perform the Delete by Query action
|
@@ -105,13 +105,13 @@ module Elastomer
|
|
105
105
|
# Returns a Hash of statistics about the bulk operation
|
106
106
|
def execute
|
107
107
|
ops = Enumerator.new do |yielder|
|
108
|
-
@client.scan(@query, @params).each_document do |hit|
|
109
|
-
yielder.yield([:delete, { _id
|
108
|
+
@client.scan(@query, @params.merge(:_source => false)).each_document do |hit|
|
109
|
+
yielder.yield([:delete, { :_id => hit["_id"], :_type => hit["_type"], :_index => hit["_index"] }])
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
113
|
stats = @client.bulk_stream_items(ops, @params) { |item| accumulate(item) }
|
114
|
-
@response_stats[
|
114
|
+
@response_stats["took"] = stats["took"]
|
115
115
|
@response_stats
|
116
116
|
end
|
117
117
|
|
@@ -26,8 +26,8 @@ module Elastomer
|
|
26
26
|
#
|
27
27
|
def initialize( client, name, type = nil )
|
28
28
|
@client = client
|
29
|
-
@name = @client.assert_param_presence(name,
|
30
|
-
@type = @client.assert_param_presence(type,
|
29
|
+
@name = @client.assert_param_presence(name, "index name") unless name.nil?
|
30
|
+
@type = @client.assert_param_presence(type, "document type") unless type.nil?
|
31
31
|
end
|
32
32
|
|
33
33
|
attr_reader :client, :name, :type
|
@@ -68,15 +68,15 @@ module Elastomer
|
|
68
68
|
def index( document, params = {} )
|
69
69
|
overrides = from_document document
|
70
70
|
params = update_params(params, overrides)
|
71
|
-
params[:action] =
|
71
|
+
params[:action] = "docs.index"
|
72
72
|
|
73
73
|
params.delete(:id) if params[:id].nil? || params[:id].to_s =~ /\A\s*\z/
|
74
74
|
|
75
75
|
response =
|
76
76
|
if params[:id]
|
77
|
-
client.put
|
77
|
+
client.put "/{index}/{type}/{id}", params
|
78
78
|
else
|
79
|
-
client.post
|
79
|
+
client.post "/{index}/{type}", params
|
80
80
|
end
|
81
81
|
|
82
82
|
response.body
|
@@ -92,7 +92,7 @@ module Elastomer
|
|
92
92
|
#
|
93
93
|
# Returns the response body as a Hash
|
94
94
|
def delete( params = {} )
|
95
|
-
response = client.delete
|
95
|
+
response = client.delete "/{index}/{type}/{id}", update_params(params, :action => "docs.delete")
|
96
96
|
response.body
|
97
97
|
end
|
98
98
|
|
@@ -106,7 +106,7 @@ module Elastomer
|
|
106
106
|
#
|
107
107
|
# Returns the response body as a Hash
|
108
108
|
def get( params = {} )
|
109
|
-
response = client.get
|
109
|
+
response = client.get "/{index}/{type}/{id}", update_params(params, :action => "docs.get")
|
110
110
|
response.body
|
111
111
|
end
|
112
112
|
|
@@ -120,7 +120,7 @@ module Elastomer
|
|
120
120
|
#
|
121
121
|
# Returns true if the document exists
|
122
122
|
def exists?( params = {} )
|
123
|
-
response = client.head
|
123
|
+
response = client.head "/{index}/{type}/{id}", update_params(params, :action => "docs.exists")
|
124
124
|
response.success?
|
125
125
|
end
|
126
126
|
alias_method :exist?, :exists?
|
@@ -135,7 +135,7 @@ module Elastomer
|
|
135
135
|
#
|
136
136
|
# Returns the response body as a Hash
|
137
137
|
def source( params = {} )
|
138
|
-
response = client.get
|
138
|
+
response = client.get "/{index}/{type}/{id}/_source", update_params(params, :action => "docs.source")
|
139
139
|
response.body
|
140
140
|
end
|
141
141
|
|
@@ -149,9 +149,9 @@ module Elastomer
|
|
149
149
|
# Returns the response body as a Hash
|
150
150
|
def multi_get( body, params = {} )
|
151
151
|
overrides = from_document body
|
152
|
-
overrides[:action] =
|
152
|
+
overrides[:action] = "docs.multi_get"
|
153
153
|
|
154
|
-
response = client.get
|
154
|
+
response = client.get "{/index}{/type}/_mget", update_params(params, overrides)
|
155
155
|
response.body
|
156
156
|
end
|
157
157
|
alias_method :mget, :multi_get
|
@@ -166,9 +166,9 @@ module Elastomer
|
|
166
166
|
# Returns the response body as a Hash
|
167
167
|
def update( script, params = {} )
|
168
168
|
overrides = from_document script
|
169
|
-
overrides[:action] =
|
169
|
+
overrides[:action] = "docs.update"
|
170
170
|
|
171
|
-
response = client.post
|
171
|
+
response = client.post "/{index}/{type}/{id}/_update", update_params(params, overrides)
|
172
172
|
response.body
|
173
173
|
end
|
174
174
|
|
@@ -197,7 +197,7 @@ module Elastomer
|
|
197
197
|
def search( query, params = nil )
|
198
198
|
query, params = extract_params(query) if params.nil?
|
199
199
|
|
200
|
-
response = client.get
|
200
|
+
response = client.get "/{index}{/type}/_search", update_params(params, :body => query, :action => "docs.search")
|
201
201
|
response.body
|
202
202
|
end
|
203
203
|
|
@@ -215,7 +215,7 @@ module Elastomer
|
|
215
215
|
#
|
216
216
|
# Returns the response body as a hash
|
217
217
|
def search_shards( params = {} )
|
218
|
-
response = client.get
|
218
|
+
response = client.get "/{index}{/type}/_search_shards", update_params(params, :action => "docs.search_shards")
|
219
219
|
response.body
|
220
220
|
end
|
221
221
|
|
@@ -242,7 +242,7 @@ module Elastomer
|
|
242
242
|
def count( query, params = nil )
|
243
243
|
query, params = extract_params(query) if params.nil?
|
244
244
|
|
245
|
-
response = client.get
|
245
|
+
response = client.get "/{index}{/type}/_count", update_params(params, :body => query, :action => "docs.count")
|
246
246
|
response.body
|
247
247
|
end
|
248
248
|
|
@@ -261,6 +261,38 @@ module Elastomer
|
|
261
261
|
@client.delete_by_query(query, update_params(params))
|
262
262
|
end
|
263
263
|
|
264
|
+
# Matches a provided or existing document to the stored percolator
|
265
|
+
# queries. To match an existing document, pass `nil` as the body and
|
266
|
+
# include `:id` in the params.
|
267
|
+
#
|
268
|
+
# Examples
|
269
|
+
#
|
270
|
+
# index.percolator(1).create :query => { :match => { :author => "pea53" } }
|
271
|
+
# docs.percolate :doc => { :author => "pea53" }
|
272
|
+
# docs.percolate nil, :id => 3
|
273
|
+
#
|
274
|
+
# Returns the response body as a Hash
|
275
|
+
def percolate(body, params = {})
|
276
|
+
response = client.get "/{index}/{type}{/id}/_percolate", update_params(params, :body => body, :action => "percolator.percolate")
|
277
|
+
response.body
|
278
|
+
end
|
279
|
+
|
280
|
+
# Counts the queries that match a provided or existing document. To count
|
281
|
+
# matches for an existing document, pass `nil` as the body and include
|
282
|
+
# `:id` in the params.
|
283
|
+
#
|
284
|
+
# Examples
|
285
|
+
#
|
286
|
+
# index.register_percolator_query 1, :query => { :match => { :author => "pea53" } }
|
287
|
+
# docs.percolate_count :doc => { :author => "pea53" }
|
288
|
+
# docs.percolate_count nil, :id => 3
|
289
|
+
#
|
290
|
+
# Returns the count
|
291
|
+
def percolate_count(body, params = {})
|
292
|
+
response = client.get "/{index}/{type}{/id}/_percolate/count", update_params(params, :body => body, :action => "percolator.percolate_count")
|
293
|
+
response.body["total"]
|
294
|
+
end
|
295
|
+
|
264
296
|
# Returns information and statistics on terms in the fields of a
|
265
297
|
# particular document as stored in the index. The :id is provided as part
|
266
298
|
# of the params hash.
|
@@ -272,7 +304,7 @@ module Elastomer
|
|
272
304
|
#
|
273
305
|
# Returns the response body as a hash
|
274
306
|
def termvector( params = {} )
|
275
|
-
response = client.get
|
307
|
+
response = client.get "/{index}/{type}/{id}/_termvector", update_params(params, :action => "docs.termvector")
|
276
308
|
response.body
|
277
309
|
end
|
278
310
|
alias_method :termvectors, :termvector
|
@@ -290,7 +322,7 @@ module Elastomer
|
|
290
322
|
#
|
291
323
|
# Returns the response body as a hash
|
292
324
|
def multi_termvectors( body, params = {} )
|
293
|
-
response = client.get
|
325
|
+
response = client.get "{/index}{/type}/_mtermvectors", update_params(params, :body => body, :action => "docs.multi_termvectors")
|
294
326
|
response.body
|
295
327
|
end
|
296
328
|
alias_method :multi_term_vectors, :multi_termvectors
|
@@ -322,7 +354,7 @@ Percolate
|
|
322
354
|
def more_like_this( query, params = nil )
|
323
355
|
query, params = extract_params(query) if params.nil?
|
324
356
|
|
325
|
-
response = client.get
|
357
|
+
response = client.get "/{index}/{type}/{id}/_mlt", update_params(params, :body => query, :action => "docs.more_like_this")
|
326
358
|
response.body
|
327
359
|
end
|
328
360
|
|
@@ -346,7 +378,7 @@ Percolate
|
|
346
378
|
def explain( query, params = nil )
|
347
379
|
query, params = extract_params(query) if params.nil?
|
348
380
|
|
349
|
-
response = client.get
|
381
|
+
response = client.get "/{index}/{type}/{id}/_explain", update_params(params, :body => query, :action => "docs.explain")
|
350
382
|
response.body
|
351
383
|
end
|
352
384
|
|
@@ -371,7 +403,7 @@ Percolate
|
|
371
403
|
def validate( query, params = nil )
|
372
404
|
query, params = extract_params(query) if params.nil?
|
373
405
|
|
374
|
-
response = client.get
|
406
|
+
response = client.get "/{index}{/type}/_validate/query", update_params(params, :body => query, :action => "docs.validate")
|
375
407
|
response.body
|
376
408
|
end
|
377
409
|
|
@@ -397,7 +429,7 @@ Percolate
|
|
397
429
|
#
|
398
430
|
# Returns the response body as a Hash
|
399
431
|
def bulk( params = {}, &block )
|
400
|
-
raise
|
432
|
+
raise "a block is required" if block.nil?
|
401
433
|
|
402
434
|
params = {:index => self.name, :type => self.type}.merge params
|
403
435
|
client.bulk params, &block
|
@@ -481,12 +513,37 @@ Percolate
|
|
481
513
|
#
|
482
514
|
# Returns the response body as a Hash
|
483
515
|
def multi_search( params = {}, &block )
|
484
|
-
raise
|
516
|
+
raise "a block is required" if block.nil?
|
485
517
|
|
486
518
|
params = {:index => self.name, :type => self.type}.merge params
|
487
519
|
client.multi_search params, &block
|
488
520
|
end
|
489
521
|
|
522
|
+
# Execute an array of percolate actions in bulk. Results are returned in
|
523
|
+
# an array in the order the actions were sent. The current index name and
|
524
|
+
# type will be passed to the API call as part of the request parameters.
|
525
|
+
#
|
526
|
+
# See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html#_multi_percolate_api
|
527
|
+
#
|
528
|
+
# params - Optional request parameters as a Hash
|
529
|
+
# block - Passed to a MultiPercolate instance which assembles the
|
530
|
+
# percolate actions into a single request.
|
531
|
+
#
|
532
|
+
# Examples
|
533
|
+
#
|
534
|
+
# # block form
|
535
|
+
# multi_percolate do |m|
|
536
|
+
# m.percolate(:author => "pea53")
|
537
|
+
# m.count(:author => "grantr")
|
538
|
+
# ...
|
539
|
+
# end
|
540
|
+
#
|
541
|
+
# Returns the response body as a Hash
|
542
|
+
def multi_percolate(params = {}, &block)
|
543
|
+
params = defaults.merge params
|
544
|
+
client.multi_percolate(params, &block)
|
545
|
+
end
|
546
|
+
|
490
547
|
SPECIAL_KEYS = %w[index type id version version_type op_type routing parent timestamp ttl consistency replication refresh].freeze
|
491
548
|
SPECIAL_KEYS_HASH = SPECIAL_KEYS.inject({}) { |h, k| h[k.to_sym] = "_#{k}"; h }.freeze
|
492
549
|
|
@@ -523,7 +580,7 @@ Percolate
|
|
523
580
|
def update_params( params, overrides = nil )
|
524
581
|
h = defaults.update params
|
525
582
|
h.update overrides unless overrides.nil?
|
526
|
-
h[:routing] = h[:routing].join(
|
583
|
+
h[:routing] = h[:routing].join(",") if Array === h[:routing]
|
527
584
|
h
|
528
585
|
end
|
529
586
|
|
@@ -29,11 +29,11 @@ module Elastomer
|
|
29
29
|
@status = response.status
|
30
30
|
body = response.body
|
31
31
|
|
32
|
-
message = body.is_a?(Hash) && body[
|
32
|
+
message = body.is_a?(Hash) && body["error"] || body.to_s
|
33
33
|
super message
|
34
34
|
|
35
35
|
else
|
36
|
-
super args.join(
|
36
|
+
super args.join(" ")
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -24,7 +24,7 @@ module Elastomer
|
|
24
24
|
#
|
25
25
|
def initialize( client, name )
|
26
26
|
@client = client
|
27
|
-
@name = @client.assert_param_presence(name,
|
27
|
+
@name = @client.assert_param_presence(name, "index name") unless name.nil?
|
28
28
|
end
|
29
29
|
|
30
30
|
attr_reader :client, :name
|
@@ -40,7 +40,7 @@ module Elastomer
|
|
40
40
|
#
|
41
41
|
# Returns true if the index (or type) exists
|
42
42
|
def exists?( params = {} )
|
43
|
-
response = client.head
|
43
|
+
response = client.head "/{index}{/type}", update_params(params, :action => "index.exists")
|
44
44
|
response.success?
|
45
45
|
end
|
46
46
|
alias_method :exist?, :exists?
|
@@ -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
|
57
|
+
response = client.post "/{index}", update_params(params, :body => body, :action => "index.create")
|
58
58
|
response.body
|
59
59
|
end
|
60
60
|
|
@@ -66,7 +66,7 @@ module Elastomer
|
|
66
66
|
#
|
67
67
|
# Returns the response body as a Hash
|
68
68
|
def delete( params = {} )
|
69
|
-
response = client.delete
|
69
|
+
response = client.delete "/{index}", update_params(params, :action => "index.delete")
|
70
70
|
response.body
|
71
71
|
end
|
72
72
|
|
@@ -78,7 +78,7 @@ module Elastomer
|
|
78
78
|
#
|
79
79
|
# Returns the response body as a Hash
|
80
80
|
def open( params = {} )
|
81
|
-
response = client.post
|
81
|
+
response = client.post "/{index}/_open", update_params(params, :action => "index.open")
|
82
82
|
response.body
|
83
83
|
end
|
84
84
|
|
@@ -90,7 +90,7 @@ module Elastomer
|
|
90
90
|
#
|
91
91
|
# Returns the response body as a Hash
|
92
92
|
def close( params = {} )
|
93
|
-
response = client.post
|
93
|
+
response = client.post "/{index}/_close", update_params(params, :action => "index.close")
|
94
94
|
response.body
|
95
95
|
end
|
96
96
|
|
@@ -102,7 +102,7 @@ module Elastomer
|
|
102
102
|
#
|
103
103
|
# Returns the response body as a Hash
|
104
104
|
def get_settings( params = {} )
|
105
|
-
response = client.get
|
105
|
+
response = client.get "{/index}/_settings", update_params(params, :action => "index.get_settings")
|
106
106
|
response.body
|
107
107
|
end
|
108
108
|
alias_method :settings, :get_settings
|
@@ -116,7 +116,7 @@ module Elastomer
|
|
116
116
|
#
|
117
117
|
# Returns the response body as a Hash
|
118
118
|
def update_settings( body, params = {} )
|
119
|
-
response = client.put
|
119
|
+
response = client.put "{/index}/_settings", update_params(params, :body => body, :action => "index.update_settings")
|
120
120
|
response.body
|
121
121
|
end
|
122
122
|
|
@@ -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
|
133
|
+
response = client.get "/{index}{/type}/_mapping", update_params(params, :action => "index.get_mapping")
|
134
134
|
response.body
|
135
135
|
end
|
136
136
|
alias_method :mapping, :get_mapping
|
@@ -145,7 +145,7 @@ 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
|
148
|
+
response = client.put "/{index}/{type}/_mapping", 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
|
@@ -160,7 +160,7 @@ module Elastomer
|
|
160
160
|
#
|
161
161
|
# Returns the response body as a Hash
|
162
162
|
def delete_mapping( type, params = {} )
|
163
|
-
response = client.delete
|
163
|
+
response = client.delete "/{index}/{type}", update_params(params, :type => type, :action => "index.delete_mapping")
|
164
164
|
response.body
|
165
165
|
end
|
166
166
|
|
@@ -172,7 +172,7 @@ module Elastomer
|
|
172
172
|
#
|
173
173
|
# Returns the response body as a Hash
|
174
174
|
def get_aliases( params = {} )
|
175
|
-
response = client.get
|
175
|
+
response = client.get "/{index}/_aliases", update_params(:action => "index.get_aliases")
|
176
176
|
response.body
|
177
177
|
end
|
178
178
|
alias_method :aliases, :get_aliases
|
@@ -193,7 +193,7 @@ module Elastomer
|
|
193
193
|
#
|
194
194
|
# Returns the response body as a Hash
|
195
195
|
def get_alias( name, params = {} )
|
196
|
-
response = client.get
|
196
|
+
response = client.get "/{index}/_alias/{name}", update_params(params, :name => name, :action => "index.get_alias")
|
197
197
|
response.body
|
198
198
|
end
|
199
199
|
|
@@ -212,7 +212,7 @@ module Elastomer
|
|
212
212
|
#
|
213
213
|
# Returns the response body as a Hash
|
214
214
|
def add_alias( name, params = {} )
|
215
|
-
response = client.put
|
215
|
+
response = client.put "/{index}/_alias/{name}", update_params(params, :name => name, :action => "index.add_alias")
|
216
216
|
response.body
|
217
217
|
end
|
218
218
|
|
@@ -230,7 +230,7 @@ module Elastomer
|
|
230
230
|
#
|
231
231
|
# Returns the response body as a Hash
|
232
232
|
def delete_alias( name, params = {} )
|
233
|
-
response = client.delete
|
233
|
+
response = client.delete "/{index}/_alias/{name}", update_params(params, :name => name, :action => "index.delete_alias")
|
234
234
|
response.body
|
235
235
|
end
|
236
236
|
|
@@ -243,7 +243,7 @@ module Elastomer
|
|
243
243
|
#
|
244
244
|
# Returns the response body as a Hash
|
245
245
|
def analyze( text, params = {} )
|
246
|
-
response = client.get
|
246
|
+
response = client.get "{/index}/_analyze", update_params(params, :body => text.to_s, :action => "index.analyze")
|
247
247
|
response.body
|
248
248
|
end
|
249
249
|
|
@@ -257,7 +257,7 @@ module Elastomer
|
|
257
257
|
#
|
258
258
|
# Returns the response body as a Hash
|
259
259
|
def refresh( params = {} )
|
260
|
-
response = client.post
|
260
|
+
response = client.post "{/index}/_refresh", update_params(params, :action => "index.refresh")
|
261
261
|
response.body
|
262
262
|
end
|
263
263
|
|
@@ -270,7 +270,7 @@ module Elastomer
|
|
270
270
|
#
|
271
271
|
# Returns the response body as a Hash
|
272
272
|
def flush( params = {} )
|
273
|
-
response = client.post
|
273
|
+
response = client.post "{/index}/_flush", update_params(params, :action => "index.flush")
|
274
274
|
response.body
|
275
275
|
end
|
276
276
|
|
@@ -284,7 +284,7 @@ module Elastomer
|
|
284
284
|
#
|
285
285
|
# Returns the response body as a Hash
|
286
286
|
def optimize( params = {} )
|
287
|
-
response = client.post
|
287
|
+
response = client.post "{/index}/_optimize", update_params(params, :action => "index.optimize")
|
288
288
|
response.body
|
289
289
|
end
|
290
290
|
|
@@ -300,7 +300,7 @@ module Elastomer
|
|
300
300
|
#
|
301
301
|
# Returns the response body as a Hash
|
302
302
|
def snapshot( params = {} )
|
303
|
-
response = client.post
|
303
|
+
response = client.post "{/index}/_gateway/snapshot", update_params(params, :action => "index.snapshot")
|
304
304
|
response.body
|
305
305
|
end
|
306
306
|
|
@@ -313,7 +313,7 @@ module Elastomer
|
|
313
313
|
#
|
314
314
|
# Returns the response body as a Hash
|
315
315
|
def recovery( params = {} )
|
316
|
-
response = client.get
|
316
|
+
response = client.get "{/index}/_recovery", update_params(params, :action => "index.recovery")
|
317
317
|
response.body
|
318
318
|
end
|
319
319
|
|
@@ -327,7 +327,7 @@ module Elastomer
|
|
327
327
|
#
|
328
328
|
# Returns the response body as a Hash
|
329
329
|
def clear_cache( params = {} )
|
330
|
-
response = client.post
|
330
|
+
response = client.post "{/index}/_cache/clear", update_params(params, :action => "index.clear_cache")
|
331
331
|
response.body
|
332
332
|
end
|
333
333
|
|
@@ -340,7 +340,7 @@ module Elastomer
|
|
340
340
|
#
|
341
341
|
# Returns the response body as a Hash
|
342
342
|
def stats( params = {} )
|
343
|
-
response = client.get
|
343
|
+
response = client.get "{/index}/_stats", update_params(params, :action => "index.stats")
|
344
344
|
response.body
|
345
345
|
end
|
346
346
|
|
@@ -355,7 +355,7 @@ module Elastomer
|
|
355
355
|
#
|
356
356
|
# Returns the response body as a Hash
|
357
357
|
def status( params = {} )
|
358
|
-
response = client.get
|
358
|
+
response = client.get "{/index}/_status", update_params(params, :action => "index.status")
|
359
359
|
response.body
|
360
360
|
end
|
361
361
|
|
@@ -368,7 +368,7 @@ module Elastomer
|
|
368
368
|
#
|
369
369
|
# Returns the response body as a Hash
|
370
370
|
def segments( params = {} )
|
371
|
-
response = client.get
|
371
|
+
response = client.get "{/index}/_segments", update_params(params, :action => "index.segments")
|
372
372
|
response.body
|
373
373
|
end
|
374
374
|
|
@@ -407,7 +407,7 @@ module Elastomer
|
|
407
407
|
#
|
408
408
|
# Returns the response body as a Hash
|
409
409
|
def bulk( params = {}, &block )
|
410
|
-
raise
|
410
|
+
raise "a block is required" if block.nil?
|
411
411
|
|
412
412
|
params = {:index => self.name}.merge params
|
413
413
|
client.bulk params, &block
|
@@ -495,12 +495,37 @@ module Elastomer
|
|
495
495
|
#
|
496
496
|
# Returns the response body as a Hash
|
497
497
|
def multi_search( params = {}, &block )
|
498
|
-
raise
|
498
|
+
raise "a block is required" if block.nil?
|
499
499
|
|
500
500
|
params = {:index => self.name}.merge params
|
501
501
|
client.multi_search params, &block
|
502
502
|
end
|
503
503
|
|
504
|
+
# Execute an array of percolate actions in bulk. Results are returned in
|
505
|
+
# an array in the order the actions were sent. The current index name will
|
506
|
+
# be passed to the API call as part of the request parameters.
|
507
|
+
#
|
508
|
+
# See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html#_multi_percolate_api
|
509
|
+
#
|
510
|
+
# params - Optional request parameters as a Hash
|
511
|
+
# block - Passed to a MultiPercolate instance which assembles the
|
512
|
+
# percolate actions into a single request.
|
513
|
+
#
|
514
|
+
# Examples
|
515
|
+
#
|
516
|
+
# # block form
|
517
|
+
# multi_percolate do |m|
|
518
|
+
# m.percolate({ :author => "pea53" }, { :type => 'default-type' })
|
519
|
+
# m.count({ :author => "pea53" }, { :type => 'type2' })
|
520
|
+
# ...
|
521
|
+
# end
|
522
|
+
#
|
523
|
+
# Returns the response body as a Hash
|
524
|
+
def multi_percolate(params = {}, &block)
|
525
|
+
params = defaults.merge params
|
526
|
+
client.multi_percolate(params, &block)
|
527
|
+
end
|
528
|
+
|
504
529
|
# Provides access to warmer API commands. Index warmers run search
|
505
530
|
# requests to warm up the index before it is available for
|
506
531
|
# searching. Warmers are useful for searches that require heavy
|
@@ -519,8 +544,8 @@ module Elastomer
|
|
519
544
|
# See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html
|
520
545
|
#
|
521
546
|
# Returns a new Warmer instance
|
522
|
-
def warmer(
|
523
|
-
|
547
|
+
def warmer(warmer_name)
|
548
|
+
Warmer.new(client, name, warmer_name)
|
524
549
|
end
|
525
550
|
|
526
551
|
# Delete documents from one or more indices and one or more types based
|
@@ -533,6 +558,17 @@ module Elastomer
|
|
533
558
|
docs.delete_by_query(query, params)
|
534
559
|
end
|
535
560
|
|
561
|
+
# Constructs a Percolator with the given id on this index.
|
562
|
+
#
|
563
|
+
# Examples
|
564
|
+
#
|
565
|
+
# index.percolator "1"
|
566
|
+
#
|
567
|
+
# Returns a Percolator
|
568
|
+
def percolator(id)
|
569
|
+
Percolator.new(client, name, id)
|
570
|
+
end
|
571
|
+
|
536
572
|
# Internal: Add default parameters to the `params` Hash and then apply
|
537
573
|
# `overrides` to the params if any are given.
|
538
574
|
#
|