elasticsearch-api 0.4.11 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/Gemfile +2 -6
  2. data/README.md +3 -4
  3. data/lib/elasticsearch/api.rb +16 -9
  4. data/lib/elasticsearch/api/actions/cat/aliases.rb +67 -0
  5. data/lib/elasticsearch/api/actions/cat/allocation.rb +69 -0
  6. data/lib/elasticsearch/api/actions/cat/count.rb +59 -0
  7. data/lib/elasticsearch/api/actions/cat/health.rb +43 -0
  8. data/lib/elasticsearch/api/actions/cat/help.rb +25 -0
  9. data/lib/elasticsearch/api/actions/cat/indices.rb +77 -0
  10. data/lib/elasticsearch/api/actions/cat/master.rb +40 -0
  11. data/lib/elasticsearch/api/actions/cat/nodes.rb +38 -0
  12. data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +40 -0
  13. data/lib/elasticsearch/api/actions/cat/recovery.rb +73 -0
  14. data/lib/elasticsearch/api/actions/cat/shards.rb +72 -0
  15. data/lib/elasticsearch/api/actions/cluster/put_settings.rb +3 -1
  16. data/lib/elasticsearch/api/actions/cluster/state.rb +23 -14
  17. data/lib/elasticsearch/api/actions/count_percolate.rb +78 -0
  18. data/lib/elasticsearch/api/actions/indices/exists.rb +4 -1
  19. data/lib/elasticsearch/api/actions/indices/exists_alias.rb +5 -3
  20. data/lib/elasticsearch/api/actions/indices/exists_template.rb +34 -0
  21. data/lib/elasticsearch/api/actions/indices/exists_type.rb +4 -1
  22. data/lib/elasticsearch/api/actions/indices/get_alias.rb +5 -3
  23. data/lib/elasticsearch/api/actions/indices/get_aliases.rb +6 -3
  24. data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +2 -1
  25. data/lib/elasticsearch/api/actions/indices/get_mapping.rb +8 -3
  26. data/lib/elasticsearch/api/actions/indices/get_settings.rb +7 -2
  27. data/lib/elasticsearch/api/actions/indices/get_warmer.rb +0 -2
  28. data/lib/elasticsearch/api/actions/indices/put_alias.rb +0 -1
  29. data/lib/elasticsearch/api/actions/indices/put_mapping.rb +11 -4
  30. data/lib/elasticsearch/api/actions/indices/put_warmer.rb +0 -1
  31. data/lib/elasticsearch/api/actions/mpercolate.rb +58 -0
  32. data/lib/elasticsearch/api/actions/mtermvectors.rb +67 -0
  33. data/lib/elasticsearch/api/actions/{cluster/node_hot_threads.rb → nodes/hot_threads.rb} +3 -3
  34. data/lib/elasticsearch/api/actions/{cluster/node_info.rb → nodes/info.rb} +3 -3
  35. data/lib/elasticsearch/api/actions/{cluster/node_shutdown.rb → nodes/shutdown.rb} +3 -3
  36. data/lib/elasticsearch/api/actions/nodes/stats.rb +79 -0
  37. data/lib/elasticsearch/api/actions/percolate.rb +67 -21
  38. data/lib/elasticsearch/api/actions/snapshot/create.rb +48 -0
  39. data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +44 -0
  40. data/lib/elasticsearch/api/actions/snapshot/delete.rb +41 -0
  41. data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +38 -0
  42. data/lib/elasticsearch/api/actions/snapshot/get.rb +47 -0
  43. data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +42 -0
  44. data/lib/elasticsearch/api/actions/snapshot/restore.rb +53 -0
  45. data/lib/elasticsearch/api/actions/termvector.rb +77 -0
  46. data/lib/elasticsearch/api/namespace/cat.rb +20 -0
  47. data/lib/elasticsearch/api/namespace/nodes.rb +20 -0
  48. data/lib/elasticsearch/api/namespace/snapshot.rb +20 -0
  49. data/lib/elasticsearch/api/utils.rb +2 -4
  50. data/lib/elasticsearch/api/version.rb +1 -1
  51. data/test/integration/yaml_test_runner.rb +37 -8
  52. data/test/unit/cat/aliases_test.rb +26 -0
  53. data/test/unit/cat/allocation_test.rb +26 -0
  54. data/test/unit/cat/count_test.rb +26 -0
  55. data/test/unit/cat/health_test.rb +26 -0
  56. data/test/unit/cat/help_test.rb +26 -0
  57. data/test/unit/cat/indices_test.rb +26 -0
  58. data/test/unit/cat/master_test.rb +26 -0
  59. data/test/unit/cat/nodes_test.rb +26 -0
  60. data/test/unit/cat/pending_tasks_test.rb +26 -0
  61. data/test/unit/cat/recovery_test.rb +26 -0
  62. data/test/unit/cat/shards_test.rb +26 -0
  63. data/test/unit/cluster/state_test.rb +12 -3
  64. data/test/unit/count_percolate_test.rb +26 -0
  65. data/test/unit/indices/exists_alias_test.rb +0 -6
  66. data/test/unit/indices/exists_template_test.rb +59 -0
  67. data/test/unit/indices/get_alias_test.rb +0 -6
  68. data/test/unit/indices/get_aliases_test.rb +10 -0
  69. data/test/unit/indices/get_field_mapping_test.rb +1 -1
  70. data/test/unit/indices/get_mapping_test.rb +3 -3
  71. data/test/unit/indices/get_settings_test.rb +10 -0
  72. data/test/unit/indices/get_warmer_test.rb +0 -6
  73. data/test/unit/indices/put_alias_test.rb +0 -6
  74. data/test/unit/indices/put_mapping_test.rb +5 -11
  75. data/test/unit/indices/put_settings_test.rb +9 -0
  76. data/test/unit/indices/put_warmer_test.rb +0 -6
  77. data/test/unit/mpercolate_test.rb +51 -0
  78. data/test/unit/mtermvectors_test.rb +38 -0
  79. data/test/unit/{cluster/node_hot_threads_test.rb → nodes/hot_threads_test.rb} +5 -5
  80. data/test/unit/{cluster/node_info_test.rb → nodes/info_test.rb} +6 -6
  81. data/test/unit/{cluster/node_shutdown_test.rb → nodes/shutdown_test.rb} +6 -6
  82. data/test/unit/{cluster/node_stats_test.rb → nodes/stats_test.rb} +10 -10
  83. data/test/unit/percolate_test.rb +2 -13
  84. data/test/unit/snapshot/create_repository_test.rb +38 -0
  85. data/test/unit/snapshot/create_test.rb +38 -0
  86. data/test/unit/snapshot/delete_repository_test.rb +35 -0
  87. data/test/unit/snapshot/delete_test.rb +38 -0
  88. data/test/unit/snapshot/get_repository_test.rb +26 -0
  89. data/test/unit/snapshot/get_test.rb +38 -0
  90. data/test/unit/snapshot/restore_test.rb +38 -0
  91. data/test/unit/termvector_test.rb +44 -0
  92. data/test/unit/utils_test.rb +11 -0
  93. metadata +89 -17
  94. data/lib/elasticsearch/api/actions/cluster/node_stats.rb +0 -75
@@ -2,50 +2,96 @@ module Elasticsearch
2
2
  module API
3
3
  module Actions
4
4
 
5
- # Return names of queries matching the passed document.
5
+ # Return names of queries matching a document.
6
6
  #
7
7
  # Percolator allows you to register queries and then evaluate a document against them:
8
8
  # the IDs of matching queries are returned in the response.
9
9
  #
10
- # @example Register queries named "alert-1" and "alert-2" for the "myindex" index
10
+ # @example Register queries named "alert-1" and "alert-2" for the "my-index" index
11
11
  #
12
- # client.index index: '_percolator',
13
- # type: 'myindex',
12
+ # client.index index: 'my-index',
13
+ # type: '.percolator',
14
14
  # id: 'alert-1',
15
15
  # body: { query: { query_string: { query: 'foo' } } }
16
16
  #
17
- # client.index index: '_percolator',
18
- # type: 'myindex',
17
+ # client.index index: 'my-index',
18
+ # type: '.percolator',
19
19
  # id: 'alert-2',
20
20
  # body: { query: { query_string: { query: 'bar' } } }
21
21
  #
22
- # @example Evaluate a document against the queries
22
+ # @example Evaluate a custom document (passed as `:doc`) against the queries
23
23
  #
24
- # client.percolate index: 'myindex', body: { doc: { title: "Foo" } }
25
- # # => {"ok":true,"matches":["alert-1"]}
24
+ # client.percolate index: 'my-index', body: { doc: { title: "Foo" } }
25
+ # # => {..., matches: [ {_index: 'my-index', _id: 'alert-1'} ]}
26
26
  #
27
- # client.percolate index: 'myindex', body: { doc: { title: "Foo Bar" } }
28
- # # => {"ok":true,"matches":["alert-1","alert-2"]}
27
+ # client.percolate index: 'my-index', body: { doc: { title: "Foo Bar" } }
28
+ # # => {..., matches: [ {_index: 'my-index', _id: 'alert-2'}, {_index: 'my-index', _id: 'alert-1'} ] }
29
29
  #
30
- # @option arguments [String] :index The name of the index with a registered percolator query (*Required*)
31
- # @option arguments [String] :type The document type
32
- # @option arguments [Hash] :body The document (`doc`) to percolate against registered queries;
33
- # optionally also a `query` to limit the percolation to specific registered queries
34
- # @option arguments [Boolean] :prefer_local With `true`, specify that a local shard should be used if available,
35
- # with `false`, use a random shard (default: true)
30
+ # @example Evaluate an existing document against the queries
36
31
  #
37
- # @see http://elasticsearch.org/guide/reference/api/percolate/
32
+ # client.index index: 'my-index', type: 'my-type', id: 123, body: { title: "Foo Bar" }
33
+ #
34
+ # client.percolate index: 'my-index', type: 'my-type', id: '123'
35
+ # # => { ..., matches: [ {_index: 'my-index', _id: 'alert-2'}, { _index: 'my-index', _id: 'alert-1'} ] }
36
+ #
37
+ # @example Register a query with custom `priority` property
38
+ #
39
+ # client.index index: 'my-index',
40
+ # type: '.percolator',
41
+ # id: 'alert-high-1',
42
+ # body: { query: { query_string: { query: 'foo' } },
43
+ # priority: 'high' }
44
+ #
45
+ # @example Evaluate a document against "high priority" percolator queries
46
+ #
47
+ # client.percolate index: 'my-index', body: {
48
+ # doc: { title: "Foo" },
49
+ # filter: { term: { priority: 'high' } }
50
+ # }
51
+ # # => {..., matches: [ {_index: 'my-index', _id: 'alert-high-1'} ]}
52
+ #
53
+ #
54
+ # @option arguments [String] :index The index of the document being percolated. (*Required*)
55
+ # @option arguments [String] :type The type of the document being percolated. (*Required*)
56
+ # @option arguments [String] :id Fetch the document specified by index/type/id and
57
+ # use it instead of the passed `doc`
58
+ # @option arguments [Hash] :body The percolator request definition using the percolate DSL
59
+ # @option arguments [List] :routing A comma-separated list of specific routing values
60
+ # @option arguments [String] :preference Specify the node or shard the operation should be performed on
61
+ # (default: random)
62
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
63
+ # unavailable (missing or closed)
64
+ # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into
65
+ # no concrete indices. (This includes `_all` string or when no
66
+ # indices have been specified)
67
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are
68
+ # open, closed or both. (options: open, closed)
69
+ # @option arguments [String] :percolate_index The index to percolate the document into. Defaults to passed `index`.
70
+ # @option arguments [String] :percolate_type The type to percolate document into. Defaults to passed `type`.
71
+ # @option arguments [Number] :version Explicit version number for concurrency control
72
+ # @option arguments [String] :version_type Specific version type (options: internal, external)
73
+ #
74
+ # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-percolate.html
38
75
  #
39
76
  def percolate(arguments={})
40
77
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
41
- raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
42
- arguments[:type] ||= 'document'
78
+ raise ArgumentError, "Required argument 'type' missing" unless arguments[:type]
43
79
 
44
- valid_params = [ :prefer_local ]
80
+ valid_params = [
81
+ :routing,
82
+ :preference,
83
+ :ignore_unavailable,
84
+ :allow_no_indices,
85
+ :expand_wildcards,
86
+ :percolate_index,
87
+ :percolate_type,
88
+ :version,
89
+ :version_type ]
45
90
 
46
91
  method = 'GET'
47
92
  path = Utils.__pathify Utils.__escape(arguments[:index]),
48
93
  Utils.__escape(arguments[:type]),
94
+ arguments[:id],
49
95
  '_percolate'
50
96
 
51
97
  params = Utils.__validate_and_extract_params arguments, valid_params
@@ -0,0 +1,48 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Snapshot
4
+ module Actions
5
+
6
+ # Create a new snapshot in the repository
7
+ #
8
+ # @example Create a snapshot of the whole cluster in the `my-backups` repository
9
+ #
10
+ # client.snapshot.create repository: 'my-backups', snapshot: 'snapshot-1'
11
+ #
12
+ # @example Create a snapshot for specific indices in the `my-backups` repository
13
+ #
14
+ # client.snapshot.create repository: 'my-backups',
15
+ # snapshot: 'snapshot-2',
16
+ # body: { indices: 'foo,bar', ignore_unavailable: true }
17
+ #
18
+ # @option arguments [String] :repository A repository name (*Required*)
19
+ # @option arguments [String] :snapshot A snapshot name (*Required*)
20
+ # @option arguments [Hash] :body The snapshot definition
21
+ # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
22
+ # @option arguments [Boolean] :wait_for_completion Whether the request should block and wait until
23
+ # the operation has completed
24
+ #
25
+ # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
26
+ #
27
+ def create(arguments={})
28
+ raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
29
+ raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot]
30
+ valid_params = [
31
+ :master_timeout,
32
+ :wait_for_completion ]
33
+
34
+ repository = arguments.delete(:repository)
35
+ snapshot = arguments.delete(:snapshot)
36
+
37
+ method = 'PUT'
38
+ path = Utils.__pathify( '_snapshot', Utils.__escape(repository), Utils.__escape(snapshot) )
39
+
40
+ params = Utils.__validate_and_extract_params arguments, valid_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,44 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Snapshot
4
+ module Actions
5
+
6
+ # Create a repository for storing snapshots
7
+ #
8
+ # @example Create a repository at `/tmp/backup`
9
+ #
10
+ # client.snapshot.create_repository repository: 'my-backups',
11
+ # body: {
12
+ # type: 'fs',
13
+ # settings: { location: '/tmp/backup', compress: true }
14
+ # }
15
+ #
16
+ # @option arguments [String] :repository A repository name (*Required*)
17
+ # @option arguments [Hash] :body The repository definition (*Required*)
18
+ # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
19
+ # @option arguments [Time] :timeout Explicit operation timeout
20
+ #
21
+ # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
22
+ #
23
+ def create_repository(arguments={})
24
+ raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
25
+ raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
26
+ valid_params = [
27
+ :repository,
28
+ :master_timeout,
29
+ :timeout ]
30
+
31
+ repository = arguments.delete(:repository)
32
+
33
+ method = 'PUT'
34
+ path = Utils.__pathify( '_snapshot', Utils.__escape(repository) )
35
+
36
+ params = Utils.__validate_and_extract_params arguments, valid_params
37
+ body = arguments[:body]
38
+
39
+ perform_request(method, path, params, body).body
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,41 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Snapshot
4
+ module Actions
5
+
6
+ # Delete a snapshot from the repository
7
+ #
8
+ # @note Will also abort a currently running snapshot.
9
+ #
10
+ # @example Delete the `snapshot-1` snapshot
11
+ #
12
+ # client.snapshot.delete repository: 'my-backups', snapshot: 'snapshot-1'
13
+ #
14
+ # @option arguments [String] :repository A repository name (*Required*)
15
+ # @option arguments [String] :snapshot A snapshot name (*Required*)
16
+ # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
17
+ #
18
+ # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
19
+ #
20
+ def delete(arguments={})
21
+ raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
22
+ raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot]
23
+
24
+ valid_params = [
25
+ :master_timeout ]
26
+
27
+ repository = arguments.delete(:repository)
28
+ snapshot = arguments.delete(:snapshot)
29
+
30
+ method = 'DELETE'
31
+ path = Utils.__pathify( '_snapshot', Utils.__escape(repository), Utils.__listify(snapshot) )
32
+
33
+ params = Utils.__validate_and_extract_params arguments, valid_params
34
+ body = nil
35
+
36
+ perform_request(method, path, params, body).body
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,38 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Snapshot
4
+ module Actions
5
+
6
+ # Delete a specific repository or repositories
7
+ #
8
+ # @example Delete the `my-backups` repository
9
+ #
10
+ # client.snapshot.delete_repository repository: 'my-backups'
11
+ #
12
+ # @option arguments [List] :repository A comma-separated list of repository names (*Required*)
13
+ # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
14
+ # @option arguments [Time] :timeout Explicit operation timeout
15
+ #
16
+ # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
17
+ #
18
+ def delete_repository(arguments={})
19
+ raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
20
+
21
+ valid_params = [
22
+ :master_timeout,
23
+ :timeout ]
24
+
25
+ repository = arguments.delete(:repository)
26
+
27
+ method = 'DELETE'
28
+ path = Utils.__pathify( '_snapshot', Utils.__listify(repository) )
29
+
30
+ params = Utils.__validate_and_extract_params arguments, valid_params
31
+ body = nil
32
+
33
+ perform_request(method, path, params, body).body
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,47 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Snapshot
4
+ module Actions
5
+
6
+ # Return information about specific (or all) snapshots
7
+ #
8
+ # @example Return information about the `snapshot-2` snapshot
9
+ #
10
+ # client.snapshot.get repository: 'my-backup', snapshot: 'snapshot-2'
11
+ #
12
+ # @example Return information about multiple snapshots
13
+ #
14
+ # client.snapshot.get repository: 'my-backup', snapshot: ['snapshot-2', 'snapshot-3']
15
+ #
16
+ # @example Return information about all snapshots in the repository
17
+ #
18
+ # client.snapshot.get repository: 'my-backup', snapshot: '_all'
19
+ #
20
+ # @option arguments [String] :repository A repository name (*Required*)
21
+ # @option arguments [List] :snapshot A comma-separated list of snapshot names (*Required*)
22
+ # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
23
+ #
24
+ # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
25
+ #
26
+ def get(arguments={})
27
+ raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
28
+ raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot]
29
+
30
+ valid_params = [
31
+ :master_timeout ]
32
+
33
+ repository = arguments.delete(:repository)
34
+ snapshot = arguments.delete(:snapshot)
35
+
36
+ method = 'GET'
37
+ path = Utils.__pathify( '_snapshot', Utils.__escape(repository), Utils.__listify(snapshot) )
38
+
39
+ params = Utils.__validate_and_extract_params arguments, valid_params
40
+ body = nil
41
+
42
+ perform_request(method, path, params, body).body
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,42 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Snapshot
4
+ module Actions
5
+
6
+ # Get information about snapshot repositories or a specific repository
7
+ #
8
+ # @example Get all repositories
9
+ #
10
+ # client.snapshot.get_repository
11
+ #
12
+ # @example Get a specific repository
13
+ #
14
+ # client.snapshot.get_repository repository: 'my-backups'
15
+ #
16
+ # @option arguments [List] :repository A comma-separated list of repository names. Leave blank or use `_all`
17
+ # to get a list of repositories
18
+ # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
19
+ # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
20
+ # (default: false)
21
+ #
22
+ # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
23
+ #
24
+ def get_repository(arguments={})
25
+ valid_params = [
26
+ :master_timeout,
27
+ :local ]
28
+
29
+ repository = arguments.delete(:repository)
30
+
31
+ method = 'GET'
32
+ path = Utils.__pathify( '_snapshot', Utils.__escape(repository) )
33
+
34
+ params = Utils.__validate_and_extract_params arguments, valid_params
35
+ body = nil
36
+
37
+ perform_request(method, path, params, body).body
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,53 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Snapshot
4
+ module Actions
5
+
6
+ # Restore the state from a snapshot
7
+ #
8
+ # @example Restore from the `snapshot-1` snapshot
9
+ #
10
+ # client.snapshot.restore repository: 'my-backups', snapshot: 'snapshot-1'
11
+ #
12
+ # @example Restore a specific index under a different name
13
+ #
14
+ # client.snapshot.restore repository: 'my-backups',
15
+ # snapshot: 'snapshot-5',
16
+ # body: {
17
+ # rename_pattern: "^(.*)$",
18
+ # rename_replacement: "restored_$1"
19
+ # }
20
+ #
21
+ # @note You cannot restore into an open index, you have to {Indices::Actions#close} it first
22
+ #
23
+ # @option arguments [String] :repository A repository name (*Required*)
24
+ # @option arguments [String] :snapshot A snapshot name (*Required*)
25
+ # @option arguments [Hash] :body Details of what to restore
26
+ # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
27
+ # @option arguments [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning
28
+ #
29
+ # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
30
+ #
31
+ def restore(arguments={})
32
+ raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
33
+ raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot]
34
+
35
+ valid_params = [
36
+ :master_timeout,
37
+ :wait_for_completion ]
38
+
39
+ repository = arguments.delete(:repository)
40
+ snapshot = arguments.delete(:snapshot)
41
+
42
+ method = 'POST'
43
+ path = Utils.__pathify( '_snapshot', Utils.__escape(repository), Utils.__escape(snapshot), '_restore' )
44
+
45
+ params = Utils.__validate_and_extract_params arguments, valid_params
46
+ body = arguments[:body]
47
+
48
+ perform_request(method, path, params, body).body
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,77 @@
1
+ module Elasticsearch
2
+ module API
3
+ module Actions
4
+
5
+ # Return information and statistics about terms in the fields of a particular document
6
+ #
7
+ # @example Get statistics for a specific document
8
+ #
9
+ # client.indices.create index: 'my_index',
10
+ # body: {
11
+ # mappings: {
12
+ # my_type: {
13
+ # properties: {
14
+ # text: {
15
+ # type: 'string',
16
+ # term_vector: 'with_positions_offsets_payloads'
17
+ # }
18
+ # }
19
+ # }
20
+ # }
21
+ # }
22
+ #
23
+ # client.index index: 'my_index', type: 'my_type', id: '1', body: { text: 'Foo Bar Fox' }
24
+ #
25
+ # client.termvector index: 'my_index', type: 'my_type', id: '1'
26
+ # # => { ..., "term_vectors" => { "text" => { "field_statistics" => { ... }, "terms" => { "bar" => ... } } }
27
+ #
28
+ # @option arguments [String] :index The name of the index (*Required*)
29
+ # @option arguments [String] :type The type of the document (*Required*)
30
+ # @option arguments [String] :id The document ID (*Required*)
31
+ # @option arguments [Hash] :body The request definition
32
+ # @option arguments [Boolean] :term_statistics Whether total term frequency and
33
+ # document frequency should be returned
34
+ # @option arguments [Boolean] :field_statistics Whether document count, sum of document frequencies
35
+ # and sum of total term frequencies should be returned
36
+ # @option arguments [List] :fields A comma-separated list of fields to return
37
+ # @option arguments [Boolean] :offsets Whether term offsets should be returned
38
+ # @option arguments [Boolean] :positions Whether term positions should be returned
39
+ # @option arguments [Boolean] :payloads Whether term payloads should be returned
40
+ # @option arguments [String] :preference Specify the node or shard the operation should be performed on
41
+ # (default: random)
42
+ # @option arguments [String] :routing Specific routing value
43
+ # @option arguments [String] :parent Parent ID of the documents
44
+ #
45
+ # @see http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/docs-termvectors.html
46
+ #
47
+ def termvector(arguments={})
48
+ raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
49
+ raise ArgumentError, "Required argument 'type' missing" unless arguments[:type]
50
+ raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
51
+
52
+ valid_params = [
53
+ :term_statistics,
54
+ :field_statistics,
55
+ :fields,
56
+ :offsets,
57
+ :positions,
58
+ :payloads,
59
+ :preference,
60
+ :routing,
61
+ :parent ]
62
+
63
+ method = 'GET'
64
+
65
+ path = Utils.__pathify Utils.__escape(arguments[:index]),
66
+ Utils.__escape(arguments[:type]),
67
+ arguments[:id],
68
+ '_termvector'
69
+
70
+ params = Utils.__validate_and_extract_params arguments, valid_params
71
+ body = arguments[:body]
72
+
73
+ perform_request(method, path, params, body).body
74
+ end
75
+ end
76
+ end
77
+ end