elastomer-client 3.0.0 → 3.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7db106056a2ea4d14012e82621bc4c4073c85c15
4
- data.tar.gz: ed047e4e19b8f45e7c553998cb0935ea59c1a94e
3
+ metadata.gz: 149f340281bffddc3fac2a8a783890725da2ee30
4
+ data.tar.gz: e25c7f445e3002c6c751fca4119e7abc6311885b
5
5
  SHA512:
6
- metadata.gz: cb92e602580ce508195626093783510df3320ba20416cac7c879fcf80839ce87fbb64dd0af7c8f37b0a2775cf9f0c3d603a692251b8ab9c7c87bcfe867b955a4
7
- data.tar.gz: 423da9494641de0a33a90dc26fdae67564469291a1120202015a5f9daecab22da06bbbf9c1e351a41a825b031563e90066ba9585b483d5c257ad3044c64ba449
6
+ metadata.gz: b738a0e0c1ee712fcdd2143996415b419203fc55c692e38d0ccc8c44caa0795f843e8da880a6ea4b4d346f65bdfbfcd6cd45c57db7d7fa00387c467cb0d3c36f
7
+ data.tar.gz: 3622c6b76c88e224f38587acd480f3bb2875abfe15e2a29ba7c00c1ea12c1166c1ef8522d93425e1a44b078f9a0d8515446a4682a4923787cb165a03c2f75228
@@ -1,3 +1,7 @@
1
+ ## 3.0.1 (2017-12-20)
2
+ - Fixed argument passing to `app_delete_by_query`
3
+ - Explicitly close scroll search contexts when scroll is complete
4
+
1
5
  ## 3.0.0 (2017-12-15)
2
6
  - Fixed swapped args in {Client,Index}#multi\_percolate count calls using block API
3
7
  - Support for Elasticsearch 5.x
@@ -53,30 +53,6 @@ module Elastomer
53
53
 
54
54
  class AppDeleteByQuery
55
55
 
56
- SEARCH_PARAMETERS = %i[
57
- index
58
- type
59
- q
60
- df
61
- analyzer
62
- analyze_wildcard
63
- batched_reduce_size
64
- default_operator
65
- lenient
66
- explain
67
- _source
68
- stored_fields
69
- sort
70
- track_scores
71
- timeout
72
- terminate_after
73
- from
74
- size
75
- search_type
76
- scroll
77
- ].to_set.freeze
78
-
79
-
80
56
  # Create a new DeleteByQuery command for deleting documents matching a
81
57
  # query
82
58
  #
@@ -132,7 +108,8 @@ module Elastomer
132
108
  # Returns a Hash of statistics about the bulk operation
133
109
  def execute
134
110
  ops = Enumerator.new do |yielder|
135
- @client.scan(@query, search_params).each_document do |hit|
111
+ scan = @client.scan(@query, search_params)
112
+ scan.each_document do |hit|
136
113
  yielder.yield([:delete, hit.select { |key, _| ["_index", "_type", "_id", "_routing"].include?(key) }])
137
114
  end
138
115
  end
@@ -144,15 +121,24 @@ module Elastomer
144
121
 
145
122
  # Internal: Remove parameters that are not valid for the _search endpoint
146
123
  def search_params
147
- params = @params.merge(:_source => false)
148
- params.select {|p, _| SEARCH_PARAMETERS.include? p}
124
+ return @search_params if defined?(@search_params)
125
+
126
+ @search_params = @params.merge(_source: false)
127
+ @search_params.delete(:action_count)
128
+ @search_params
149
129
  end
150
130
 
151
131
  # Internal: Remove parameters that are not valid for the _bulk endpoint
152
132
  def bulk_params
153
- @params.clone.tap { |p| p.delete(:q) }
133
+ return @bulk_params if defined?(@bulk_params)
134
+
135
+ @bulk_params = @params.dup
136
+ return @bulk_params if @bulk_params.nil?
137
+
138
+ @bulk_params.delete(:q)
139
+ @bulk_params
154
140
  end
155
141
 
156
- end # AppDeleteByQuery
157
- end # Client
158
- end # Elastomer
142
+ end
143
+ end
144
+ end
@@ -135,11 +135,11 @@ module Elastomer
135
135
  query.merge(:sort => [:_doc])
136
136
  end
137
137
 
138
- DEFAULT_OPTS = {
139
- :index => nil,
140
- :type => nil,
141
- :scroll => "5m",
142
- :size => 50,
138
+ DEFAULT_OPTS = {
139
+ index: nil,
140
+ type: nil,
141
+ scroll: "5m",
142
+ size: 50,
143
143
  }.freeze
144
144
 
145
145
  class Scroller
@@ -151,7 +151,7 @@ module Elastomer
151
151
  # and https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-type.html#scan
152
152
  #
153
153
  # client - Elastomer::Client used for HTTP requests to the server
154
- # query - The query to scan as a Hash or a JSON encoded String
154
+ # query - The query to scroll as a Hash or a JSON encoded String
155
155
  # opts - Options Hash
156
156
  # :index - the name of the index to search
157
157
  # :type - the document type to search
@@ -194,7 +194,7 @@ module Elastomer
194
194
  # hits['hits'].each { |document| ... }
195
195
  # end
196
196
  #
197
- # Returns this Scan instance.
197
+ # Returns this Scroller instance.
198
198
  def each
199
199
  loop do
200
200
  body = do_scroll
@@ -209,6 +209,8 @@ module Elastomer
209
209
  end
210
210
 
211
211
  self
212
+ ensure
213
+ clear!
212
214
  end
213
215
 
214
216
  # Iterate over each document from the scan query. This method is just a
@@ -227,11 +229,24 @@ module Elastomer
227
229
  # document['_source']
228
230
  # end
229
231
  #
230
- # Returns this Scan instance.
232
+ # Returns this Scroller instance.
231
233
  def each_document( &block )
232
234
  each { |hits| hits["hits"].each(&block) }
233
235
  end
234
236
 
237
+ # Terminate the scroll query. This will remove the search context from the
238
+ # cluster and no further documents can be returned by this Scroller
239
+ # instance.
240
+ #
241
+ # Returns nil if the `scroll_id` is not valid; returns the reponse body if
242
+ # the `scroll_id` was cleared.
243
+ def clear!
244
+ return if scroll_id.nil?
245
+ client.clear_scroll(scroll_id)
246
+ rescue ::Elastomer::Client::IllegalArgument
247
+ nil
248
+ end
249
+
235
250
  # Internal: Perform the actual scroll requests. This method wil call out
236
251
  # to the `Client#start_scroll` and `Client#continue_scroll` methods while
237
252
  # keeping track of the `scroll_id` internally.
@@ -1,5 +1,5 @@
1
1
  module Elastomer
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -70,6 +70,17 @@ module Elastomer
70
70
  end
71
71
  end
72
72
 
73
+ # COMPATIBILITY: return a simple boolean value or legacy {"enabled": true/false}.
74
+ #
75
+ # https://www.elastic.co/guide/en/elasticsearch/reference/5.5/breaking_50_mapping_changes.html#_literal_norms_literal
76
+ def strict_boolean(b)
77
+ if es_version_2_x?
78
+ {enabled: b}
79
+ else
80
+ b
81
+ end
82
+ end
83
+
73
84
  # Elasticsearch 2.0 changed some request formats in a non-backward-compatible
74
85
  # way. Some tests need to know what version is running to structure requests
75
86
  # as expected.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastomer-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Pease
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-12-15 00:00:00.000000000 Z
12
+ date: 2017-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -317,7 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
317
317
  version: '0'
318
318
  requirements: []
319
319
  rubyforge_project:
320
- rubygems_version: 2.6.14
320
+ rubygems_version: 2.6.11
321
321
  signing_key:
322
322
  specification_version: 4
323
323
  summary: A library for interacting with Elasticsearch