elasticsearch-api 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +13 -0
  5. data/README.md +160 -0
  6. data/Rakefile +62 -0
  7. data/elasticsearch-api.gemspec +51 -0
  8. data/lib/elasticsearch-api +1 -0
  9. data/lib/elasticsearch/api.rb +23 -0
  10. data/lib/elasticsearch/api/actions/bulk.rb +71 -0
  11. data/lib/elasticsearch/api/actions/cluster/get_settings.rb +21 -0
  12. data/lib/elasticsearch/api/actions/cluster/health.rb +50 -0
  13. data/lib/elasticsearch/api/actions/cluster/node_hot_threads.rb +46 -0
  14. data/lib/elasticsearch/api/actions/cluster/node_info.rb +59 -0
  15. data/lib/elasticsearch/api/actions/cluster/node_shutdown.rb +36 -0
  16. data/lib/elasticsearch/api/actions/cluster/node_stats.rb +77 -0
  17. data/lib/elasticsearch/api/actions/cluster/put_settings.rb +28 -0
  18. data/lib/elasticsearch/api/actions/cluster/reroute.rb +44 -0
  19. data/lib/elasticsearch/api/actions/cluster/state.rb +47 -0
  20. data/lib/elasticsearch/api/actions/count.rb +46 -0
  21. data/lib/elasticsearch/api/actions/create.rb +34 -0
  22. data/lib/elasticsearch/api/actions/delete.rb +61 -0
  23. data/lib/elasticsearch/api/actions/delete_by_query.rb +62 -0
  24. data/lib/elasticsearch/api/actions/exists.rb +51 -0
  25. data/lib/elasticsearch/api/actions/explain.rb +71 -0
  26. data/lib/elasticsearch/api/actions/get.rb +59 -0
  27. data/lib/elasticsearch/api/actions/get_source.rb +59 -0
  28. data/lib/elasticsearch/api/actions/index.rb +81 -0
  29. data/lib/elasticsearch/api/actions/indices/analyze.rb +63 -0
  30. data/lib/elasticsearch/api/actions/indices/clear_cache.rb +69 -0
  31. data/lib/elasticsearch/api/actions/indices/close.rb +35 -0
  32. data/lib/elasticsearch/api/actions/indices/create.rb +83 -0
  33. data/lib/elasticsearch/api/actions/indices/delete.rb +48 -0
  34. data/lib/elasticsearch/api/actions/indices/delete_alias.rb +37 -0
  35. data/lib/elasticsearch/api/actions/indices/delete_mapping.rb +26 -0
  36. data/lib/elasticsearch/api/actions/indices/delete_template.rb +33 -0
  37. data/lib/elasticsearch/api/actions/indices/delete_warmer.rb +32 -0
  38. data/lib/elasticsearch/api/actions/indices/exists.rb +35 -0
  39. data/lib/elasticsearch/api/actions/indices/exists_alias.rb +41 -0
  40. data/lib/elasticsearch/api/actions/indices/exists_type.rb +39 -0
  41. data/lib/elasticsearch/api/actions/indices/flush.rb +40 -0
  42. data/lib/elasticsearch/api/actions/indices/get_alias.rb +41 -0
  43. data/lib/elasticsearch/api/actions/indices/get_aliases.rb +32 -0
  44. data/lib/elasticsearch/api/actions/indices/get_mapping.rb +36 -0
  45. data/lib/elasticsearch/api/actions/indices/get_settings.rb +32 -0
  46. data/lib/elasticsearch/api/actions/indices/get_template.rb +30 -0
  47. data/lib/elasticsearch/api/actions/indices/get_warmer.rb +44 -0
  48. data/lib/elasticsearch/api/actions/indices/open.rb +33 -0
  49. data/lib/elasticsearch/api/actions/indices/optimize.rb +57 -0
  50. data/lib/elasticsearch/api/actions/indices/put_alias.rb +43 -0
  51. data/lib/elasticsearch/api/actions/indices/put_mapping.rb +49 -0
  52. data/lib/elasticsearch/api/actions/indices/put_settings.rb +45 -0
  53. data/lib/elasticsearch/api/actions/indices/put_template.rb +40 -0
  54. data/lib/elasticsearch/api/actions/indices/put_warmer.rb +48 -0
  55. data/lib/elasticsearch/api/actions/indices/refresh.rb +43 -0
  56. data/lib/elasticsearch/api/actions/indices/segments.rb +33 -0
  57. data/lib/elasticsearch/api/actions/indices/snapshot_index.rb +32 -0
  58. data/lib/elasticsearch/api/actions/indices/stats.rb +96 -0
  59. data/lib/elasticsearch/api/actions/indices/status.rb +46 -0
  60. data/lib/elasticsearch/api/actions/indices/update_aliases.rb +49 -0
  61. data/lib/elasticsearch/api/actions/indices/validate_query.rb +68 -0
  62. data/lib/elasticsearch/api/actions/info.rb +19 -0
  63. data/lib/elasticsearch/api/actions/mget.rb +64 -0
  64. data/lib/elasticsearch/api/actions/mlt.rb +86 -0
  65. data/lib/elasticsearch/api/actions/msearch.rb +75 -0
  66. data/lib/elasticsearch/api/actions/percolate.rb +57 -0
  67. data/lib/elasticsearch/api/actions/ping.rb +29 -0
  68. data/lib/elasticsearch/api/actions/scroll.rb +44 -0
  69. data/lib/elasticsearch/api/actions/search.rb +145 -0
  70. data/lib/elasticsearch/api/actions/suggest.rb +46 -0
  71. data/lib/elasticsearch/api/actions/update.rb +103 -0
  72. data/lib/elasticsearch/api/namespace/cluster.rb +20 -0
  73. data/lib/elasticsearch/api/namespace/common.rb +27 -0
  74. data/lib/elasticsearch/api/namespace/indices.rb +20 -0
  75. data/lib/elasticsearch/api/utils.rb +97 -0
  76. data/lib/elasticsearch/api/version.rb +5 -0
  77. data/test/integration/yaml_test_runner.rb +330 -0
  78. data/test/test_helper.rb +52 -0
  79. data/test/unit/bulk_test.rb +85 -0
  80. data/test/unit/client_test.rb +31 -0
  81. data/test/unit/cluster/get_settings_test.rb +26 -0
  82. data/test/unit/cluster/health_test.rb +38 -0
  83. data/test/unit/cluster/node_hot_threads_test.rb +35 -0
  84. data/test/unit/cluster/node_info_test.rb +45 -0
  85. data/test/unit/cluster/node_shutdown_test.rb +45 -0
  86. data/test/unit/cluster/node_stats_test.rb +65 -0
  87. data/test/unit/cluster/put_settings_test.rb +26 -0
  88. data/test/unit/cluster/reroute_test.rb +38 -0
  89. data/test/unit/cluster/state_test.rb +37 -0
  90. data/test/unit/count_test.rb +46 -0
  91. data/test/unit/create_document_test.rb +38 -0
  92. data/test/unit/delete_by_query_test.rb +42 -0
  93. data/test/unit/delete_document_test.rb +62 -0
  94. data/test/unit/exists_document_test.rb +76 -0
  95. data/test/unit/explain_document_test.rb +64 -0
  96. data/test/unit/get_document_source_test.rb +62 -0
  97. data/test/unit/get_document_test.rb +62 -0
  98. data/test/unit/hashie_test.rb +78 -0
  99. data/test/unit/index_document_test.rb +77 -0
  100. data/test/unit/indices/analyze_test.rb +67 -0
  101. data/test/unit/indices/clear_cache_test.rb +45 -0
  102. data/test/unit/indices/close_test.rb +42 -0
  103. data/test/unit/indices/create_test.rb +42 -0
  104. data/test/unit/indices/delete_alias_test.rb +38 -0
  105. data/test/unit/indices/delete_mapping_test.rb +47 -0
  106. data/test/unit/indices/delete_template_test.rb +26 -0
  107. data/test/unit/indices/delete_test.rb +45 -0
  108. data/test/unit/indices/delete_warmer_test.rb +59 -0
  109. data/test/unit/indices/exists_alias_test.rb +65 -0
  110. data/test/unit/indices/exists_test.rb +57 -0
  111. data/test/unit/indices/exists_type_test.rb +59 -0
  112. data/test/unit/indices/flush_test.rb +45 -0
  113. data/test/unit/indices/get_alias_test.rb +41 -0
  114. data/test/unit/indices/get_aliases_test.rb +35 -0
  115. data/test/unit/indices/get_mapping_test.rb +53 -0
  116. data/test/unit/indices/get_settings_test.rb +35 -0
  117. data/test/unit/indices/get_template_test.rb +32 -0
  118. data/test/unit/indices/get_warmer_test.rb +41 -0
  119. data/test/unit/indices/open_test.rb +42 -0
  120. data/test/unit/indices/optimize_test.rb +45 -0
  121. data/test/unit/indices/put_alias_test.rb +47 -0
  122. data/test/unit/indices/put_mapping_test.rb +57 -0
  123. data/test/unit/indices/put_settings_test.rb +50 -0
  124. data/test/unit/indices/put_template_test.rb +48 -0
  125. data/test/unit/indices/put_warmer_test.rb +62 -0
  126. data/test/unit/indices/refresh_test.rb +55 -0
  127. data/test/unit/indices/segments_test.rb +55 -0
  128. data/test/unit/indices/snapshot_index_test.rb +55 -0
  129. data/test/unit/indices/stats_test.rb +76 -0
  130. data/test/unit/indices/status_test.rb +55 -0
  131. data/test/unit/indices/update_aliases_test.rb +42 -0
  132. data/test/unit/indices/validate_query_test.rb +75 -0
  133. data/test/unit/info_test.rb +26 -0
  134. data/test/unit/json_builders_test.rb +64 -0
  135. data/test/unit/mget_test.rb +70 -0
  136. data/test/unit/mlt_test.rb +80 -0
  137. data/test/unit/msearch_test.rb +120 -0
  138. data/test/unit/percolate_test.rb +49 -0
  139. data/test/unit/ping_test.rb +48 -0
  140. data/test/unit/scroll_test.rb +26 -0
  141. data/test/unit/search_test.rb +93 -0
  142. data/test/unit/suggest_test.rb +55 -0
  143. data/test/unit/update_document_test.rb +62 -0
  144. data/test/unit/utils_test.rb +118 -0
  145. metadata +498 -0
@@ -0,0 +1,49 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Indices
4
+ module Actions
5
+
6
+ # Create or update mapping.
7
+ #
8
+ # Pass the mapping definition(s) in the `:body` argument.
9
+ #
10
+ # @example Create or update a mapping for a specific document type
11
+ #
12
+ # client.indices.put_mapping index: 'myindex', type: 'mytype', body: {
13
+ # mytype: {
14
+ # properties: {
15
+ # title: { type: 'string', analyzer: 'snowball' }
16
+ # }
17
+ # }
18
+ # }
19
+ #
20
+ # @option arguments [Hash] :body The mapping definition (*Required*)
21
+ # @option arguments [List] :index A comma-separated list of index names; use `_all` to perform the operation
22
+ # on all indices (*Required*)
23
+ # @option arguments [String] :type The name of the document type (*Required*)
24
+ # @option arguments [Boolean] :ignore_conflicts Specify whether to ignore conflicts while updating the mapping
25
+ # (default: false)
26
+ # @option arguments [Time] :timeout Explicit operation timeout
27
+ #
28
+ # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-put-mapping/
29
+ #
30
+ def put_mapping(arguments={})
31
+ raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
32
+ raise ArgumentError, "Required argument 'type' missing" unless arguments[:type]
33
+ raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
34
+ method = 'PUT'
35
+ path = Utils.__pathify( Utils.__listify(arguments[:index]), arguments[:type], '_mapping' )
36
+ params = arguments.select do |k,v|
37
+ [ :ignore_conflicts,
38
+ :timeout ].include?(k)
39
+ end
40
+ # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
41
+ params = Hash[params] unless params.is_a?(Hash)
42
+ body = arguments[:body]
43
+
44
+ perform_request(method, path, params, body).body
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,45 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Indices
4
+ module Actions
5
+
6
+ # Update the settings for one or multiple indices.
7
+ #
8
+ # @example Change the number of replicas for all indices
9
+ #
10
+ # client.indices.put_settings body: { index: { number_of_replicas: 0 } }
11
+ #
12
+ #
13
+ # @example Change the number of replicas for a specific index
14
+ #
15
+ # client.indices.put_settings index: 'myindex', body: { index: { number_of_replicas: 0 } }
16
+ #
17
+ #
18
+ # @example Disable "flush" for all indices
19
+ #
20
+ # client.indices.put_settings body: { 'index.translog.disable_flush' => true }
21
+ #
22
+ # @example Allocate specific index on specific nodes
23
+ #
24
+ # client.indices.put_settings index: 'my-big-index',
25
+ # body: { 'index.routing.allocation.require.tag' => 'bigbox' }
26
+ #
27
+ # @option arguments [Hash] :body The index settings to be updated (*Required*)
28
+ # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
29
+ # to perform the operation on all indices
30
+ #
31
+ # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings/
32
+ #
33
+ def put_settings(arguments={})
34
+ raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
35
+ method = 'PUT'
36
+ path = Utils.__pathify( Utils.__listify(arguments[:index]), '_settings' )
37
+ params = {}
38
+ body = arguments[:body]
39
+
40
+ perform_request(method, path, params, body).body
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,40 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Indices
4
+ module Actions
5
+
6
+ # Create or update an index template.
7
+ #
8
+ #
9
+ # @example Create a template for all indices starting with `logs-`
10
+ #
11
+ # client.indices.put_template :name => 'foo',
12
+ # :body => { template: 'logs-*', settings: { 'index.number_of_shards' => 1 } }
13
+ #
14
+ # @option arguments [String] :name The name of the template (*Required*)
15
+ # @option arguments [Hash] :body The template definition (*Required*)
16
+ # @option arguments [Number] :order The order for this template when merging multiple matching ones
17
+ # (higher numbers are merged later, overriding the lower numbers)
18
+ # @option arguments [Time] :timeout Explicit operation timeout
19
+ #
20
+ # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/
21
+ #
22
+ def put_template(arguments={})
23
+ raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
24
+ raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
25
+ method = 'PUT'
26
+ path = "_template/#{arguments[:name]}"
27
+ params = arguments.select do |k,v|
28
+ [ :order,
29
+ :timeout ].include?(k)
30
+ end
31
+ # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
32
+ params = Hash[params] unless params.is_a?(Hash)
33
+ body = arguments[:body]
34
+
35
+ perform_request(method, path, params, body).body
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,48 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Indices
4
+ module Actions
5
+
6
+ # Create or update an index warmer.
7
+ #
8
+ # An index warmer will run before an index is refreshed, ie. available for search.
9
+ # It allows you to register "heavy" queries with popular filters, facets or sorts,
10
+ # increasing performance when the index is searched for the first time.
11
+ #
12
+ # @example Register a warmer which will populate the caches for `published` filter and sorting on `created_at`
13
+ #
14
+ # client.indices.put_warmer index: 'myindex',
15
+ # name: 'main',
16
+ # body: {
17
+ # query: { filtered: { filter: { term: { published: true } } } },
18
+ # sort: [ "created_at" ]
19
+ # }
20
+ #
21
+ # @option arguments [List] :index A comma-separated list of index names to register the warmer for; use `_all`
22
+ # or empty string to perform the operation on all indices (*Required*)
23
+ # @option arguments [String] :name The name of the warmer (*Required*)
24
+ # @option arguments [List] :type A comma-separated list of document types to register the warmer for;
25
+ # leave empty to perform the operation on all types
26
+ # @option arguments [Hash] :body The search request definition for the warmer
27
+ # (query, filters, facets, sorting, etc) (*Required*)
28
+ #
29
+ # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-warmers/
30
+ #
31
+ def put_warmer(arguments={})
32
+ 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]
35
+ method = 'PUT'
36
+ path = Utils.__pathify( Utils.__listify(arguments[:index]),
37
+ Utils.__listify(arguments[:type]),
38
+ '_warmer',
39
+ Utils.__listify(arguments[:name]) )
40
+ params = {}
41
+ body = arguments[:body]
42
+
43
+ perform_request(method, path, params, body).body
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,43 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Indices
4
+ module Actions
5
+
6
+ # Refresh the index and to make the changes (creates, updates, deletes) searchable.
7
+ #
8
+ # By default, Elasticsearch has a delay of 1 second until changes to an index are
9
+ # available for search; the delay is configurable, see {Indices::Actions#put_settings}.
10
+ #
11
+ # You can trigger this operation explicitely, for example when performing a sequence of commands
12
+ # in integration tests, or when you need to perform a manual "synchronization" of the index
13
+ # with an external system at given moment.
14
+ #
15
+ # @example Refresh an index named _myindex_
16
+ #
17
+ # client.indices.refresh index: 'myindex'
18
+ #
19
+ # @note The refresh operation can adversely affect indexing throughput when used too frequently.
20
+ #
21
+ # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
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)
25
+ #
26
+ # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-refresh/
27
+ #
28
+ def refresh(arguments={})
29
+ method = 'POST'
30
+ path = Utils.__pathify( Utils.__listify(arguments[:index]), '_refresh' )
31
+ params = arguments.select do |k,v|
32
+ [ :ignore_indices ].include?(k)
33
+ end
34
+ # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
35
+ params = Hash[params] unless params.is_a?(Hash)
36
+ body = nil
37
+
38
+ perform_request(method, path, params, body).body
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,33 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Indices
4
+ module Actions
5
+
6
+ # Return information about segments for one or more indices.
7
+ #
8
+ # The response contains information about segment size, number of documents, deleted documents, etc.
9
+ # See also {Indices::Actions#optimize}.
10
+ #
11
+ # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
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)
15
+ #
16
+ # @see http://elasticsearch.org/guide/reference/api/admin-indices-segments/
17
+ #
18
+ def segments(arguments={})
19
+ method = 'GET'
20
+ path = Utils.__pathify( Utils.__listify(arguments[:index]), '_segments' )
21
+ params = arguments.select do |k,v|
22
+ [ :ignore_indices ].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)
26
+ body = nil
27
+
28
+ perform_request(method, path, params, body).body
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,32 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Indices
4
+ module Actions
5
+
6
+ # When using the shared storage gateway, manually trigger the snapshot operation.
7
+ #
8
+ # @deprecated The shared gateway has been deprecated [https://github.com/elasticsearch/elasticsearch/issues/2458]
9
+ #
10
+ # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
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)
14
+ #
15
+ # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-gateway-snapshot/
16
+ #
17
+ def snapshot_index(arguments={})
18
+ method = 'POST'
19
+ path = Utils.__pathify( Utils.__listify(arguments[:index]), '_gateway/snapshot' )
20
+ params = arguments.select do |k,v|
21
+ [ :ignore_indices ].include?(k)
22
+ end
23
+ # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
24
+ params = Hash[params] unless params.is_a?(Hash)
25
+ body = nil
26
+
27
+ perform_request(method, path, params, body).body
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,96 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Indices
4
+ module Actions
5
+
6
+ # Return statistical information about one or more indices.
7
+ #
8
+ # The response contains comprehensive statistical information about metrics related to index:
9
+ # how much time did indexing, search and other operations take, how much disk space it takes,
10
+ # how much memory filter caches or field data require, etc.
11
+ #
12
+ # @example Get default statistics for all indices
13
+ #
14
+ # client.indices.stats
15
+ #
16
+ # @example Get all available statistics for a single index
17
+ #
18
+ # client.indices.stats index: 'foo', all: true
19
+ #
20
+ # @example Get statistics about documents and disk size for multiple indices
21
+ #
22
+ # client.indices.stats index: ['foo', 'bar'], clear: true, docs: true, store: true
23
+ #
24
+ # @example Get statistics about filter cache and field data, for all indices
25
+ #
26
+ # client.indices.stats clear: true, fielddata: true , filter_cache: true, fields: '*'
27
+ #
28
+ # @example Get statistics about searches, with segmentation for different search groups
29
+ #
30
+ # client.indices.stats clear: true, search: true , groups: ['groupA', 'groupB']
31
+ #
32
+ # @since The `fielddata`, `filter_cache` and `id_cache` metrics are available from version 0.90.
33
+ #
34
+ # @option arguments [List] :search_groups A comma-separated list of search groups to include
35
+ # in the `search` statistics
36
+ # @option arguments [Boolean] :all Return all available information
37
+ # @option arguments [Boolean] :clear Reset the default level of detail
38
+ # @option arguments [Boolean] :docs Return information about indexed and deleted documents
39
+ # @option arguments [Boolean] :fielddata Return information about field data
40
+ # @option arguments [Boolean] :fields A comma-separated list of fields for `fielddata` metric (supports wildcards)
41
+ # @option arguments [Boolean] :filter_cache Return information about filter cache
42
+ # @option arguments [Boolean] :flush Return information about flush operations
43
+ # @option arguments [Boolean] :get Return information about get operations
44
+ # @option arguments [Boolean] :groups A comma-separated list of search groups for `search` statistics
45
+ # @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)
48
+ # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
49
+ # to perform the operation on all indices
50
+ # @option arguments [Boolean] :indexing Return information about indexing operations
51
+ # @option arguments [List] :indexing_types A comma-separated list of document types to include
52
+ # in the `indexing` statistics
53
+ # @option arguments [Boolean] :merge Return information about merge operations
54
+ # @option arguments [Boolean] :refresh Return information about refresh operations
55
+ # @option arguments [Boolean] :search Return information about search operations; use the `groups` parameter to
56
+ # include information for specific search groups
57
+ # @option arguments [Boolean] :store Return information about the size of the index
58
+ # @option arguments [Boolean] :warmer Return information about warmers
59
+ #
60
+ # @see http://elasticsearch.org/guide/reference/api/admin-indices-stats/
61
+ #
62
+ def stats(arguments={})
63
+ method = 'GET'
64
+ path = Utils.__pathify( Utils.__listify(arguments[:index]), '_stats' )
65
+ params = arguments.select do |k,v|
66
+ [ :all,
67
+ :clear,
68
+ :docs,
69
+ :fielddata,
70
+ :fields,
71
+ :filter_cache,
72
+ :flush,
73
+ :get,
74
+ :groups,
75
+ :id_cache,
76
+ :ignore_indices,
77
+ :indexing,
78
+ :merge,
79
+ :refresh,
80
+ :search,
81
+ :store,
82
+ :warmer ].include?(k)
83
+ end
84
+ # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
85
+ params = Hash[params] unless params.is_a?(Hash)
86
+ body = nil
87
+
88
+ params[:fields] = Utils.__listify(params[:fields]) if params[:fields]
89
+ params[:groups] = Utils.__listify(params[:groups]) if params[:groups]
90
+
91
+ perform_request(method, path, params, body).body
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,46 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Indices
4
+ module Actions
5
+
6
+ # Return information about one or more indices
7
+ #
8
+ # @example Get information about all indices
9
+ #
10
+ # client.indices.status
11
+ #
12
+ # @example Get information about a specific index
13
+ #
14
+ # client.indices.status index: 'foo'
15
+ #
16
+ # @example Get information about shard recovery for a specific index
17
+ #
18
+ # client.indices.status index: 'foo', recovery: true
19
+ #
20
+ # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string
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)
24
+ # @option arguments [Boolean] :recovery Return information about shard recovery (progress, size, etc)
25
+ # @option arguments [Boolean] :snapshot Return information about snapshots (when shared gateway is used)
26
+ #
27
+ # @see http://elasticsearch.org/guide/reference/api/admin-indices-status/
28
+ #
29
+ def status(arguments={})
30
+ method = 'GET'
31
+ path = Utils.__pathify( Utils.__listify(arguments[:index]), '_status' )
32
+ params = arguments.select do |k,v|
33
+ [ :ignore_indices,
34
+ :recovery,
35
+ :snapshot ].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)
39
+ body = nil
40
+
41
+ perform_request(method, path, params, body).body
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,49 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Indices
4
+ module Actions
5
+
6
+ # Perform multiple operation on index aliases in a single request.
7
+ #
8
+ # Pass the `actions` (add, remove) in the `body` argument.
9
+ #
10
+ # @example Add multiple indices to a single alias
11
+ #
12
+ # client.indices.update_aliases body: {
13
+ # actions: [
14
+ # { add: { index: 'logs-2013-06', alias: 'year-2013' } },
15
+ # { add: { index: 'logs-2013-05', alias: 'year-2013' } }
16
+ # ]
17
+ # }
18
+ #
19
+ # @example Swap an alias (atomic operation)
20
+ #
21
+ # client.indices.update_aliases body: {
22
+ # actions: [
23
+ # { remove: { index: 'logs-2013-06', alias: 'current-month' } },
24
+ # { add: { index: 'logs-2013-07', alias: 'current-month' } }
25
+ # ]
26
+ # }
27
+ #
28
+ # @option arguments [Hash] :body The operations definition and other configuration (*Required*)
29
+ # @option arguments [Time] :timeout Explicit operation timeout
30
+ #
31
+ # @see http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/
32
+ #
33
+ def update_aliases(arguments={})
34
+ raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
35
+ method = 'POST'
36
+ path = "_aliases"
37
+ params = arguments.select do |k,v|
38
+ [ :timeout ].include?(k)
39
+ end
40
+ # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
41
+ params = Hash[params] unless params.is_a?(Hash)
42
+ body = arguments[:body]
43
+
44
+ perform_request(method, path, params, body).body
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end