elasticsearch-api 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +13 -0
- data/README.md +160 -0
- data/Rakefile +62 -0
- data/elasticsearch-api.gemspec +51 -0
- data/lib/elasticsearch-api +1 -0
- data/lib/elasticsearch/api.rb +23 -0
- data/lib/elasticsearch/api/actions/bulk.rb +71 -0
- data/lib/elasticsearch/api/actions/cluster/get_settings.rb +21 -0
- data/lib/elasticsearch/api/actions/cluster/health.rb +50 -0
- data/lib/elasticsearch/api/actions/cluster/node_hot_threads.rb +46 -0
- data/lib/elasticsearch/api/actions/cluster/node_info.rb +59 -0
- data/lib/elasticsearch/api/actions/cluster/node_shutdown.rb +36 -0
- data/lib/elasticsearch/api/actions/cluster/node_stats.rb +77 -0
- data/lib/elasticsearch/api/actions/cluster/put_settings.rb +28 -0
- data/lib/elasticsearch/api/actions/cluster/reroute.rb +44 -0
- data/lib/elasticsearch/api/actions/cluster/state.rb +47 -0
- data/lib/elasticsearch/api/actions/count.rb +46 -0
- data/lib/elasticsearch/api/actions/create.rb +34 -0
- data/lib/elasticsearch/api/actions/delete.rb +61 -0
- data/lib/elasticsearch/api/actions/delete_by_query.rb +62 -0
- data/lib/elasticsearch/api/actions/exists.rb +51 -0
- data/lib/elasticsearch/api/actions/explain.rb +71 -0
- data/lib/elasticsearch/api/actions/get.rb +59 -0
- data/lib/elasticsearch/api/actions/get_source.rb +59 -0
- data/lib/elasticsearch/api/actions/index.rb +81 -0
- data/lib/elasticsearch/api/actions/indices/analyze.rb +63 -0
- data/lib/elasticsearch/api/actions/indices/clear_cache.rb +69 -0
- data/lib/elasticsearch/api/actions/indices/close.rb +35 -0
- data/lib/elasticsearch/api/actions/indices/create.rb +83 -0
- data/lib/elasticsearch/api/actions/indices/delete.rb +48 -0
- data/lib/elasticsearch/api/actions/indices/delete_alias.rb +37 -0
- data/lib/elasticsearch/api/actions/indices/delete_mapping.rb +26 -0
- data/lib/elasticsearch/api/actions/indices/delete_template.rb +33 -0
- data/lib/elasticsearch/api/actions/indices/delete_warmer.rb +32 -0
- data/lib/elasticsearch/api/actions/indices/exists.rb +35 -0
- data/lib/elasticsearch/api/actions/indices/exists_alias.rb +41 -0
- data/lib/elasticsearch/api/actions/indices/exists_type.rb +39 -0
- data/lib/elasticsearch/api/actions/indices/flush.rb +40 -0
- data/lib/elasticsearch/api/actions/indices/get_alias.rb +41 -0
- data/lib/elasticsearch/api/actions/indices/get_aliases.rb +32 -0
- data/lib/elasticsearch/api/actions/indices/get_mapping.rb +36 -0
- data/lib/elasticsearch/api/actions/indices/get_settings.rb +32 -0
- data/lib/elasticsearch/api/actions/indices/get_template.rb +30 -0
- data/lib/elasticsearch/api/actions/indices/get_warmer.rb +44 -0
- data/lib/elasticsearch/api/actions/indices/open.rb +33 -0
- data/lib/elasticsearch/api/actions/indices/optimize.rb +57 -0
- data/lib/elasticsearch/api/actions/indices/put_alias.rb +43 -0
- data/lib/elasticsearch/api/actions/indices/put_mapping.rb +49 -0
- data/lib/elasticsearch/api/actions/indices/put_settings.rb +45 -0
- data/lib/elasticsearch/api/actions/indices/put_template.rb +40 -0
- data/lib/elasticsearch/api/actions/indices/put_warmer.rb +48 -0
- data/lib/elasticsearch/api/actions/indices/refresh.rb +43 -0
- data/lib/elasticsearch/api/actions/indices/segments.rb +33 -0
- data/lib/elasticsearch/api/actions/indices/snapshot_index.rb +32 -0
- data/lib/elasticsearch/api/actions/indices/stats.rb +96 -0
- data/lib/elasticsearch/api/actions/indices/status.rb +46 -0
- data/lib/elasticsearch/api/actions/indices/update_aliases.rb +49 -0
- data/lib/elasticsearch/api/actions/indices/validate_query.rb +68 -0
- data/lib/elasticsearch/api/actions/info.rb +19 -0
- data/lib/elasticsearch/api/actions/mget.rb +64 -0
- data/lib/elasticsearch/api/actions/mlt.rb +86 -0
- data/lib/elasticsearch/api/actions/msearch.rb +75 -0
- data/lib/elasticsearch/api/actions/percolate.rb +57 -0
- data/lib/elasticsearch/api/actions/ping.rb +29 -0
- data/lib/elasticsearch/api/actions/scroll.rb +44 -0
- data/lib/elasticsearch/api/actions/search.rb +145 -0
- data/lib/elasticsearch/api/actions/suggest.rb +46 -0
- data/lib/elasticsearch/api/actions/update.rb +103 -0
- data/lib/elasticsearch/api/namespace/cluster.rb +20 -0
- data/lib/elasticsearch/api/namespace/common.rb +27 -0
- data/lib/elasticsearch/api/namespace/indices.rb +20 -0
- data/lib/elasticsearch/api/utils.rb +97 -0
- data/lib/elasticsearch/api/version.rb +5 -0
- data/test/integration/yaml_test_runner.rb +330 -0
- data/test/test_helper.rb +52 -0
- data/test/unit/bulk_test.rb +85 -0
- data/test/unit/client_test.rb +31 -0
- data/test/unit/cluster/get_settings_test.rb +26 -0
- data/test/unit/cluster/health_test.rb +38 -0
- data/test/unit/cluster/node_hot_threads_test.rb +35 -0
- data/test/unit/cluster/node_info_test.rb +45 -0
- data/test/unit/cluster/node_shutdown_test.rb +45 -0
- data/test/unit/cluster/node_stats_test.rb +65 -0
- data/test/unit/cluster/put_settings_test.rb +26 -0
- data/test/unit/cluster/reroute_test.rb +38 -0
- data/test/unit/cluster/state_test.rb +37 -0
- data/test/unit/count_test.rb +46 -0
- data/test/unit/create_document_test.rb +38 -0
- data/test/unit/delete_by_query_test.rb +42 -0
- data/test/unit/delete_document_test.rb +62 -0
- data/test/unit/exists_document_test.rb +76 -0
- data/test/unit/explain_document_test.rb +64 -0
- data/test/unit/get_document_source_test.rb +62 -0
- data/test/unit/get_document_test.rb +62 -0
- data/test/unit/hashie_test.rb +78 -0
- data/test/unit/index_document_test.rb +77 -0
- data/test/unit/indices/analyze_test.rb +67 -0
- data/test/unit/indices/clear_cache_test.rb +45 -0
- data/test/unit/indices/close_test.rb +42 -0
- data/test/unit/indices/create_test.rb +42 -0
- data/test/unit/indices/delete_alias_test.rb +38 -0
- data/test/unit/indices/delete_mapping_test.rb +47 -0
- data/test/unit/indices/delete_template_test.rb +26 -0
- data/test/unit/indices/delete_test.rb +45 -0
- data/test/unit/indices/delete_warmer_test.rb +59 -0
- data/test/unit/indices/exists_alias_test.rb +65 -0
- data/test/unit/indices/exists_test.rb +57 -0
- data/test/unit/indices/exists_type_test.rb +59 -0
- data/test/unit/indices/flush_test.rb +45 -0
- data/test/unit/indices/get_alias_test.rb +41 -0
- data/test/unit/indices/get_aliases_test.rb +35 -0
- data/test/unit/indices/get_mapping_test.rb +53 -0
- data/test/unit/indices/get_settings_test.rb +35 -0
- data/test/unit/indices/get_template_test.rb +32 -0
- data/test/unit/indices/get_warmer_test.rb +41 -0
- data/test/unit/indices/open_test.rb +42 -0
- data/test/unit/indices/optimize_test.rb +45 -0
- data/test/unit/indices/put_alias_test.rb +47 -0
- data/test/unit/indices/put_mapping_test.rb +57 -0
- data/test/unit/indices/put_settings_test.rb +50 -0
- data/test/unit/indices/put_template_test.rb +48 -0
- data/test/unit/indices/put_warmer_test.rb +62 -0
- data/test/unit/indices/refresh_test.rb +55 -0
- data/test/unit/indices/segments_test.rb +55 -0
- data/test/unit/indices/snapshot_index_test.rb +55 -0
- data/test/unit/indices/stats_test.rb +76 -0
- data/test/unit/indices/status_test.rb +55 -0
- data/test/unit/indices/update_aliases_test.rb +42 -0
- data/test/unit/indices/validate_query_test.rb +75 -0
- data/test/unit/info_test.rb +26 -0
- data/test/unit/json_builders_test.rb +64 -0
- data/test/unit/mget_test.rb +70 -0
- data/test/unit/mlt_test.rb +80 -0
- data/test/unit/msearch_test.rb +120 -0
- data/test/unit/percolate_test.rb +49 -0
- data/test/unit/ping_test.rb +48 -0
- data/test/unit/scroll_test.rb +26 -0
- data/test/unit/search_test.rb +93 -0
- data/test/unit/suggest_test.rb +55 -0
- data/test/unit/update_document_test.rb +62 -0
- data/test/unit/utils_test.rb +118 -0
- metadata +498 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Indices
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Return the result of the analysis process (tokens)
|
7
|
+
#
|
8
|
+
# Allows to "test-drive" the Elasticsearch analysis process by performing the analysis on the
|
9
|
+
# same text with different analyzers. An ad-hoc analysis chain can be built from specific
|
10
|
+
# _tokenizer_ and _filters_.
|
11
|
+
#
|
12
|
+
# @example Analyze text "Quick Brown Jumping Fox" with the _snowball_ analyzer
|
13
|
+
#
|
14
|
+
# client.indices.analyze text: 'The Quick Brown Jumping Fox', analyzer: 'snowball'
|
15
|
+
#
|
16
|
+
# @example Analyze text "Quick Brown Jumping Fox" with the _snowball_ analyzer
|
17
|
+
#
|
18
|
+
# client.indices.analyze text: 'The Quick Brown Jumping Fox',
|
19
|
+
# tokenizer: 'whitespace',
|
20
|
+
# filters: ['lowercase','stop']
|
21
|
+
#
|
22
|
+
# @option arguments [String] :index The name of the index to scope the operation
|
23
|
+
# @option arguments [Hash] :body The text on which the analysis should be performed
|
24
|
+
# @option arguments [String] :analyzer The name of the analyzer to use
|
25
|
+
# @option arguments [String] :field Use the analyzer configured for this field
|
26
|
+
# (instead of passing the analyzer name)
|
27
|
+
# @option arguments [List] :filters A comma-separated list of filters to use for the analysis
|
28
|
+
# @option arguments [String] :index The name of the index to scope the operation
|
29
|
+
# @option arguments [Boolean] :prefer_local With `true`, specify that a local shard should be used if available,
|
30
|
+
# with `false`, use a random shard (default: true)
|
31
|
+
# @option arguments [String] :text The text on which the analysis should be performed
|
32
|
+
# (when request body is not used)
|
33
|
+
# @option arguments [String] :tokenizer The name of the tokenizer to use for the analysis
|
34
|
+
# @option arguments [String] :format Format of the output (options: detailed, text)
|
35
|
+
#
|
36
|
+
# @see http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze/
|
37
|
+
#
|
38
|
+
def analyze(arguments={})
|
39
|
+
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)
|
53
|
+
|
54
|
+
params[:filters] = Utils.__listify(params[:filters]) if params[:filters]
|
55
|
+
|
56
|
+
body = arguments[:body]
|
57
|
+
|
58
|
+
perform_request(method, path, params, body).body
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Indices
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Clear caches and other auxiliary data structures.
|
7
|
+
#
|
8
|
+
# Can be performed against a specific index, or against all indices.
|
9
|
+
#
|
10
|
+
# By default, all caches and data structures will be cleared.
|
11
|
+
# Pass a specific cache or structure name to clear just a single one.
|
12
|
+
#
|
13
|
+
# @example Clear all caches and data structures
|
14
|
+
#
|
15
|
+
# client.indices.clear_cache
|
16
|
+
#
|
17
|
+
# @example Clear the field data structure only
|
18
|
+
#
|
19
|
+
# client.indices.clear_cache field_data: true
|
20
|
+
#
|
21
|
+
# @example Clear only specific field in the field data structure
|
22
|
+
#
|
23
|
+
# client.indices.clear_cache field_data: true, fields: 'created_at', filter_cache: false, id_cache: false
|
24
|
+
#
|
25
|
+
# @option arguments [List] :index A comma-separated list of index name to limit the operation
|
26
|
+
# @option arguments [Boolean] :field_data Clear field data
|
27
|
+
# @option arguments [Boolean] :fielddata Clear field data
|
28
|
+
# @option arguments [List] :fields A comma-separated list of fields to clear when using the
|
29
|
+
# `field_data` parameter(default: all)
|
30
|
+
# @option arguments [Boolean] :filter Clear filter caches
|
31
|
+
# @option arguments [Boolean] :filter_cache Clear filter caches
|
32
|
+
# @option arguments [Boolean] :filter_keys A comma-separated list of keys to clear when using the
|
33
|
+
# `filter_cache` parameter (default: all)
|
34
|
+
# @option arguments [Boolean] :id Clear ID caches for parent/child
|
35
|
+
# @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)
|
38
|
+
# @option arguments [List] :index A comma-separated list of index name to limit the operation
|
39
|
+
# @option arguments [Boolean] :recycler Clear the recycler cache
|
40
|
+
#
|
41
|
+
# @see http://www.elasticsearch.org/guide/reference/api/admin-indices-clearcache/
|
42
|
+
#
|
43
|
+
def clear_cache(arguments={})
|
44
|
+
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)
|
60
|
+
body = nil
|
61
|
+
|
62
|
+
params[:fields] = Utils.__listify(params[:fields]) if params[:fields]
|
63
|
+
|
64
|
+
perform_request(method, path, params, body).body
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Indices
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Close an index (keep the data on disk, but deny operations with the index).
|
7
|
+
#
|
8
|
+
# A closed index can be opened again with the {Indices::Actions#close} API.
|
9
|
+
#
|
10
|
+
# @example Close index named _myindex_
|
11
|
+
#
|
12
|
+
# client.indices.close index: 'myindex'
|
13
|
+
#
|
14
|
+
# @option arguments [String] :index The name of the index (*Required*)
|
15
|
+
# @option arguments [Time] :timeout Explicit operation timeout
|
16
|
+
#
|
17
|
+
# @see http://www.elasticsearch.org/guide/reference/api/admin-indices-open-close/
|
18
|
+
#
|
19
|
+
def close(arguments={})
|
20
|
+
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
|
21
|
+
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)
|
28
|
+
body = nil
|
29
|
+
|
30
|
+
perform_request(method, path, params, body).body
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Indices
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Create an index.
|
7
|
+
#
|
8
|
+
# Pass the index `settings` and `mappings` in the `:body` attribute.
|
9
|
+
#
|
10
|
+
# @example Create an index with specific settings, custom analyzers and mappings
|
11
|
+
#
|
12
|
+
# client.indices.create index: 'test',
|
13
|
+
# body: {
|
14
|
+
# settings: {
|
15
|
+
# index: {
|
16
|
+
# number_of_shards: 1,
|
17
|
+
# number_of_replicas: 0,
|
18
|
+
# 'routing.allocation.include.name' => 'node-1'
|
19
|
+
# },
|
20
|
+
# analysis: {
|
21
|
+
# filter: {
|
22
|
+
# ngram: {
|
23
|
+
# type: 'nGram',
|
24
|
+
# min_gram: 3,
|
25
|
+
# max_gram: 25
|
26
|
+
# }
|
27
|
+
# },
|
28
|
+
# analyzer: {
|
29
|
+
# ngram: {
|
30
|
+
# tokenizer: 'whitespace',
|
31
|
+
# filter: ['lowercase', 'stop', 'ngram'],
|
32
|
+
# type: 'custom'
|
33
|
+
# },
|
34
|
+
# ngram_search: {
|
35
|
+
# tokenizer: 'whitespace',
|
36
|
+
# filter: ['lowercase', 'stop'],
|
37
|
+
# type: 'custom'
|
38
|
+
# }
|
39
|
+
# }
|
40
|
+
# }
|
41
|
+
# },
|
42
|
+
# mappings: {
|
43
|
+
# document: {
|
44
|
+
# properties: {
|
45
|
+
# title: {
|
46
|
+
# type: 'multi_field',
|
47
|
+
# fields: {
|
48
|
+
# title: { type: 'string', analyzer: 'snowball' },
|
49
|
+
# exact: { type: 'string', analyzer: 'keyword' },
|
50
|
+
# ngram: { type: 'string',
|
51
|
+
# index_analyzer: 'ngram',
|
52
|
+
# search_analyzer: 'ngram_search'
|
53
|
+
# }
|
54
|
+
# }
|
55
|
+
# }
|
56
|
+
# }
|
57
|
+
# }
|
58
|
+
# }
|
59
|
+
# }
|
60
|
+
#
|
61
|
+
# @option arguments [String] :index The name of the index (*Required*)
|
62
|
+
# @option arguments [Hash] :body Optional configuration for the index (`settings` and `mappings`)
|
63
|
+
# @option arguments [Time] :timeout Explicit operation timeout
|
64
|
+
#
|
65
|
+
# @see http://www.elasticsearch.org/guide/reference/api/admin-indices-create-index/
|
66
|
+
#
|
67
|
+
def create(arguments={})
|
68
|
+
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
|
69
|
+
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)
|
76
|
+
body = arguments[:body]
|
77
|
+
|
78
|
+
perform_request(method, path, params, body).body
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Indices
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Delete an index, list of indices, or all indices in the cluster.
|
7
|
+
#
|
8
|
+
# @example Delete an index
|
9
|
+
#
|
10
|
+
# client.indices.delete index: 'foo'
|
11
|
+
#
|
12
|
+
# @example Delete a list of indices
|
13
|
+
#
|
14
|
+
# client.indices.delete index: ['foo', 'bar']
|
15
|
+
# client.indices.delete index: 'foo,bar'
|
16
|
+
#
|
17
|
+
#
|
18
|
+
# @example Delete a list of indices matching wildcard expression
|
19
|
+
#
|
20
|
+
# client.indices.delete index: 'foo*'
|
21
|
+
#
|
22
|
+
# @example Delete all indices
|
23
|
+
#
|
24
|
+
# client.indices.delete
|
25
|
+
# client.indices.delete index: '_all'
|
26
|
+
#
|
27
|
+
# @option arguments [List] :index A comma-separated list of indices to delete;
|
28
|
+
# use `_all` or leave empty to delete all indices
|
29
|
+
# @option arguments [Time] :timeout Explicit operation timeout
|
30
|
+
#
|
31
|
+
# @see http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-index/
|
32
|
+
#
|
33
|
+
def delete(arguments={})
|
34
|
+
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)
|
41
|
+
body = nil
|
42
|
+
|
43
|
+
perform_request(method, path, params, body).body
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Indices
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Delete a single index alias.
|
7
|
+
#
|
8
|
+
# @example Delete an alias
|
9
|
+
#
|
10
|
+
# client.indices.delete_alias index: 'foo', name: 'bar'
|
11
|
+
#
|
12
|
+
# See the {Indices::Actions#update_aliases} for performing operations with index aliases in bulk.
|
13
|
+
#
|
14
|
+
# @option arguments [String] :index The name of the index with an alias (*Required*)
|
15
|
+
# @option arguments [String] :name The name of the alias to be deleted (*Required*)
|
16
|
+
# @option arguments [Time] :timeout Explicit timestamp for the document
|
17
|
+
#
|
18
|
+
# @see http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/
|
19
|
+
#
|
20
|
+
def delete_alias(arguments={})
|
21
|
+
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
|
22
|
+
raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
|
23
|
+
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)
|
30
|
+
body = nil
|
31
|
+
|
32
|
+
perform_request(method, path, params, body).body
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Indices
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Delete all documents and mapping for a specific document type.
|
7
|
+
#
|
8
|
+
# @option arguments [List] :index A comma-separated list of index names; use `_all` for all indices (*Required*)
|
9
|
+
# @option arguments [String] :type The name of the document type to delete (*Required*)
|
10
|
+
#
|
11
|
+
# @see http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-mapping/
|
12
|
+
#
|
13
|
+
def delete_mapping(arguments={})
|
14
|
+
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
|
15
|
+
raise ArgumentError, "Required argument 'type' missing" unless arguments[:type]
|
16
|
+
method = 'DELETE'
|
17
|
+
path = Utils.__pathify( Utils.__listify(arguments[:index]), arguments[:type] )
|
18
|
+
params = {}
|
19
|
+
body = nil
|
20
|
+
|
21
|
+
perform_request(method, path, params, body).body
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Indices
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Delete an index template.
|
7
|
+
#
|
8
|
+
# @example Delete a template named _mytemplate_
|
9
|
+
#
|
10
|
+
# client.indices.delete_template name: 'mytemplate'
|
11
|
+
#
|
12
|
+
# @option arguments [String] :name The name of the template (*Required*)
|
13
|
+
# @option arguments [Time] :timeout Explicit operation timeout
|
14
|
+
#
|
15
|
+
# @see http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/
|
16
|
+
#
|
17
|
+
def delete_template(arguments={})
|
18
|
+
raise ArgumentError, "Required argument 'name' missing" unless arguments[:name]
|
19
|
+
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)
|
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
|
+
# Delete one or more warmers for a list of indices.
|
7
|
+
#
|
8
|
+
# @example Delete a warmer named _mywarmer_ for index named _myindex_
|
9
|
+
#
|
10
|
+
# client.indices.delete_warmer index: 'myindex', name: 'mywarmer'
|
11
|
+
#
|
12
|
+
# @option arguments [List] :index A comma-separated list of index names to register warmer for; use `_all`
|
13
|
+
# or empty string to perform the operation on all indices (*Required*)
|
14
|
+
# @option arguments [String] :name The name of the warmer (supports wildcards); leave empty to delete all warmers
|
15
|
+
# @option arguments [List] :type A comma-separated list of document types to register warmer for; use `_all`
|
16
|
+
# or empty string to perform the operation on all types
|
17
|
+
#
|
18
|
+
# @see http://www.elasticsearch.org/guide/reference/api/admin-indices-warmers/
|
19
|
+
#
|
20
|
+
def delete_warmer(arguments={})
|
21
|
+
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
|
22
|
+
method = 'DELETE'
|
23
|
+
path = Utils.__pathify( Utils.__listify(arguments[:index]), '_warmer', Utils.__listify(arguments[:name]) )
|
24
|
+
params = {}
|
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,35 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Indices
|
4
|
+
module Actions
|
5
|
+
|
6
|
+
# Return true if the index (or all indices in a list) exists, false otherwise.
|
7
|
+
#
|
8
|
+
# @example Check whether index named _myindex_ exists
|
9
|
+
#
|
10
|
+
# client.indices.exists index: 'myindex'
|
11
|
+
#
|
12
|
+
# @option arguments [List] :index A comma-separated list of indices to check (*Required*)
|
13
|
+
# @return [true,false]
|
14
|
+
#
|
15
|
+
# @see http://www.elasticsearch.org/guide/reference/api/admin-indices-indices-exists/
|
16
|
+
#
|
17
|
+
def exists(arguments={})
|
18
|
+
raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
|
19
|
+
method = 'HEAD'
|
20
|
+
path = Utils.__listify(arguments[:index])
|
21
|
+
params = {}
|
22
|
+
body = nil
|
23
|
+
|
24
|
+
perform_request(method, path, params, body).status == 200 ? true : false
|
25
|
+
rescue Exception => e
|
26
|
+
if e.class.to_s =~ /NotFound/ || e.message =~ /Not\s*Found|404/i
|
27
|
+
false
|
28
|
+
else
|
29
|
+
raise e
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|