elasticsearch-api 5.0.0 → 5.0.1

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: 4cc08537b5dbcbca7ec02089ab9ee7a7e287de92
4
- data.tar.gz: e01a7be115aa6647b862986416b2d07d15c43dbe
3
+ metadata.gz: 4c481f1950627254aa828e2f5b0618bb85d2c636
4
+ data.tar.gz: 7f926b2449c1b1cf88bff4595f01ce573c73aa71
5
5
  SHA512:
6
- metadata.gz: 570952fbd8ba30c8ddaf3eff9e9817962208641bd9ed04b5192a165bd54d8d007aea0f1301196ab45e053bc3e20fe4cb1442de3a63a3c7da58a685f94ce31b04
7
- data.tar.gz: 0ac3db83470814d07bcfd742f36d39e0f80c10a16515cf74789ddc8eeac62de579cd502f693c0ddae71a10226d1951f067cf6d45b544ee0bae0568ec32094bc4
6
+ metadata.gz: 53aad6b5e65b3958c7c4b1aa9572c74a36492f8ac316628c3f147bf9c909cd9f55dc0b93b002c49ba4d439e0a94dfc6ba46eb82cce9f7977b120151f188fd1ac
7
+ data.tar.gz: dacb2b8fdb3c759edc520786aea48519bea340b7df091ded51b9237043391b8a83109949a83ae497a6a0539d4e9004edb74514b2725bf436b1571b719f274437
@@ -22,6 +22,7 @@ module Elasticsearch
22
22
  ]
23
23
 
24
24
  COMMON_QUERY_PARAMS = [
25
+ :ignore, # Client specific parameters
25
26
  :format, # Search, Cat, ...
26
27
  :pretty, # Pretty-print the response
27
28
  :human, # Return numeric values in human readable format
@@ -25,6 +25,7 @@ module Elasticsearch
25
25
  #
26
26
  # client.cat.nodes format: 'json'
27
27
  #
28
+ # @option arguments [Boolean] :full_id Return the full node ID instead of the shortened version (default: false)
28
29
  # @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
29
30
  # @option arguments [Boolean] :v Display column headers as part of the output
30
31
  # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
@@ -38,6 +39,7 @@ module Elasticsearch
38
39
  #
39
40
  def nodes(arguments={})
40
41
  valid_params = [
42
+ :full_id,
41
43
  :local,
42
44
  :master_timeout,
43
45
  :h,
@@ -15,55 +15,85 @@ module Elasticsearch
15
15
  #
16
16
  # client.delete_by_query index: 'myindex', body: { query: { term: { published: false } } }
17
17
  #
18
- # @option arguments [List] :index A comma-separated list of indices to restrict the operation;
19
- # use `_all`to perform the operation on all indices (*Required*)
20
- # @option arguments [List] :type A comma-separated list of types to restrict the operation
21
- # @option arguments [Hash] :body A query to restrict the operation
18
+ # @option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices (*Required*)
19
+ # @option arguments [List] :type A comma-separated list of document types to search; leave empty to perform the operation on all types
20
+ # @option arguments [Hash] :body The search definition using the Query DSL (*Required*)
22
21
  # @option arguments [String] :analyzer The analyzer to use for the query string
23
- # @option arguments [String] :consistency Specific write consistency setting for the operation
24
- # (options: one, quorum, all)
25
- # @option arguments [String] :default_operator The default operator for query string query (AND or OR)
26
- # (options: AND, OR)
22
+ # @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false)
23
+ # @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR)
27
24
  # @option arguments [String] :df The field to use as default where no field prefix is given in the query string
28
- # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
29
- # no concrete indices. (This includes `_all` string or when no
30
- # indices have been specified)
31
- # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
32
- # are open, closed or both. (options: open, closed)
33
- # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
34
- # `missing` ones (options: none, missing) @until 1.0
35
- # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
36
- # unavailable (missing, closed, etc)
37
- # @option arguments [String] :replication Specific replication type (options: sync, async)
25
+ # @option arguments [Number] :from Starting offset (default: 0)
26
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
27
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
28
+ # @option arguments [String] :conflicts What to do when the delete-by-query hits version conflicts? (options: abort, proceed)
29
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, none, all)
30
+ # @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
31
+ # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
38
32
  # @option arguments [String] :q Query in the Lucene query string syntax
39
- # @option arguments [String] :routing Specific routing value
40
- # @option arguments [String] :source The URL-encoded query definition (instead of using the request body)
41
- # @option arguments [Time] :timeout Explicit operation timeout
33
+ # @option arguments [List] :routing A comma-separated list of specific routing values
34
+ # @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search
35
+ # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch)
36
+ # @option arguments [Time] :search_timeout Explicit timeout for each search request. Defaults to no timeout.
37
+ # @option arguments [Number] :size Number of hits to return (default: 10)
38
+ # @option arguments [List] :sort A comma-separated list of <field>:<direction> pairs
39
+ # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return
40
+ # @option arguments [List] :_source_exclude A list of fields to exclude from the returned _source field
41
+ # @option arguments [List] :_source_include A list of fields to extract and return from the _source field
42
+ # @option arguments [Number] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
43
+ # @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes
44
+ # @option arguments [Boolean] :version Specify whether to return document version as part of a hit
45
+ # @option arguments [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to index level setting
46
+ # @option arguments [Boolean] :refresh Should the effected indexes be refreshed?
47
+ # @option arguments [Time] :timeout Time each individual bulk request should wait for shards that are unavailable.
48
+ # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
49
+ # @option arguments [Number] :scroll_size Size on the scroll request powering the update_by_query
50
+ # @option arguments [Boolean] :wait_for_completion Should the request should block until the delete-by-query is complete.
51
+ # @option arguments [Number] :requests_per_second The throttle for this request in sub-requests per second. -1 means no throttle.
52
+ # @option arguments [Integer] :slices The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.
42
53
  #
43
- # @see http://www.elasticsearch.org/guide/reference/api/delete-by-query/
54
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html
44
55
  #
45
56
  def delete_by_query(arguments={})
46
57
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
47
58
 
48
59
  valid_params = [
49
60
  :analyzer,
50
- :consistency,
61
+ :analyze_wildcard,
51
62
  :default_operator,
52
63
  :df,
53
- :ignore_indices,
64
+ :from,
54
65
  :ignore_unavailable,
55
66
  :allow_no_indices,
67
+ :conflicts,
56
68
  :expand_wildcards,
57
- :replication,
69
+ :lenient,
70
+ :preference,
58
71
  :q,
59
72
  :routing,
60
- :source,
61
- :timeout ]
73
+ :scroll,
74
+ :search_type,
75
+ :search_timeout,
76
+ :size,
77
+ :sort,
78
+ :_source,
79
+ :_source_exclude,
80
+ :_source_include,
81
+ :terminate_after,
82
+ :stats,
83
+ :version,
84
+ :request_cache,
85
+ :refresh,
86
+ :timeout,
87
+ :wait_for_active_shards,
88
+ :scroll_size,
89
+ :wait_for_completion,
90
+ :requests_per_second,
91
+ :slices ]
62
92
 
63
- method = HTTP_DELETE
93
+ method = HTTP_POST
64
94
  path = Utils.__pathify Utils.__listify(arguments[:index]),
65
95
  Utils.__listify(arguments[:type]),
66
- '/_query'
96
+ '/_delete_by_query'
67
97
 
68
98
  params = Utils.__validate_and_extract_params arguments, valid_params
69
99
  body = arguments[:body]
@@ -7,7 +7,7 @@ module Elasticsearch
7
7
  # The `index` API will either _create_ a new document, or _update_ an existing one, when a document `:id`
8
8
  # is passed. When creating a document, an ID will be auto-generated, when it's not passed as an argument.
9
9
  #
10
- # You can specifically enforce the _create_ operation by settint the `op_type` argument to `create`, or
10
+ # You can specifically enforce the _create_ operation by setting the `op_type` argument to `create`, or
11
11
  # by using the {Actions#create} method.
12
12
  #
13
13
  # Optimistic concurrency control is performed, when the `version` argument is specified. By default,
@@ -71,6 +71,8 @@ module Elasticsearch
71
71
  # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
72
72
  # are open, closed or both. (options: open, closed)
73
73
  #
74
+ # @option arguments [Boolean] :include_segment_file_sizes Whether to report the aggregated disk usage of each one of the Lucene index files. Only applies if segment stats are requested. (default: false)
75
+ #
74
76
  # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-stats.html
75
77
  #
76
78
  def stats(arguments={})
@@ -99,7 +101,8 @@ module Elasticsearch
99
101
  :ignore_indices,
100
102
  :ignore_unavailable,
101
103
  :allow_no_indices,
102
- :expand_wildcards ]
104
+ :expand_wildcards,
105
+ :include_segment_file_sizes ]
103
106
 
104
107
  method = HTTP_GET
105
108
 
@@ -13,9 +13,12 @@ module Elasticsearch
13
13
  #
14
14
  # client.indices.validate_query index: 'myindex', q: '[[[ BOOM! ]]]', explain: true
15
15
  #
16
- # @example Validate a DSL query (with explanation)
16
+ # @example Validate a DSL query (with explanation and rewrite). With rewrite set to true, the
17
+ # explanation is more detailed showing the actual Lucene query that will
18
+ # be executed.
17
19
  #
18
20
  # client.indices.validate_query index: 'myindex',
21
+ # rewrite: true,
19
22
  # explain: true,
20
23
  # body: {
21
24
  # filtered: {
@@ -64,6 +67,7 @@ module Elasticsearch
64
67
  #
65
68
  def validate_query(arguments={})
66
69
  valid_params = [
70
+ :rewrite,
67
71
  :explain,
68
72
  :ignore_unavailable,
69
73
  :allow_no_indices,
@@ -32,6 +32,7 @@ module Elasticsearch
32
32
  # (supports wildcards)
33
33
  # @option arguments [List] :fields A comma-separated list of fields for `fielddata` and `completion` index
34
34
  # metrics (supports wildcards)
35
+ # @option arguments [Boolean] :include_segment_file_sizes Whether to report the aggregated disk usage of each one of the Lucene index files. Only applies if segment stats are requested. (default: false)
35
36
  # @option arguments [Boolean] :groups A comma-separated list of search groups for `search` index metric
36
37
  # @option arguments [Boolean] :human Whether to return time and byte values in human-readable format
37
38
  # @option arguments [String] :level Specify the level for aggregating indices stats
@@ -51,6 +52,7 @@ module Elasticsearch
51
52
  :completion_fields,
52
53
  :fielddata_fields,
53
54
  :fields,
55
+ :include_segment_file_sizes,
54
56
  :groups,
55
57
  :human,
56
58
  :level,
@@ -2,7 +2,7 @@ module Elasticsearch
2
2
  module API
3
3
  module Actions
4
4
 
5
- # Returns true if the cluster returns a sucessfull HTTP response, false otherwise.
5
+ # Returns true if the cluster returns a successful HTTP response, false otherwise.
6
6
  #
7
7
  # @example
8
8
  #
@@ -7,7 +7,8 @@ module Elasticsearch
7
7
  # When using `from` and `size` to return a large result sets, performance drops as you "paginate" in the set,
8
8
  # and you can't guarantee the consistency when the index is being updated at the same time.
9
9
  #
10
- # "Scrolling" the results is frequently used with the `scan` search type.
10
+ # The "Scroll" API uses a "point in time" snapshot of the index state, which was created via a "Search" API
11
+ # request specifying the `scroll` parameter.
11
12
  #
12
13
  # @example A basic example
13
14
  #
@@ -24,8 +25,13 @@ module Elasticsearch
24
25
  # 1_000.times do |i| client.index index: 'test', type: 'test', id: i+1, body: {title: "Test #{i}"} end
25
26
  # client.indices.refresh index: 'test'
26
27
  #
27
- # # Open the "view" of the index with the `scan` search_type
28
- # r = client.search index: 'test', search_type: 'scan', scroll: '5m', size: 10
28
+ # # Open the "view" of the index by passing the `scroll` parameter
29
+ # # Sorting by `_doc` makes the operations faster
30
+ # r = client.search index: 'test', scroll: '1m', body: {sort: ['_doc']}
31
+ #
32
+ # # Display the initial results
33
+ # puts "--- BATCH 0 -------------------------------------------------"
34
+ # puts r['hits']['hits'].map { |d| d['_source']['title'] }.inspect
29
35
  #
30
36
  # # Call the `scroll` API until empty results are returned
31
37
  # while r = client.scroll(scroll_id: r['_scroll_id'], scroll: '5m') and not r['hits']['hits'].empty? do
@@ -235,7 +235,7 @@ module Elasticsearch
235
235
  end
236
236
 
237
237
  unless messages.empty?
238
- if terminal = STDERR.tty?
238
+ if STDERR.tty?
239
239
  STDERR.puts messages.map { |m| "\e[31;1m#{m}\e[0m" }.join("\n")
240
240
  else
241
241
  STDERR.puts messages.join("\n")
@@ -251,11 +251,11 @@ module Elasticsearch
251
251
 
252
252
  message += ". This method is not supported in the version you're using: #{Elasticsearch::API::VERSION}, and will be removed in the next release."
253
253
 
254
- if terminal = STDERR.tty?
255
- STDERR.puts "\e[31;1m#{message}\e[0m"
256
- else
257
- STDERR.puts message
258
- end
254
+ if STDERR.tty?
255
+ STDERR.puts "\e[31;1m#{message}\e[0m"
256
+ else
257
+ STDERR.puts message
258
+ end
259
259
  end
260
260
 
261
261
  extend self
@@ -1,5 +1,5 @@
1
1
  module Elasticsearch
2
2
  module API
3
- VERSION = "5.0.0"
3
+ VERSION = "5.0.1"
4
4
  end
5
5
  end
@@ -231,39 +231,44 @@ module Elasticsearch
231
231
  skip = actions.select { |a| a['skip'] }.first
232
232
  $stderr.puts "SKIP: #{skip.inspect}" if ENV['DEBUG']
233
233
 
234
- # Skip version
235
- if skip && skip['skip']['version']
234
+ def skip_version(skip)
235
+ if skip && skip['skip']['version']
236
236
 
237
- return skip['skip']['reason'] ? skip['skip']['reason'] : true if skip['skip']['version'] == 'all'
237
+ return skip['skip']['reason'] ? skip['skip']['reason'] : true if skip['skip']['version'] == 'all'
238
238
 
239
- min, max = skip['skip']['version'].split('-').map(&:strip)
239
+ min, max = skip['skip']['version'].split('-').map(&:strip)
240
240
 
241
- min_normalized = sprintf "%03d-%03d-%03d",
242
- *min.split('.')
243
- .map(&:to_i)
244
- .fill(0, min.split('.').length, 3-min.split('.').length)
241
+ min_normalized = sprintf "%03d-%03d-%03d",
242
+ *min.split('.')
243
+ .map(&:to_i)
244
+ .fill(0, min.split('.').length, 3-min.split('.').length)
245
245
 
246
- max_normalized = sprintf "%03d-%03d-%03d",
247
- *max.split('.')
248
- .map(&:to_i)
249
- .map(&:to_i)
250
- .fill(0, max.split('.').length, 3-max.split('.').length)
246
+ max_normalized = sprintf "%03d-%03d-%03d",
247
+ *max.split('.')
248
+ .map(&:to_i)
249
+ .map(&:to_i)
250
+ .fill(0, max.split('.').length, 3-max.split('.').length)
251
251
 
252
- es_normalized = sprintf "%03d-%03d-%03d", *$es_version.split('.').map(&:to_i)
252
+ es_normalized = sprintf "%03d-%03d-%03d", *$es_version.split('.').map(&:to_i)
253
253
 
254
- if ( min.empty? || min_normalized <= es_normalized ) && ( max.empty? || max_normalized >= es_normalized )
255
- return skip['skip']['reason'] ? skip['skip']['reason'] : true
254
+ if ( min.empty? || min_normalized <= es_normalized ) && ( max.empty? || max_normalized >= es_normalized )
255
+ return skip['skip']['reason'] ? skip['skip']['reason'] : true
256
+ end
257
+
258
+ return false
256
259
  end
260
+ end
257
261
 
258
- # Skip features
259
- elsif skip && skip['skip']['features']
260
- skip_features = skip['skip']['features'].respond_to?(:split) ? skip['skip']['features'].split(',') : skip['skip']['features']
261
- if ( skip_features & SKIP_FEATURES.split(',') ).size > 0
262
- return skip['skip']['features']
262
+ def skip_features(skip)
263
+ if skip && skip['skip']['features']
264
+ skip_features = skip['skip']['features'].respond_to?(:split) ? skip['skip']['features'].split(',') : skip['skip']['features']
265
+ if ( skip_features & SKIP_FEATURES.split(',') ).size > 0
266
+ return skip['skip']['features']
267
+ end
263
268
  end
264
269
  end
265
270
 
266
- return false
271
+ return skip_version(skip) || skip_features(skip)
267
272
  end
268
273
 
269
274
  extend self
@@ -401,6 +406,10 @@ suites.each do |suite|
401
406
  actions.each do |action|
402
407
  $stderr.puts "ACTION: #{action.inspect}" if ENV['DEBUG']
403
408
 
409
+ # This check verifies that the YAML has correct indentation.
410
+ # See https://github.com/elastic/elasticsearch/issues/21980
411
+ raise "INVALID YAML: #{action.inspect}" if action.keys.size != 1
412
+
404
413
  case
405
414
 
406
415
  # --- Perform action ------------------------------------------
@@ -15,8 +15,8 @@ module Elasticsearch
15
15
 
16
16
  should "perform correct request" do
17
17
  subject.expects(:perform_request).with do |method, url, params, body|
18
- assert_equal 'DELETE', method
19
- assert_equal 'foo/_query', url
18
+ assert_equal 'POST', method
19
+ assert_equal 'foo/_delete_by_query', url
20
20
  assert_equal Hash.new, params
21
21
  assert_equal Hash.new, body[:term]
22
22
  true
@@ -27,7 +27,7 @@ module Elasticsearch
27
27
 
28
28
  should "optionally take the :type argument" do
29
29
  subject.expects(:perform_request).with do |method, url, params, body|
30
- assert_equal 'foo/tweet,post/_query', url
30
+ assert_equal 'foo/tweet,post/_delete_by_query', url
31
31
  true
32
32
  end.returns(FakeResponse.new)
33
33
 
@@ -36,7 +36,7 @@ module Elasticsearch
36
36
 
37
37
  should "pass the query in URL parameters" do
38
38
  subject.expects(:perform_request).with do |method, url, params, body|
39
- assert_equal 'foo/_query', url
39
+ assert_equal 'foo/_delete_by_query', url
40
40
  assert_equal 'foo:bar', params[:q]
41
41
  true
42
42
  end.returns(FakeResponse.new)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-07 00:00:00.000000000 Z
11
+ date: 2017-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json