elasticsearch-api 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. data/Rakefile +50 -5
  2. data/elasticsearch-api.gemspec +1 -0
  3. data/lib/elasticsearch/api/actions/bulk.rb +14 -3
  4. data/lib/elasticsearch/api/actions/count.rb +10 -2
  5. data/lib/elasticsearch/api/actions/delete_by_query.rb +12 -2
  6. data/lib/elasticsearch/api/actions/indices/clear_cache.rb +12 -2
  7. data/lib/elasticsearch/api/actions/indices/close.rb +17 -1
  8. data/lib/elasticsearch/api/actions/indices/exists.rb +19 -1
  9. data/lib/elasticsearch/api/actions/indices/exists_alias.rb +15 -3
  10. data/lib/elasticsearch/api/actions/indices/exists_type.rb +15 -3
  11. data/lib/elasticsearch/api/actions/indices/flush.rb +16 -4
  12. data/lib/elasticsearch/api/actions/indices/get_alias.rb +15 -5
  13. data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +16 -1
  14. data/lib/elasticsearch/api/actions/indices/get_mapping.rb +17 -1
  15. data/lib/elasticsearch/api/actions/indices/get_warmer.rb +17 -0
  16. data/lib/elasticsearch/api/actions/indices/open.rb +17 -1
  17. data/lib/elasticsearch/api/actions/indices/optimize.rb +15 -3
  18. data/lib/elasticsearch/api/actions/indices/put_mapping.rb +20 -1
  19. data/lib/elasticsearch/api/actions/indices/put_settings.rb +20 -1
  20. data/lib/elasticsearch/api/actions/indices/put_warmer.rb +20 -3
  21. data/lib/elasticsearch/api/actions/indices/refresh.rb +15 -3
  22. data/lib/elasticsearch/api/actions/indices/segments.rb +15 -3
  23. data/lib/elasticsearch/api/actions/indices/snapshot_index.rb +15 -3
  24. data/lib/elasticsearch/api/actions/indices/stats.rb +14 -4
  25. data/lib/elasticsearch/api/actions/indices/status.rb +12 -2
  26. data/lib/elasticsearch/api/actions/indices/validate_query.rb +12 -2
  27. data/lib/elasticsearch/api/actions/msearch.rb +2 -2
  28. data/lib/elasticsearch/api/utils.rb +2 -0
  29. data/lib/elasticsearch/api/version.rb +1 -1
  30. data/test/integration/yaml_test_runner.rb +23 -5
  31. data/test/unit/utils_test.rb +10 -0
  32. metadata +2 -2
data/Rakefile CHANGED
@@ -1,5 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ __current__ = Pathname( File.expand_path('..', __FILE__) )
4
+
3
5
  desc "Run unit tests"
4
6
  task :default => 'test:unit'
5
7
  task :test => 'test:unit'
@@ -27,10 +29,53 @@ namespace :test do
27
29
  # test.warning = true
28
30
  end
29
31
 
30
- Rake::TestTask.new(:integration) do |test|
31
- Rake::Task['test:ci_reporter'].invoke if ENV['CI']
32
- test.libs << 'lib' << 'test'
33
- test.test_files = FileList["test/integration/yaml_test_runner.rb", "test/integration/**/*_test.rb"]
32
+ desc "Run integration tests"
33
+ task :integration do
34
+ require 'elasticsearch'
35
+
36
+ current_branch = `git --git-dir=#{__current__.join('../support/elasticsearch/.git')} --work-tree=#{__current__.join('../support/elasticsearch')} branch --no-color`.split("\n").select { |b| b =~ /^\*/ }.first.gsub(/^\*\s*/, '')
37
+
38
+ # Define the task
39
+ t = Rake::TestTask.new(:integration) do |test|
40
+ Rake::Task['test:ci_reporter'].invoke if ENV['CI']
41
+ test.libs << 'lib' << 'test'
42
+ test.test_files = FileList["test/integration/yaml_test_runner.rb", "test/integration/**/*_test.rb"]
43
+ end
44
+
45
+ begin
46
+ client = Elasticsearch::Client.new host: "localhost:#{ENV['TEST_CLUSTER_PORT'] || 9250}"
47
+ es_version_info = client.info['version']
48
+ build_hash = es_version_info['build_hash']
49
+ cluster_running = true
50
+ rescue Faraday::Error::ConnectionFailed => e
51
+ STDERR.puts "[!] Test cluster not running?"
52
+ cluster_running = false
53
+ end
54
+
55
+ checkout_server_build = ENV['TEST_NO_SPEC_CHECKOUT'].nil? || true
56
+ checkout_build_hash = ENV['TEST_BUILD_HASH'] || build_hash
57
+
58
+ begin
59
+ # Checkout the branch corresponding to the build
60
+ sh "git --git-dir=#{__current__.join('../support/elasticsearch/.git')} --work-tree=#{__current__.join('../support/elasticsearch')} checkout #{checkout_build_hash} --force --quiet" if cluster_running && checkout_server_build
61
+
62
+ # Path to the API specs
63
+ ENV['TEST_REST_API_SPEC'] = __current__.join('../support/elasticsearch/rest-api-spec/test/').to_s
64
+
65
+ # Run the task
66
+ args = [t.ruby_opts_string, t.run_code, t.file_list_string, t.option_list].join(' ')
67
+
68
+ ruby args do |ok, status|
69
+ if !ok && status.respond_to?(:signaled?) && status.signaled?
70
+ raise SignalException.new(status.termsig)
71
+ elsif !ok
72
+ fail "Command failed with status (#{status.exitstatus}): " + "[ruby #{args}]"
73
+ end
74
+ end
75
+
76
+ ensure
77
+ sh "git --git-dir=#{__current__.join('../support/elasticsearch/.git')} --work-tree=#{__current__.join('../support/elasticsearch')} checkout #{current_branch}", verbose: false if cluster_running && checkout_server_build
78
+ end
34
79
  end
35
80
 
36
81
  Rake::TestTask.new(:all) do |test|
@@ -39,7 +84,7 @@ namespace :test do
39
84
  test.test_files = FileList["test/unit/**/*_test.rb", "test/integration/**/*_test.rb", "test/integration/yaml_test_runner.rb"]
40
85
  end
41
86
 
42
- namespace :server do
87
+ namespace :cluster do
43
88
  desc "Start Elasticsearch nodes for tests"
44
89
  task :start do
45
90
  $LOAD_PATH << File.expand_path('../../elasticsearch-transport/lib', __FILE__) << File.expand_path('../test', __FILE__)
@@ -48,6 +48,7 @@ Gem::Specification.new do |s|
48
48
  if defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
49
49
  s.add_development_dependency "test-unit", '~> 2'
50
50
  s.add_development_dependency "activesupport", '~> 3'
51
+ s.add_development_dependency "json"
51
52
  end
52
53
 
53
54
  if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
@@ -7,15 +7,26 @@ module Elasticsearch
7
7
  # Pass the operations in the `:body` option as an array of hashes, following Elasticsearch conventions.
8
8
  # For operations which take data, pass them as the `:data` option in the operation hash.
9
9
  #
10
- # @example Perform three operations in a single request
10
+ # @example Perform three operations in a single request, passing actions and data as an array of hashes
11
+ #
12
+ # client.bulk body: [
13
+ # { index: { _index: 'myindex', _type: 'mytype', _id: 1 } },
14
+ # { title: 'foo' },
15
+ #
16
+ # { index: { _index: 'myindex', _type: 'mytype', _id: 2 } },
17
+ # { title: 'foo' },
18
+ #
19
+ # { delete: { _index: 'myindex', _type: 'mytype', _id: 3 } }
20
+ # ]
21
+ # @example Perform three operations in a single request, passing data in the `:data` option
11
22
  #
12
23
  # client.bulk body: [
13
24
  # { index: { _index: 'myindex', _type: 'mytype', _id: 1, data: { title: 'foo' } } },
14
25
  # { update: { _index: 'myindex', _type: 'mytype', _id: 2, data: { doc: { title: 'foo' } } } },
15
- # { delete: { _index: 'myindex', _type: 'mytype', _id: 3 },
26
+ # { delete: { _index: 'myindex', _type: 'mytype', _id: 3 } }
16
27
  # ]
17
28
  #
18
- # @example Perform a script-based bulk update
29
+ # @example Perform a script-based bulk update, passing scripts in the `:data` option
19
30
  #
20
31
  # client.bulk body: [
21
32
  # { update: { _index: 'myindex', _type: 'mytype', _id: 1,
@@ -19,8 +19,13 @@ module Elasticsearch
19
19
  # @option arguments [List] :index A comma-separated list of indices to restrict the results
20
20
  # @option arguments [List] :type A comma-separated list of types to restrict the results
21
21
  # @option arguments [Hash] :body A query to restrict the results (optional)
22
- # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
23
- # (options: none, missing)
22
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
23
+ # no concrete indices. (This includes `_all` string or when no
24
+ # indices have been specified)
25
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
26
+ # `missing` ones (options: none, missing) @until 1.0
27
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
28
+ # unavailable (missing, closed, etc)
24
29
  # @option arguments [Number] :min_score Include only documents with a specific `_score` value in the result
25
30
  # @option arguments [String] :preference Specify the node or shard the operation should be performed on
26
31
  # (default: random)
@@ -32,6 +37,9 @@ module Elasticsearch
32
37
  def count(arguments={})
33
38
  valid_params = [
34
39
  :ignore_indices,
40
+ :ignore_unavailable,
41
+ :allow_no_indices,
42
+ :expand_wildcards,
35
43
  :min_score,
36
44
  :preference,
37
45
  :routing,
@@ -25,8 +25,15 @@ module Elasticsearch
25
25
  # @option arguments [String] :default_operator The default operator for query string query (AND or OR)
26
26
  # (options: AND, OR)
27
27
  # @option arguments [String] :df The field to use as default where no field prefix is given in the query string
28
- # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
29
- # (options: none, missing)
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)
30
37
  # @option arguments [String] :replication Specific replication type (options: sync, async)
31
38
  # @option arguments [String] :q Query in the Lucene query string syntax
32
39
  # @option arguments [String] :routing Specific routing value
@@ -44,6 +51,9 @@ module Elasticsearch
44
51
  :default_operator,
45
52
  :df,
46
53
  :ignore_indices,
54
+ :ignore_unavailable,
55
+ :allow_no_indices,
56
+ :expand_wildcards,
47
57
  :replication,
48
58
  :q,
49
59
  :routing,
@@ -23,6 +23,11 @@ module Elasticsearch
23
23
  # client.indices.clear_cache field_data: true, fields: 'created_at', filter_cache: false, id_cache: false
24
24
  #
25
25
  # @option arguments [List] :index A comma-separated list of index name to limit the operation
26
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
27
+ # no concrete indices. (This includes `_all` string or when no
28
+ # indices have been specified)
29
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
30
+ # are open, closed or both. (options: open, closed)
26
31
  # @option arguments [Boolean] :field_data Clear field data
27
32
  # @option arguments [Boolean] :fielddata Clear field data
28
33
  # @option arguments [List] :fields A comma-separated list of fields to clear when using the
@@ -33,8 +38,10 @@ module Elasticsearch
33
38
  # `filter_cache` parameter (default: all)
34
39
  # @option arguments [Boolean] :id Clear ID caches for parent/child
35
40
  # @option arguments [Boolean] :id_cache Clear ID caches for parent/child
36
- # @option arguments [String] :ignore_indices When performed on multiple indices,
37
- # allows to ignore `missing` ones (options: none, missing)
41
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
42
+ # `missing` ones (options: none, missing) @until 1.0
43
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
44
+ # unavailable (missing, closed, etc)
38
45
  # @option arguments [List] :index A comma-separated list of index name to limit the operation
39
46
  # @option arguments [Boolean] :recycler Clear the recycler cache
40
47
  #
@@ -51,6 +58,9 @@ module Elasticsearch
51
58
  :id,
52
59
  :id_cache,
53
60
  :ignore_indices,
61
+ :ignore_unavailable,
62
+ :allow_no_indices,
63
+ :expand_wildcards,
54
64
  :recycler ]
55
65
 
56
66
  method = 'POST'
@@ -12,13 +12,29 @@ module Elasticsearch
12
12
  # client.indices.close index: 'myindex'
13
13
  #
14
14
  # @option arguments [String] :index The name of the index (*Required*)
15
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
16
+ # no concrete indices. (This includes `_all` string or when no
17
+ # indices have been specified)
18
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
19
+ # are open, closed or both. (options: open, closed)
20
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
21
+ # `missing` ones (options: none, missing) @until 1.0
22
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
23
+ # unavailable (missing, closed, etc)
15
24
  # @option arguments [Time] :timeout Explicit operation timeout
16
25
  #
17
26
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-open-close/
18
27
  #
19
28
  def close(arguments={})
20
29
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
21
- valid_params = [ :timeout ]
30
+
31
+ valid_params = [
32
+ :ignore_indices,
33
+ :ignore_unavailable,
34
+ :allow_no_indices,
35
+ :expand_wildcards,
36
+ :timeout
37
+ ]
22
38
 
23
39
  method = 'POST'
24
40
  path = Utils.__pathify Utils.__listify(arguments[:index]), '_close'
@@ -10,15 +10,33 @@ module Elasticsearch
10
10
  # client.indices.exists index: 'myindex'
11
11
  #
12
12
  # @option arguments [List] :index A comma-separated list of indices to check (*Required*)
13
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
14
+ # no concrete indices. (This includes `_all` string or when no
15
+ # indices have been specified)
16
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
17
+ # are open, closed or both. (options: open, closed)
18
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
19
+ # `missing` ones (options: none, missing) @until 1.0
20
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
21
+ # unavailable (missing, closed, etc)
22
+ #
13
23
  # @return [true,false]
14
24
  #
15
25
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-indices-exists/
16
26
  #
17
27
  def exists(arguments={})
18
28
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
29
+
30
+ valid_params = [
31
+ :ignore_indices,
32
+ :ignore_unavailable,
33
+ :allow_no_indices,
34
+ :expand_wildcards
35
+ ]
36
+
19
37
  method = 'HEAD'
20
38
  path = Utils.__listify(arguments[:index])
21
- params = {}
39
+ params = Utils.__validate_and_extract_params arguments, valid_params
22
40
  body = nil
23
41
 
24
42
  perform_request(method, path, params, body).status == 200 ? true : false
@@ -11,14 +11,26 @@ module Elasticsearch
11
11
  #
12
12
  # @option arguments [List] :index A comma-separated list of index names to filter aliases
13
13
  # @option arguments [List] :name A comma-separated list of alias names to return (*Required*)
14
- # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
15
- # (options: none, missing)
14
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
15
+ # no concrete indices. (This includes `_all` string or when no
16
+ # indices have been specified)
17
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
18
+ # are open, closed or both. (options: open, closed)
19
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
20
+ # `missing` ones (options: none, missing) @until 1.0
21
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
22
+ # unavailable (missing, closed, etc)
16
23
  #
17
24
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/
18
25
  #
19
26
  def exists_alias(arguments={})
20
27
  raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
21
- valid_params = [ :ignore_indices ]
28
+ valid_params = [
29
+ :ignore_indices,
30
+ :ignore_unavailable,
31
+ :allow_no_indices,
32
+ :expand_wildcards
33
+ ]
22
34
 
23
35
  method = 'HEAD'
24
36
  path = Utils.__pathify Utils.__listify(arguments[:index]), '_alias', Utils.__escape(arguments[:name])
@@ -8,15 +8,27 @@ module Elasticsearch
8
8
  # @option arguments [List] :index A comma-separated list of index names; use `_all`
9
9
  # to check the types across all indices (*Required*)
10
10
  # @option arguments [List] :type A comma-separated list of document types to check (*Required*)
11
- # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
12
- # (options: none, missing)
11
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
12
+ # no concrete indices. (This includes `_all` string or when no
13
+ # indices have been specified)
14
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
15
+ # are open, closed or both. (options: open, closed)
16
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
17
+ # `missing` ones (options: none, missing) @until 1.0
18
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
19
+ # unavailable (missing, closed, etc)
13
20
  #
14
21
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-types-exists/
15
22
  #
16
23
  def exists_type(arguments={})
17
24
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
18
25
  raise ArgumentError, "Required argument 'type' missing" unless arguments[:type]
19
- valid_params = [ :ignore_indices ]
26
+ valid_params = [
27
+ :ignore_indices,
28
+ :ignore_unavailable,
29
+ :allow_no_indices,
30
+ :expand_wildcards
31
+ ]
20
32
 
21
33
  method = 'HEAD'
22
34
  path = Utils.__pathify Utils.__listify(arguments[:index]), Utils.__escape(arguments[:type])
@@ -11,10 +11,19 @@ module Elasticsearch
11
11
  # @note The flush operation is handled automatically by Elasticsearch, you don't need to perform it manually.
12
12
  #
13
13
  # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string for all indices
14
- # @option arguments [Boolean] :force TODO: ?
15
- # @option arguments [Boolean] :full TODO: ?
16
- # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
17
- # (options: none, missing)
14
+ # @option arguments [Boolean] :force Whether a flush should be forced even if it is not necessarily needed ie.
15
+ # if no changes will be committed to the index. (Internal)
16
+ # @option arguments [Boolean] :full If set to true a new index writer is created and settings that have been
17
+ # changed related to the index writer will be refreshed. (Internal)
18
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
19
+ # no concrete indices. (This includes `_all` string or when no
20
+ # indices have been specified)
21
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
22
+ # are open, closed or both. (options: open, closed)
23
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
24
+ # `missing` ones (options: none, missing) @until 1.0
25
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
26
+ # unavailable (missing, closed, etc)
18
27
  # @option arguments [Boolean] :refresh Refresh the index after performing the operation
19
28
  #
20
29
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-flush/
@@ -24,6 +33,9 @@ module Elasticsearch
24
33
  :force,
25
34
  :full,
26
35
  :ignore_indices,
36
+ :ignore_unavailable,
37
+ :allow_no_indices,
38
+ :expand_wildcards,
27
39
  :refresh ]
28
40
 
29
41
  method = 'POST'
@@ -15,16 +15,26 @@ module Elasticsearch
15
15
  #
16
16
  # @option arguments [List] :index A comma-separated list of index names to filter aliases
17
17
  # @option arguments [List] :name A comma-separated list of alias names to return (*Required*)
18
- # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
19
- # (options: none, missing)
20
- # @option arguments [List] :index A comma-separated list of index names to filter aliases
21
- # @option arguments [List] :name A comma-separated list of alias names to return
18
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
19
+ # no concrete indices. (This includes `_all` string or when no
20
+ # indices have been specified)
21
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
22
+ # are open, closed or both. (options: open, closed)
23
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
24
+ # `missing` ones (options: none, missing) @until 1.0
25
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
26
+ # unavailable (missing, closed, etc)
22
27
  #
23
28
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/
24
29
  #
25
30
  def get_alias(arguments={})
26
31
  raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
27
- valid_params = [ :ignore_indices ]
32
+ valid_params = [
33
+ :ignore_indices,
34
+ :ignore_unavailable,
35
+ :allow_no_indices,
36
+ :expand_wildcards
37
+ ]
28
38
 
29
39
  method = 'GET'
30
40
  path = Utils.__pathify Utils.__listify(arguments[:index]), '_alias', Utils.__escape(arguments[:name])
@@ -21,12 +21,27 @@ module Elasticsearch
21
21
  # @option arguments [List] :type A comma-separated list of document types
22
22
  # @option arguments [List] :field A comma-separated list of fields (*Required*)
23
23
  # @option arguments [Boolean] :include_defaults Whether default mapping values should be returned as well
24
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
25
+ # no concrete indices. (This includes `_all` string or when no
26
+ # indices have been specified)
27
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
28
+ # are open, closed or both. (options: open, closed)
29
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
30
+ # `missing` ones (options: none, missing) @until 1.0
31
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
32
+ # unavailable (missing, closed, etc)
24
33
  #
25
34
  # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html
26
35
  #
27
36
  def get_field_mapping(arguments={})
28
37
  raise ArgumentError, "Required argument 'field' missing" unless arguments[:field]
29
- valid_params = [ :include_defaults ]
38
+ valid_params = [
39
+ :include_defaults,
40
+ :ignore_indices,
41
+ :ignore_unavailable,
42
+ :allow_no_indices,
43
+ :expand_wildcards
44
+ ]
30
45
 
31
46
  method = 'GET'
32
47
  path = Utils.__pathify(
@@ -19,13 +19,29 @@ module Elasticsearch
19
19
  #
20
20
  # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string for all indices
21
21
  # @option arguments [List] :type A comma-separated list of document types
22
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
23
+ # no concrete indices. (This includes `_all` string or when no
24
+ # indices have been specified)
25
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
26
+ # are open, closed or both. (options: open, closed)
27
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
28
+ # `missing` ones (options: none, missing) @until 1.0
29
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
30
+ # unavailable (missing, closed, etc)
22
31
  #
23
32
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-get-mapping/
24
33
  #
25
34
  def get_mapping(arguments={})
35
+ valid_params = [
36
+ :ignore_indices,
37
+ :ignore_unavailable,
38
+ :allow_no_indices,
39
+ :expand_wildcards
40
+ ]
41
+
26
42
  method = 'GET'
27
43
  path = Utils.__pathify Utils.__listify(arguments[:index]), Utils.__listify(arguments[:type]), '_mapping'
28
- params = {}
44
+ params = Utils.__validate_and_extract_params arguments, valid_params
29
45
  body = nil
30
46
 
31
47
  perform_request(method, path, params, body).body
@@ -26,11 +26,28 @@ module Elasticsearch
26
26
  # @option arguments [String] :name The name of the warmer (supports wildcards); leave empty to get all warmers
27
27
  # @option arguments [List] :type A comma-separated list of document types to restrict the operation;
28
28
  # leave empty to perform the operation on all types
29
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
30
+ # no concrete indices. (This includes `_all` string or when no
31
+ # indices have been specified)
32
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
33
+ # are open, closed or both. (options: open, closed)
34
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
35
+ # `missing` ones (options: none, missing) @until 1.0
36
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
37
+ # unavailable (missing, closed, etc)
29
38
  #
30
39
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-warmers/
31
40
  #
32
41
  def get_warmer(arguments={})
33
42
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
43
+
44
+ valid_params = [
45
+ :ignore_indices,
46
+ :ignore_unavailable,
47
+ :allow_no_indices,
48
+ :expand_wildcards
49
+ ]
50
+
34
51
  method = 'GET'
35
52
  path = Utils.__pathify( Utils.__listify(arguments[:index]), '_warmer', Utils.__escape(arguments[:name]) )
36
53
  params = {}
@@ -10,13 +10,29 @@ module Elasticsearch
10
10
  # client.indices.open index: 'myindex'
11
11
  #
12
12
  # @option arguments [String] :index The name of the index (*Required*)
13
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
14
+ # no concrete indices. (This includes `_all` string or when no
15
+ # indices have been specified)
16
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
17
+ # are open, closed or both. (options: open, closed)
18
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
19
+ # `missing` ones (options: none, missing) @until 1.0
20
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
21
+ # unavailable (missing, closed, etc)
13
22
  # @option arguments [Time] :timeout Explicit operation timeout
14
23
  #
15
24
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-open-close/
16
25
  #
17
26
  def open(arguments={})
18
27
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
19
- valid_params = [ :timeout ]
28
+
29
+ valid_params = [
30
+ :ignore_indices,
31
+ :ignore_unavailable,
32
+ :allow_no_indices,
33
+ :expand_wildcards,
34
+ :timeout
35
+ ]
20
36
 
21
37
  method = 'POST'
22
38
  path = Utils.__pathify Utils.__escape(arguments[:index]), '_open'
@@ -18,12 +18,20 @@ module Elasticsearch
18
18
  #
19
19
  # @option arguments [List] :index A comma-separated list of index names; use `_all`
20
20
  # or empty string to perform the operation on all indices
21
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
22
+ # no concrete indices. (This includes `_all` string or when no
23
+ # indices have been specified)
24
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
25
+ # are open, closed or both. (options: open, closed)
21
26
  # @option arguments [Boolean] :flush Specify whether the index should be flushed after performing the operation
22
27
  # (default: true)
23
- # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
24
- # (options: none, missing)
28
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
29
+ # `missing` ones (options: none, missing) @until 1.0
30
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
31
+ # unavailable (missing, closed, etc)
25
32
  # @option arguments [Number] :max_num_segments The number of segments the index should be merged into
26
33
  # (default: dynamic)
34
+ # @option arguments [Time] :master_timeout Specify timeout for connection to master
27
35
  # @option arguments [Boolean] :only_expunge_deletes Specify whether the operation should only expunge
28
36
  # deleted documents
29
37
  # @option arguments [Boolean] :refresh Specify whether the index should be refreshed after performing the operation
@@ -35,8 +43,12 @@ module Elasticsearch
35
43
  #
36
44
  def optimize(arguments={})
37
45
  valid_params = [
38
- :flush,
39
46
  :ignore_indices,
47
+ :ignore_unavailable,
48
+ :allow_no_indices,
49
+ :expand_wildcards,
50
+ :flush,
51
+ :master_timeout,
40
52
  :max_num_segments,
41
53
  :only_expunge_deletes,
42
54
  :operation_threading,
@@ -23,6 +23,16 @@ module Elasticsearch
23
23
  # @option arguments [String] :type The name of the document type (*Required*)
24
24
  # @option arguments [Boolean] :ignore_conflicts Specify whether to ignore conflicts while updating the mapping
25
25
  # (default: false)
26
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
27
+ # no concrete indices. (This includes `_all` string or when no
28
+ # indices have been specified)
29
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
30
+ # are open, closed or both. (options: open, closed)
31
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
32
+ # `missing` ones (options: none, missing) @until 1.0
33
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
34
+ # unavailable (missing, closed, etc)
35
+ # @option arguments [Time] :master_timeout Specify timeout for connection to master
26
36
  # @option arguments [Time] :timeout Explicit operation timeout
27
37
  #
28
38
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-put-mapping/
@@ -31,7 +41,16 @@ module Elasticsearch
31
41
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
32
42
  raise ArgumentError, "Required argument 'type' missing" unless arguments[:type]
33
43
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
34
- valid_params = [ :ignore_conflicts, :timeout ]
44
+
45
+ valid_params = [
46
+ :ignore_conflicts,
47
+ :ignore_indices,
48
+ :ignore_unavailable,
49
+ :allow_no_indices,
50
+ :expand_wildcards,
51
+ :master_timeout,
52
+ :timeout
53
+ ]
35
54
 
36
55
  method = 'PUT'
37
56
  path = Utils.__pathify Utils.__listify(arguments[:index]), Utils.__escape(arguments[:type]), '_mapping'
@@ -27,14 +27,33 @@ module Elasticsearch
27
27
  # @option arguments [Hash] :body The index settings to be updated (*Required*)
28
28
  # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
29
29
  # to perform the operation on all indices
30
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
31
+ # no concrete indices. (This includes `_all` string or when no
32
+ # indices have been specified)
33
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
34
+ # are open, closed or both. (options: open, closed)
35
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
36
+ # `missing` ones (options: none, missing) @until 1.0
37
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
38
+ # unavailable (missing, closed, etc)
39
+ # @option arguments [Time] :master_timeout Specify timeout for connection to master
30
40
  #
31
41
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings/
32
42
  #
33
43
  def put_settings(arguments={})
34
44
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
45
+
46
+ valid_params = [
47
+ :ignore_indices,
48
+ :ignore_unavailable,
49
+ :allow_no_indices,
50
+ :expand_wildcards,
51
+ :master_timeout
52
+ ]
53
+
35
54
  method = 'PUT'
36
55
  path = Utils.__pathify Utils.__listify(arguments[:index]), '_settings'
37
- params = {}
56
+ params = Utils.__validate_and_extract_params arguments, valid_params
38
57
  body = arguments[:body]
39
58
 
40
59
  perform_request(method, path, params, body).body
@@ -25,19 +25,36 @@ module Elasticsearch
25
25
  # leave empty to perform the operation on all types
26
26
  # @option arguments [Hash] :body The search request definition for the warmer
27
27
  # (query, filters, facets, sorting, etc) (*Required*)
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)
28
37
  #
29
38
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-warmers/
30
39
  #
31
40
  def put_warmer(arguments={})
32
41
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
33
- raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
34
- raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
42
+ raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
43
+ raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
44
+
45
+ valid_params = [
46
+ :ignore_indices,
47
+ :ignore_unavailable,
48
+ :allow_no_indices,
49
+ :expand_wildcards
50
+ ]
51
+
35
52
  method = 'PUT'
36
53
  path = Utils.__pathify( Utils.__listify(arguments[:index]),
37
54
  Utils.__listify(arguments[:type]),
38
55
  '_warmer',
39
56
  Utils.__listify(arguments[:name]) )
40
- params = {}
57
+ params = Utils.__validate_and_extract_params arguments, valid_params
41
58
  body = arguments[:body]
42
59
 
43
60
  perform_request(method, path, params, body).body
@@ -20,13 +20,25 @@ module Elasticsearch
20
20
  #
21
21
  # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
22
22
  # to perform the operation on all indices
23
- # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
24
- # (options: none, missing)
23
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
24
+ # no concrete indices. (This includes `_all` string or when no
25
+ # indices have been specified)
26
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
27
+ # are open, closed or both. (options: open, closed)
28
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
29
+ # `missing` ones (options: none, missing) @until 1.0
30
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
31
+ # unavailable (missing, closed, etc)
25
32
  #
26
33
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-refresh/
27
34
  #
28
35
  def refresh(arguments={})
29
- valid_params = [ :ignore_indices ]
36
+ valid_params = [
37
+ :ignore_indices,
38
+ :ignore_unavailable,
39
+ :allow_no_indices,
40
+ :expand_wildcards
41
+ ]
30
42
 
31
43
  method = 'POST'
32
44
  path = Utils.__pathify Utils.__listify(arguments[:index]), '_refresh'
@@ -10,13 +10,25 @@ module Elasticsearch
10
10
  #
11
11
  # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
12
12
  # to perform the operation on all indices
13
- # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
14
- # (options: none, missing)
13
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
14
+ # no concrete indices. (This includes `_all` string or when no
15
+ # indices have been specified)
16
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
17
+ # are open, closed or both. (options: open, closed)
18
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
19
+ # `missing` ones (options: none, missing) @until 1.0
20
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
21
+ # unavailable (missing, closed, etc)
15
22
  #
16
23
  # @see http://elasticsearch.org/guide/reference/api/admin-indices-segments/
17
24
  #
18
25
  def segments(arguments={})
19
- valid_params = [ :ignore_indices ]
26
+ valid_params = [
27
+ :ignore_indices,
28
+ :ignore_unavailable,
29
+ :allow_no_indices,
30
+ :expand_wildcards
31
+ ]
20
32
 
21
33
  method = 'GET'
22
34
  path = Utils.__pathify Utils.__listify(arguments[:index]), '_segments'
@@ -9,13 +9,25 @@ module Elasticsearch
9
9
  #
10
10
  # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
11
11
  # to perform the operation on all indices
12
- # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
13
- # (options: none, missing)
12
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
13
+ # no concrete indices. (This includes `_all` string or when no
14
+ # indices have been specified)
15
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
16
+ # are open, closed or both. (options: open, closed)
17
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
18
+ # `missing` ones (options: none, missing) @until 1.0
19
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
20
+ # unavailable (missing, closed, etc)
14
21
  #
15
22
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-gateway-snapshot/
16
23
  #
17
24
  def snapshot_index(arguments={})
18
- valid_params = [ :ignore_indices ]
25
+ valid_params = [
26
+ :ignore_indices,
27
+ :ignore_unavailable,
28
+ :allow_no_indices,
29
+ :expand_wildcards
30
+ ]
19
31
 
20
32
  method = 'POST'
21
33
  path = Utils.__pathify Utils.__listify(arguments[:index]), '_gateway/snapshot'
@@ -31,8 +31,11 @@ module Elasticsearch
31
31
  #
32
32
  # @since The `fielddata`, `filter_cache` and `id_cache` metrics are available from version 0.90.
33
33
  #
34
- # @option arguments [List] :search_groups A comma-separated list of search groups to include
35
- # in the `search` statistics
34
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
35
+ # no concrete indices. (This includes `_all` string or when no
36
+ # indices have been specified)
37
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
38
+ # are open, closed or both. (options: open, closed)
36
39
  # @option arguments [Boolean] :all Return all available information
37
40
  # @option arguments [Boolean] :clear Reset the default level of detail
38
41
  # @option arguments [Boolean] :docs Return information about indexed and deleted documents
@@ -43,8 +46,10 @@ module Elasticsearch
43
46
  # @option arguments [Boolean] :get Return information about get operations
44
47
  # @option arguments [Boolean] :groups A comma-separated list of search groups for `search` statistics
45
48
  # @option arguments [Boolean] :id_cache Return information about ID cache
46
- # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
47
- # (options: none, missing)
49
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
50
+ # `missing` ones (options: none, missing) @until 1.0
51
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
52
+ # unavailable (missing, closed, etc)
48
53
  # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
49
54
  # to perform the operation on all indices
50
55
  # @option arguments [Boolean] :indexing Return information about indexing operations
@@ -54,6 +59,8 @@ module Elasticsearch
54
59
  # @option arguments [Boolean] :refresh Return information about refresh operations
55
60
  # @option arguments [Boolean] :search Return information about search operations; use the `groups` parameter to
56
61
  # include information for specific search groups
62
+ # @option arguments [List] :search_groups A comma-separated list of search groups to include
63
+ # in the `search` statistics
57
64
  # @option arguments [Boolean] :store Return information about the size of the index
58
65
  # @option arguments [Boolean] :warmer Return information about warmers
59
66
  #
@@ -72,6 +79,9 @@ module Elasticsearch
72
79
  :groups,
73
80
  :id_cache,
74
81
  :ignore_indices,
82
+ :ignore_unavailable,
83
+ :allow_no_indices,
84
+ :expand_wildcards,
75
85
  :indexing,
76
86
  :merge,
77
87
  :refresh,
@@ -19,8 +19,15 @@ module Elasticsearch
19
19
  #
20
20
  # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
21
21
  # to perform the operation on all indices
22
- # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
23
- # (options: none, missing)
22
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
23
+ # no concrete indices. (This includes `_all` string or when no
24
+ # indices have been specified)
25
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
26
+ # are open, closed or both. (options: open, closed)
27
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
28
+ # `missing` ones (options: none, missing) @until 1.0
29
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
30
+ # unavailable (missing, closed, etc)
24
31
  # @option arguments [Boolean] :recovery Return information about shard recovery (progress, size, etc)
25
32
  # @option arguments [Boolean] :snapshot Return information about snapshots (when shared gateway is used)
26
33
  #
@@ -29,6 +36,9 @@ module Elasticsearch
29
36
  def status(arguments={})
30
37
  valid_params = [
31
38
  :ignore_indices,
39
+ :ignore_unavailable,
40
+ :allow_no_indices,
41
+ :expand_wildcards,
32
42
  :recovery,
33
43
  :snapshot ]
34
44
 
@@ -39,9 +39,16 @@ module Elasticsearch
39
39
  # @option arguments [List] :type A comma-separated list of document types to restrict the operation;
40
40
  # leave empty to perform the operation on all types
41
41
  # @option arguments [Hash] :body The query definition (*without* the top-level `query` element)
42
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
43
+ # no concrete indices. (This includes `_all` string or when no
44
+ # indices have been specified)
45
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
46
+ # are open, closed or both. (options: open, closed)
42
47
  # @option arguments [Boolean] :explain Return detailed information about the error
43
- # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
44
- # (options: none, missing)
48
+ # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore
49
+ # `missing` ones (options: none, missing) @until 1.0
50
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
51
+ # unavailable (missing, closed, etc)
45
52
  # @option arguments [String] :source The URL-encoded query definition (instead of using the request body)
46
53
  # @option arguments [String] :q Query in the Lucene query string syntax
47
54
  #
@@ -52,6 +59,9 @@ module Elasticsearch
52
59
  :q,
53
60
  :explain,
54
61
  :ignore_indices,
62
+ :ignore_unavailable,
63
+ :allow_no_indices,
64
+ :expand_wildcards,
55
65
  :source ]
56
66
 
57
67
  method = 'GET'
@@ -21,8 +21,8 @@ module Elasticsearch
21
21
  # body: [
22
22
  # { query: { match_all: {} } },
23
23
  # { index: 'myindex', type: 'mytype' },
24
- # { query: { query_string: { query: '"Test 1"' } } }
25
- # { search_type: 'count' }
24
+ # { query: { query_string: { query: '"Test 1"' } } },
25
+ # { search_type: 'count' },
26
26
  # { facets: { published: { terms: { field: 'published' } } } }
27
27
  # ]
28
28
  #
@@ -78,6 +78,7 @@ module Elasticsearch
78
78
  payload = payload.
79
79
  inject([]) do |sum, item|
80
80
  operation, meta = item.to_a.first
81
+ meta = meta.clone
81
82
  data = meta.delete(:data) || meta.delete('data')
82
83
 
83
84
  sum << { operation => meta }
@@ -86,6 +87,7 @@ module Elasticsearch
86
87
  end.
87
88
  map { |item| MultiJson.dump(item) }
88
89
  payload << "" unless payload.empty?
90
+ return payload.join("\n")
89
91
 
90
92
  # Array of strings
91
93
  when payload.all? { |d| d.is_a? String }
@@ -1,5 +1,5 @@
1
1
  module Elasticsearch
2
2
  module API
3
- VERSION = "0.4.3"
3
+ VERSION = "0.4.4"
4
4
  end
5
5
  end
@@ -10,7 +10,7 @@ require 'elasticsearch/extensions/test/profiling'
10
10
 
11
11
  # Launch test cluster
12
12
  #
13
- Elasticsearch::Extensions::Test::Cluster.start if ENV['SERVER'] and not Elasticsearch::Extensions::Test::Cluster.running?
13
+ Elasticsearch::Extensions::Test::Cluster.start(nodes: 1) if ENV['SERVER'] and not Elasticsearch::Extensions::Test::Cluster.running?
14
14
 
15
15
  # Register `at_exit` handler for server shutdown.
16
16
  # MUST be called before requiring `test/unit`.
@@ -42,9 +42,12 @@ $client ||= Elasticsearch::Client.new host: "localhost:#{ENV['TEST_CLUSTER_PORT'
42
42
 
43
43
  # Store Elasticsearch version
44
44
  #
45
- $es_version = $client.info['version']['number']
45
+ es_version_info = $client.info['version']
46
+ $es_version = es_version_info['number']
46
47
 
47
- puts '-'*80, "Elasticsearch #{ANSI.ansi($es_version, :bold)}", '-'*80
48
+ puts '-'*80,
49
+ "Elasticsearch #{ANSI.ansi($es_version, :bold)} [#{es_version_info['build_hash'].to_s[0...7]}]".center(80),
50
+ '-'*80
48
51
 
49
52
  require 'test_helper'
50
53
  require 'test/unit'
@@ -177,7 +180,21 @@ module Elasticsearch
177
180
  skip = actions.select { |a| a['skip'] }.first
178
181
  if skip
179
182
  min, max = skip['skip']['version'].split('-').map(&:strip)
180
- if min <= $es_version && max >= $es_version
183
+
184
+ min_normalized = sprintf "%03d-%03d-%03d",
185
+ *min.split('.')
186
+ .map(&:to_i)
187
+ .fill(0, min.split('.').length, 3-min.split('.').length)
188
+
189
+ max_normalized = sprintf "%03d-%03d-%03d",
190
+ *max.split('.')
191
+ .map(&:to_i)
192
+ .map(&:to_i)
193
+ .fill(0, max.split('.').length, 3-max.split('.').length)
194
+
195
+ es_normalized = sprintf "%03d-%03d-%03d", *$es_version.split('.').map(&:to_i)
196
+
197
+ if min_normalized <= es_normalized && max_normalized >= es_normalized
181
198
  return skip['skip']['reason'] ? skip['skip']['reason'] : true
182
199
  end
183
200
  end
@@ -193,7 +210,8 @@ end
193
210
 
194
211
  include Elasticsearch::YamlTestSuite
195
212
 
196
- PATH = Pathname(ENV['SPEC'] || File.expand_path('../../../spec/test', __FILE__))
213
+ PATH = Pathname(ENV['TEST_REST_API_SPEC'] || \
214
+ File.expand_path('../../../../support/elasticsearch/rest-api-spec/test', __FILE__))
197
215
  suites = Dir.glob(PATH.join('*')).map { |d| Pathname(d) }
198
216
  suites = suites.select { |s| s.to_s =~ Regexp.new(ENV['FILTER']) } if ENV['FILTER']
199
217
 
@@ -124,6 +124,16 @@ module Elasticsearch
124
124
  PAYLOAD
125
125
  end
126
126
 
127
+ should "not modify the original payload" do
128
+ original = [ { :index => {:foo => 'bar', :data => { :moo => 'bam' }} } ]
129
+ result = Elasticsearch::API::Utils.__bulkify original
130
+ assert_not_nil original.first[:index][:data], "Deleted :data from #{original}"
131
+ assert_equal <<-PAYLOAD.gsub(/^\s+/, ''), result
132
+ {"index":{"foo":"bar"}}
133
+ {"moo":"bam"}
134
+ PAYLOAD
135
+ end
136
+
127
137
  end
128
138
 
129
139
  context "__validate_and_extract_params" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
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-12-09 00:00:00.000000000 Z
12
+ date: 2014-01-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json