elasticsearch-api 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. data/README.md +8 -2
  2. data/Rakefile +15 -1
  3. data/elasticsearch-api.gemspec +12 -0
  4. data/lib/{elasticsearch-api → elasticsearch-api.rb} +0 -0
  5. data/lib/elasticsearch/api.rb +9 -0
  6. data/lib/elasticsearch/api/actions/bulk.rb +9 -9
  7. data/lib/elasticsearch/api/actions/cluster/health.rb +12 -12
  8. data/lib/elasticsearch/api/actions/cluster/node_hot_threads.rb +9 -9
  9. data/lib/elasticsearch/api/actions/cluster/node_info.rb +16 -16
  10. data/lib/elasticsearch/api/actions/cluster/node_shutdown.rb +7 -7
  11. data/lib/elasticsearch/api/actions/cluster/node_stats.rb +16 -18
  12. data/lib/elasticsearch/api/actions/cluster/reroute.rb +4 -6
  13. data/lib/elasticsearch/api/actions/cluster/state.rb +12 -12
  14. data/lib/elasticsearch/api/actions/count.rb +9 -9
  15. data/lib/elasticsearch/api/actions/delete.rb +16 -13
  16. data/lib/elasticsearch/api/actions/delete_by_query.rb +15 -14
  17. data/lib/elasticsearch/api/actions/exists.rb +13 -11
  18. data/lib/elasticsearch/api/actions/explain.rb +28 -17
  19. data/lib/elasticsearch/api/actions/get.rb +20 -11
  20. data/lib/elasticsearch/api/actions/get_source.rb +23 -11
  21. data/lib/elasticsearch/api/actions/index.rb +20 -18
  22. data/lib/elasticsearch/api/actions/indices/analyze.rb +12 -13
  23. data/lib/elasticsearch/api/actions/indices/clear_cache.rb +15 -15
  24. data/lib/elasticsearch/api/actions/indices/close.rb +5 -6
  25. data/lib/elasticsearch/api/actions/indices/create.rb +5 -6
  26. data/lib/elasticsearch/api/actions/indices/delete.rb +5 -6
  27. data/lib/elasticsearch/api/actions/indices/delete_alias.rb +5 -6
  28. data/lib/elasticsearch/api/actions/indices/delete_mapping.rb +1 -1
  29. data/lib/elasticsearch/api/actions/indices/delete_template.rb +5 -6
  30. data/lib/elasticsearch/api/actions/indices/delete_warmer.rb +1 -1
  31. data/lib/elasticsearch/api/actions/indices/exists_alias.rb +5 -6
  32. data/lib/elasticsearch/api/actions/indices/exists_type.rb +5 -6
  33. data/lib/elasticsearch/api/actions/indices/flush.rb +9 -9
  34. data/lib/elasticsearch/api/actions/indices/get_alias.rb +5 -6
  35. data/lib/elasticsearch/api/actions/indices/get_aliases.rb +5 -6
  36. data/lib/elasticsearch/api/actions/indices/get_mapping.rb +1 -1
  37. data/lib/elasticsearch/api/actions/indices/get_settings.rb +1 -1
  38. data/lib/elasticsearch/api/actions/indices/get_template.rb +1 -2
  39. data/lib/elasticsearch/api/actions/indices/get_warmer.rb +1 -1
  40. data/lib/elasticsearch/api/actions/indices/open.rb +5 -6
  41. data/lib/elasticsearch/api/actions/indices/optimize.rb +12 -12
  42. data/lib/elasticsearch/api/actions/indices/put_alias.rb +5 -6
  43. data/lib/elasticsearch/api/actions/indices/put_mapping.rb +5 -7
  44. data/lib/elasticsearch/api/actions/indices/put_settings.rb +1 -1
  45. data/lib/elasticsearch/api/actions/indices/put_template.rb +5 -7
  46. data/lib/elasticsearch/api/actions/indices/refresh.rb +5 -6
  47. data/lib/elasticsearch/api/actions/indices/segments.rb +5 -6
  48. data/lib/elasticsearch/api/actions/indices/snapshot_index.rb +5 -6
  49. data/lib/elasticsearch/api/actions/indices/stats.rb +23 -23
  50. data/lib/elasticsearch/api/actions/indices/status.rb +8 -8
  51. data/lib/elasticsearch/api/actions/indices/update_aliases.rb +4 -5
  52. data/lib/elasticsearch/api/actions/indices/validate_query.rb +11 -9
  53. data/lib/elasticsearch/api/actions/mget.rb +21 -11
  54. data/lib/elasticsearch/api/actions/mlt.rb +28 -24
  55. data/lib/elasticsearch/api/actions/msearch.rb +4 -5
  56. data/lib/elasticsearch/api/actions/percolate.rb +7 -6
  57. data/lib/elasticsearch/api/actions/scroll.rb +5 -6
  58. data/lib/elasticsearch/api/actions/search.rb +37 -30
  59. data/lib/elasticsearch/api/actions/suggest.rb +8 -8
  60. data/lib/elasticsearch/api/actions/update.rb +24 -20
  61. data/lib/elasticsearch/api/utils.rb +44 -6
  62. data/lib/elasticsearch/api/version.rb +1 -1
  63. data/test/integration/yaml_test_runner.rb +4 -5
  64. data/test/test_helper.rb +1 -1
  65. data/test/unit/bulk_test.rb +9 -0
  66. data/test/unit/cluster/node_hot_threads_test.rb +9 -0
  67. data/test/unit/create_document_test.rb +9 -0
  68. data/test/unit/delete_document_test.rb +16 -1
  69. data/test/unit/exists_document_test.rb +9 -0
  70. data/test/unit/explain_document_test.rb +9 -0
  71. data/test/unit/get_document_source_test.rb +10 -1
  72. data/test/unit/get_document_test.rb +16 -1
  73. data/test/unit/index_document_test.rb +15 -0
  74. data/test/unit/indices/analyze_test.rb +9 -0
  75. data/test/unit/indices/clear_cache_test.rb +9 -0
  76. data/test/unit/indices/close_test.rb +9 -0
  77. data/test/unit/indices/create_test.rb +9 -0
  78. data/test/unit/indices/delete_alias_test.rb +9 -0
  79. data/test/unit/indices/delete_mapping_test.rb +9 -0
  80. data/test/unit/indices/delete_template_test.rb +9 -0
  81. data/test/unit/indices/delete_test.rb +9 -0
  82. data/test/unit/indices/delete_warmer_test.rb +9 -0
  83. data/test/unit/indices/exists_alias_test.rb +9 -0
  84. data/test/unit/indices/exists_test.rb +9 -0
  85. data/test/unit/indices/exists_type_test.rb +9 -0
  86. data/test/unit/indices/flush_test.rb +9 -0
  87. data/test/unit/indices/get_alias_test.rb +9 -0
  88. data/test/unit/indices/get_aliases_test.rb +9 -0
  89. data/test/unit/indices/get_mapping_test.rb +9 -0
  90. data/test/unit/indices/get_settings_test.rb +9 -0
  91. data/test/unit/indices/get_template_test.rb +10 -6
  92. data/test/unit/indices/get_warmer_test.rb +9 -0
  93. data/test/unit/indices/open_test.rb +9 -0
  94. data/test/unit/indices/optimize_test.rb +9 -0
  95. data/test/unit/indices/put_alias_test.rb +9 -0
  96. data/test/unit/indices/put_mapping_test.rb +9 -0
  97. data/test/unit/indices/put_settings_test.rb +9 -0
  98. data/test/unit/indices/put_template_test.rb +9 -0
  99. data/test/unit/indices/put_warmer_test.rb +9 -0
  100. data/test/unit/indices/refresh_test.rb +9 -0
  101. data/test/unit/indices/segments_test.rb +9 -0
  102. data/test/unit/indices/snapshot_index_test.rb +9 -0
  103. data/test/unit/indices/stats_test.rb +9 -0
  104. data/test/unit/indices/status_test.rb +9 -0
  105. data/test/unit/indices/validate_query_test.rb +9 -0
  106. data/test/unit/mget_test.rb +9 -0
  107. data/test/unit/mlt_test.rb +9 -0
  108. data/test/unit/msearch_test.rb +9 -0
  109. data/test/unit/percolate_test.rb +9 -0
  110. data/test/unit/search_test.rb +16 -1
  111. data/test/unit/suggest_test.rb +9 -0
  112. data/test/unit/update_document_test.rb +16 -1
  113. data/test/unit/utils_test.rb +34 -5
  114. metadata +161 -44
  115. checksums.yaml +0 -7
@@ -37,22 +37,23 @@ module Elasticsearch
37
37
  #
38
38
  def delete_by_query(arguments={})
39
39
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
40
+
41
+ valid_params = [
42
+ :analyzer,
43
+ :consistency,
44
+ :default_operator,
45
+ :df,
46
+ :ignore_indices,
47
+ :replication,
48
+ :q,
49
+ :routing,
50
+ :source,
51
+ :timeout ]
52
+
40
53
  method = 'DELETE'
41
54
  path = Utils.__pathify( Utils.__listify(arguments[:index]), '/_query' )
42
- params = arguments.select do |k,v|
43
- [ :analyzer,
44
- :consistency,
45
- :default_operator,
46
- :df,
47
- :ignore_indices,
48
- :replication,
49
- :q,
50
- :routing,
51
- :source,
52
- :timeout ].include?(k)
53
- end
54
- # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
55
- params = Hash[params] unless params.is_a?(Hash)
55
+
56
+ params = Utils.__validate_and_extract_params arguments, valid_params
56
57
  body = arguments[:body]
57
58
 
58
59
  perform_request(method, path, params, body).body
@@ -21,21 +21,23 @@ module Elasticsearch
21
21
  # @see http://elasticsearch.org/guide/reference/api/get/
22
22
  #
23
23
  def exists(arguments={})
24
- raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
24
+ raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
25
25
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
26
26
  arguments[:type] ||= '_all'
27
27
 
28
+ valid_params = [
29
+ :parent,
30
+ :preference,
31
+ :realtime,
32
+ :refresh,
33
+ :routing ]
34
+
28
35
  method = 'HEAD'
29
- path = Utils.__pathify( arguments[:index], arguments[:type], arguments[:id] )
30
- params = arguments.select do |k,v|
31
- [ :parent,
32
- :preference,
33
- :realtime,
34
- :refresh,
35
- :routing ].include?(k)
36
- end
37
- # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
38
- params = Hash[params] unless params.is_a?(Hash)
36
+ path = Utils.__pathify Utils.__escape(arguments[:index]),
37
+ Utils.__escape(arguments[:type]),
38
+ Utils.__escape(arguments[:id])
39
+
40
+ params = Utils.__validate_and_extract_params arguments, valid_params
39
41
  body = nil
40
42
 
41
43
  perform_request(method, path, params, body).status == 200 ? true : false
@@ -35,6 +35,10 @@ module Elasticsearch
35
35
  # @option arguments [String] :q Query in the Lucene query string syntax
36
36
  # @option arguments [String] :routing Specific routing value
37
37
  # @option arguments [String] :source The URL-encoded query definition (instead of using the request body)
38
+ # @option arguments [String] :_source Specify whether the _source field should be returned,
39
+ # or a list of fields to return
40
+ # @option arguments [String] :_source_exclude A list of fields to exclude from the returned _source field
41
+ # @option arguments [String] :_source_include A list of fields to extract and return from the _source field
38
42
  #
39
43
  # @see http://elasticsearch.org/guide/reference/api/explain/
40
44
  #
@@ -42,24 +46,31 @@ module Elasticsearch
42
46
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
43
47
  raise ArgumentError, "Required argument 'type' missing" unless arguments[:type]
44
48
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
49
+
50
+ valid_params = [
51
+ :analyze_wildcard,
52
+ :analyzer,
53
+ :default_operator,
54
+ :df,
55
+ :fields,
56
+ :lenient,
57
+ :lowercase_expanded_terms,
58
+ :parent,
59
+ :preference,
60
+ :q,
61
+ :routing,
62
+ :source,
63
+ :_source,
64
+ :_source_include,
65
+ :_source_exclude ]
66
+
45
67
  method = 'GET'
46
- path = Utils.__pathify( arguments[:index], arguments[:type], arguments[:id], '_explain' )
47
- params = arguments.select do |k,v|
48
- [ :analyze_wildcard,
49
- :analyzer,
50
- :default_operator,
51
- :df,
52
- :fields,
53
- :lenient,
54
- :lowercase_expanded_terms,
55
- :parent,
56
- :preference,
57
- :q,
58
- :routing,
59
- :source ].include?(k)
60
- end
61
- # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
62
- params = Hash[params] unless params.is_a?(Hash)
68
+ path = Utils.__pathify Utils.__escape(arguments[:index]),
69
+ Utils.__escape(arguments[:type]),
70
+ Utils.__escape(arguments[:id]),
71
+ '_explain'
72
+
73
+ params = Utils.__validate_and_extract_params arguments, valid_params
63
74
  body = arguments[:body]
64
75
 
65
76
  params[:fields] = Utils.__listify(params[:fields]) if params[:fields]
@@ -22,6 +22,10 @@ module Elasticsearch
22
22
  # @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode
23
23
  # @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation
24
24
  # @option arguments [String] :routing Specific routing value
25
+ # @option arguments [String] :_source Specify whether the _source field should be returned,
26
+ # or a list of fields to return
27
+ # @option arguments [String] :_source_exclude A list of fields to exclude from the returned _source field
28
+ # @option arguments [String] :_source_include A list of fields to extract and return from the _source field
25
29
  #
26
30
  # @see http://elasticsearch.org/guide/reference/api/get/
27
31
  #
@@ -30,18 +34,23 @@ module Elasticsearch
30
34
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
31
35
  arguments[:type] ||= '_all'
32
36
 
37
+ valid_params = [
38
+ :fields,
39
+ :parent,
40
+ :preference,
41
+ :realtime,
42
+ :refresh,
43
+ :routing,
44
+ :_source,
45
+ :_source_include,
46
+ :_source_exclude ]
47
+
33
48
  method = 'GET'
34
- path = Utils.__pathify( arguments[:index], arguments[:type], arguments[:id] )
35
- params = arguments.select do |k,v|
36
- [ :fields,
37
- :parent,
38
- :preference,
39
- :realtime,
40
- :refresh,
41
- :routing ].include?(k)
42
- end
43
- # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
44
- params = Hash[params] unless params.is_a?(Hash)
49
+ path = Utils.__pathify Utils.__escape(arguments[:index]),
50
+ Utils.__escape(arguments[:type]),
51
+ Utils.__escape(arguments[:id])
52
+
53
+ params = Utils.__validate_and_extract_params arguments, valid_params
45
54
  body = nil
46
55
 
47
56
  params[:fields] = Utils.__listify(params[:fields]) if params[:fields]
@@ -22,6 +22,12 @@ module Elasticsearch
22
22
  # @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode
23
23
  # @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation
24
24
  # @option arguments [String] :routing Specific routing value
25
+ # @option arguments [String] :_source Specify whether the _source field should be returned,
26
+ # or a list of fields to return
27
+ # @option arguments [String] :_source_exclude A list of fields to exclude from the returned _source field
28
+ # @option arguments [String] :_source_include A list of fields to extract and return from the _source field
29
+ #
30
+ # @see http://elasticsearch.org/guide/reference/api/get/
25
31
  #
26
32
  # @since 0.90.1
27
33
  #
@@ -30,18 +36,24 @@ module Elasticsearch
30
36
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
31
37
  arguments[:type] ||= '_all'
32
38
 
39
+ valid_params = [
40
+ :fields,
41
+ :parent,
42
+ :preference,
43
+ :realtime,
44
+ :refresh,
45
+ :routing,
46
+ :_source,
47
+ :_source_include,
48
+ :_source_exclude ]
49
+
33
50
  method = 'GET'
34
- path = Utils.__pathify( arguments[:index], arguments[:type], arguments[:id], '_source' )
35
- params = arguments.select do |k,v|
36
- [ :fields,
37
- :parent,
38
- :preference,
39
- :realtime,
40
- :refresh,
41
- :routing ].include?(k)
42
- end
43
- # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
44
- params = Hash[params] unless params.is_a?(Hash)
51
+ path = Utils.__pathify Utils.__escape(arguments[:index]),
52
+ Utils.__escape(arguments[:type]),
53
+ Utils.__escape(arguments[:id]),
54
+ '_source'
55
+
56
+ params = Utils.__validate_and_extract_params arguments, valid_params
45
57
  body = nil
46
58
 
47
59
  params[:fields] = Utils.__listify(params[:fields]) if params[:fields]
@@ -52,26 +52,28 @@ module Elasticsearch
52
52
  #
53
53
  def index(arguments={})
54
54
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
55
- raise ArgumentError, "Required argument 'type' missing" unless arguments[:type]
55
+ raise ArgumentError, "Required argument 'type' missing" unless arguments[:type]
56
+
57
+ valid_params = [
58
+ :consistency,
59
+ :op_type,
60
+ :parent,
61
+ :percolate,
62
+ :refresh,
63
+ :replication,
64
+ :routing,
65
+ :timeout,
66
+ :timestamp,
67
+ :ttl,
68
+ :version,
69
+ :version_type ]
70
+
56
71
  method = arguments[:id] ? 'PUT' : 'POST'
57
- path = Utils.__pathify( arguments[:index], arguments[:type], arguments[:id] )
58
- params = arguments.select do |k,v|
59
- [ :consistency,
60
- :op_type,
61
- :parent,
62
- :percolate,
63
- :refresh,
64
- :replication,
65
- :routing,
66
- :timeout,
67
- :timestamp,
68
- :ttl,
69
- :version,
70
- :version_type ].include?(k)
71
- end
72
- # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
73
- params = Hash[params] unless params.is_a?(Hash)
72
+ path = Utils.__pathify Utils.__escape(arguments[:index]),
73
+ Utils.__escape(arguments[:type]),
74
+ Utils.__escape(arguments[:id])
74
75
 
76
+ params = Utils.__validate_and_extract_params arguments, valid_params
75
77
  body = arguments[:body]
76
78
 
77
79
  perform_request(method, path, params, body).body
@@ -36,21 +36,20 @@ module Elasticsearch
36
36
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze/
37
37
  #
38
38
  def analyze(arguments={})
39
+ valid_params = [
40
+ :analyzer,
41
+ :field,
42
+ :filters,
43
+ :index,
44
+ :prefer_local,
45
+ :text,
46
+ :tokenizer,
47
+ :format ]
48
+
39
49
  method = 'GET'
40
- path = Utils.__pathify( arguments[:index], '_analyze' )
41
- params = arguments.select do |k,v|
42
- [ :analyzer,
43
- :field,
44
- :filters,
45
- :index,
46
- :prefer_local,
47
- :text,
48
- :tokenizer,
49
- :format ].include?(k)
50
- end
51
- # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
52
- params = Hash[params] unless params.is_a?(Hash)
50
+ path = Utils.__pathify Utils.__listify(arguments[:index]), '_analyze'
53
51
 
52
+ params = Utils.__validate_and_extract_params arguments, valid_params
54
53
  params[:filters] = Utils.__listify(params[:filters]) if params[:filters]
55
54
 
56
55
  body = arguments[:body]
@@ -41,22 +41,22 @@ module Elasticsearch
41
41
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-clearcache/
42
42
  #
43
43
  def clear_cache(arguments={})
44
+ valid_params = [
45
+ :field_data,
46
+ :fielddata,
47
+ :fields,
48
+ :filter,
49
+ :filter_cache,
50
+ :filter_keys,
51
+ :id,
52
+ :id_cache,
53
+ :ignore_indices,
54
+ :recycler ]
55
+
44
56
  method = 'POST'
45
- path = Utils.__pathify( Utils.__listify(arguments[:index]), '_cache/clear' )
46
- params = arguments.select do |k,v|
47
- [ :field_data,
48
- :fielddata,
49
- :fields,
50
- :filter,
51
- :filter_cache,
52
- :filter_keys,
53
- :id,
54
- :id_cache,
55
- :ignore_indices,
56
- :recycler ].include?(k)
57
- end
58
- # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
59
- params = Hash[params] unless params.is_a?(Hash)
57
+ path = Utils.__pathify Utils.__listify(arguments[:index]), '_cache/clear'
58
+
59
+ params = Utils.__validate_and_extract_params arguments, valid_params
60
60
  body = nil
61
61
 
62
62
  params[:fields] = Utils.__listify(params[:fields]) if params[:fields]
@@ -18,13 +18,12 @@ module Elasticsearch
18
18
  #
19
19
  def close(arguments={})
20
20
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
21
+ valid_params = [ :timeout ]
22
+
21
23
  method = 'POST'
22
- path = "#{arguments[:index]}/_close"
23
- params = arguments.select do |k,v|
24
- [ :timeout ].include?(k)
25
- end
26
- # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
27
- params = Hash[params] unless params.is_a?(Hash)
24
+ path = Utils.__pathify Utils.__listify(arguments[:index]), '_close'
25
+
26
+ params = Utils.__validate_and_extract_params arguments, valid_params
28
27
  body = nil
29
28
 
30
29
  perform_request(method, path, params, body).body
@@ -66,13 +66,12 @@ module Elasticsearch
66
66
  #
67
67
  def create(arguments={})
68
68
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
69
+ valid_params = [ :timeout ]
70
+
69
71
  method = 'PUT'
70
- path = "#{arguments[:index]}"
71
- params = arguments.select do |k,v|
72
- [ :timeout ].include?(k)
73
- end
74
- # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
75
- params = Hash[params] unless params.is_a?(Hash)
72
+ path = Utils.__pathify Utils.__escape(arguments[:index])
73
+
74
+ params = Utils.__validate_and_extract_params arguments, valid_params
76
75
  body = arguments[:body]
77
76
 
78
77
  perform_request(method, path, params, body).body
@@ -31,13 +31,12 @@ module Elasticsearch
31
31
  # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-index/
32
32
  #
33
33
  def delete(arguments={})
34
+ valid_params = [ :timeout ]
35
+
34
36
  method = 'DELETE'
35
- path = Utils.__pathify( Utils.__listify(arguments[:index]) )
36
- params = arguments.select do |k,v|
37
- [ :timeout ].include?(k)
38
- end
39
- # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
40
- params = Hash[params] unless params.is_a?(Hash)
37
+ path = Utils.__pathify Utils.__listify(arguments[:index])
38
+
39
+ params = Utils.__validate_and_extract_params arguments, valid_params
41
40
  body = nil
42
41
 
43
42
  perform_request(method, path, params, body).body
@@ -20,13 +20,12 @@ module Elasticsearch
20
20
  def delete_alias(arguments={})
21
21
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
22
22
  raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
23
+ valid_params = [ :timeout ]
24
+
23
25
  method = 'DELETE'
24
- path = "#{arguments[:index]}/_alias/#{arguments[:name]}"
25
- params = arguments.select do |k,v|
26
- [ :timeout ].include?(k)
27
- end
28
- # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
29
- params = Hash[params] unless params.is_a?(Hash)
26
+ path = Utils.__pathify Utils.__escape(arguments[:index]), '_alias', Utils.__escape(arguments[:name])
27
+
28
+ params = Utils.__validate_and_extract_params arguments, valid_params
30
29
  body = nil
31
30
 
32
31
  perform_request(method, path, params, body).body
@@ -14,7 +14,7 @@ module Elasticsearch
14
14
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
15
15
  raise ArgumentError, "Required argument 'type' missing" unless arguments[:type]
16
16
  method = 'DELETE'
17
- path = Utils.__pathify( Utils.__listify(arguments[:index]), arguments[:type] )
17
+ path = Utils.__pathify Utils.__listify(arguments[:index]), Utils.__escape(arguments[:type])
18
18
  params = {}
19
19
  body = nil
20
20
 
@@ -16,13 +16,12 @@ module Elasticsearch
16
16
  #
17
17
  def delete_template(arguments={})
18
18
  raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
19
+ valid_params = [ :timeout ]
20
+
19
21
  method = 'DELETE'
20
- path = "_template/#{arguments[:name]}"
21
- params = arguments.select do |k,v|
22
- [ :timeout ].include?(k)
23
- end
24
- # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
25
- params = Hash[params] unless params.is_a?(Hash)
22
+ path = Utils.__pathify '_template', Utils.__escape(arguments[:name])
23
+
24
+ params = Utils.__validate_and_extract_params arguments, valid_params
26
25
  body = nil
27
26
 
28
27
  perform_request(method, path, params, body).body