elasticsearch-api 6.3.0 → 6.3.1
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 +4 -4
- data/lib/elasticsearch/api/actions/delete_template.rb +21 -0
- data/lib/elasticsearch/api/actions/field_stats.rb +36 -0
- data/lib/elasticsearch/api/actions/get_template.rb +27 -0
- data/lib/elasticsearch/api/actions/indices/delete_mapping.rb +26 -0
- data/lib/elasticsearch/api/actions/indices/delete_warmer.rb +32 -0
- data/lib/elasticsearch/api/actions/indices/get_aliases.rb +37 -0
- data/lib/elasticsearch/api/actions/indices/get_warmer.rb +62 -0
- data/lib/elasticsearch/api/actions/indices/optimize.rb +77 -0
- data/lib/elasticsearch/api/actions/indices/put_warmer.rb +65 -0
- data/lib/elasticsearch/api/actions/indices/seal.rb +24 -0
- data/lib/elasticsearch/api/actions/indices/snapshot_index.rb +44 -0
- data/lib/elasticsearch/api/actions/indices/status.rb +63 -0
- data/lib/elasticsearch/api/actions/list_benchmarks.rb +27 -0
- data/lib/elasticsearch/api/actions/mlt.rb +130 -0
- data/lib/elasticsearch/api/actions/mpercolate.rb +62 -0
- data/lib/elasticsearch/api/actions/nodes/shutdown.rb +39 -0
- data/lib/elasticsearch/api/actions/percolate.rb +73 -0
- data/lib/elasticsearch/api/actions/put_template.rb +25 -0
- data/lib/elasticsearch/api/actions/remote/info.rb +21 -0
- data/lib/elasticsearch/api/actions/search_exists.rb +63 -0
- data/lib/elasticsearch/api/actions/suggest.rb +49 -0
- data/lib/elasticsearch/api/version.rb +1 -1
- data/spec/elasticsearch/api/actions/delete_template_spec.rb +17 -0
- data/spec/elasticsearch/api/actions/field_stats_spec.rb +17 -0
- data/spec/elasticsearch/api/actions/get_template_spec.rb +52 -0
- data/spec/elasticsearch/api/actions/indices/delete_mapping_spec.rb +77 -0
- data/spec/elasticsearch/api/actions/indices/delete_warmer_spec.rb +86 -0
- data/spec/elasticsearch/api/actions/indices/get_aliases_spec.rb +55 -0
- data/spec/elasticsearch/api/actions/indices/get_warmer_spec.rb +48 -0
- data/spec/elasticsearch/api/actions/indices/optimize_spec.rb +63 -0
- data/spec/elasticsearch/api/actions/indices/put_warmer_spec.rb +101 -0
- data/spec/elasticsearch/api/actions/indices/seal_spec.rb +18 -0
- data/spec/elasticsearch/api/actions/indices/snapshot_index_spec.rb +89 -0
- data/spec/elasticsearch/api/actions/indices/status_spec.rb +92 -0
- data/spec/elasticsearch/api/actions/list_benchmarks_spec.rb +17 -0
- data/spec/elasticsearch/api/actions/mlt_spec.rb +130 -0
- data/spec/elasticsearch/api/actions/mpercolate_spec.rb +49 -0
- data/spec/elasticsearch/api/actions/nodes/shutdown_spec.rb +59 -0
- data/spec/elasticsearch/api/actions/percolate_spec.rb +67 -0
- data/spec/elasticsearch/api/actions/put_template_spec.rb +17 -0
- data/spec/elasticsearch/api/actions/remote/info_spec.rb +18 -0
- data/spec/elasticsearch/api/actions/search_exists_spec.rb +63 -0
- data/spec/elasticsearch/api/actions/suggest_spec.rb +77 -0
- metadata +65 -2
@@ -0,0 +1,63 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Actions
|
4
|
+
|
5
|
+
# Return whether documents exists for a particular query
|
6
|
+
#
|
7
|
+
# @option arguments [List] :index A comma-separated list of indices to restrict the results
|
8
|
+
# @option arguments [List] :type A comma-separated list of types to restrict the results
|
9
|
+
# @option arguments [Hash] :body A query to restrict the results specified with the Query DSL (optional)
|
10
|
+
# @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
|
11
|
+
# unavailable (missing or closed)
|
12
|
+
# @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves
|
13
|
+
# into no concrete indices.
|
14
|
+
# @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices
|
15
|
+
# that are open, closed or both.
|
16
|
+
# (options: open, closed, none, all)
|
17
|
+
# @option arguments [Number] :min_score Include only documents with a specific `_score` value in the result
|
18
|
+
# @option arguments [String] :preference Specify the node or shard the operation should be performed on
|
19
|
+
# (default: random)
|
20
|
+
# @option arguments [String] :routing Specific routing value
|
21
|
+
# @option arguments [String] :q Query in the Lucene query string syntax
|
22
|
+
# @option arguments [String] :analyzer The analyzer to use for the query string
|
23
|
+
# @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be
|
24
|
+
# analyzed (default: false)
|
25
|
+
# @option arguments [String] :default_operator The default operator for query string query (AND or OR)
|
26
|
+
# (options: AND, OR)
|
27
|
+
# @option arguments [String] :df The field to use as default where no field prefix is given
|
28
|
+
# in the query string
|
29
|
+
# @option arguments [Boolean] :lenient Specify whether format-based query failures
|
30
|
+
# (such as providing text to a numeric field) should be ignored
|
31
|
+
# @option arguments [Boolean] :lowercase_expanded_terms Specify whether query terms should be lowercased
|
32
|
+
#
|
33
|
+
# @see http://www.elastic.co/guide/en/elasticsearch/reference/master/search-exists.html
|
34
|
+
#
|
35
|
+
def search_exists(arguments={})
|
36
|
+
method = 'POST'
|
37
|
+
path = "_search/exists"
|
38
|
+
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
39
|
+
body = arguments[:body]
|
40
|
+
|
41
|
+
perform_request(method, path, params, body).body
|
42
|
+
end
|
43
|
+
|
44
|
+
# Register this action with its valid params when the module is loaded.
|
45
|
+
#
|
46
|
+
# @since 6.2.0
|
47
|
+
ParamsRegistry.register(:search_exists, [
|
48
|
+
:ignore_unavailable,
|
49
|
+
:allow_no_indices,
|
50
|
+
:expand_wildcards,
|
51
|
+
:min_score,
|
52
|
+
:preference,
|
53
|
+
:routing,
|
54
|
+
:q,
|
55
|
+
:analyzer,
|
56
|
+
:analyze_wildcard,
|
57
|
+
:default_operator,
|
58
|
+
:df,
|
59
|
+
:lenient,
|
60
|
+
:lowercase_expanded_terms ].freeze)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Elasticsearch
|
2
|
+
module API
|
3
|
+
module Actions
|
4
|
+
|
5
|
+
# Return query terms suggestions based on provided text and configuration.
|
6
|
+
#
|
7
|
+
# Pass the request definition in the `:body` argument.
|
8
|
+
#
|
9
|
+
# @example Return query terms suggestions ("auto-correction")
|
10
|
+
#
|
11
|
+
# client.suggest index: 'myindex',
|
12
|
+
# body: { my_suggest: { text: 'tset', term: { field: 'title' } } }
|
13
|
+
# # => { ... "my_suggest"=>[ {"text"=>"tset", ... "options"=>[{"text"=>"test", "score"=>0.75, "freq"=>5}] }]}
|
14
|
+
#
|
15
|
+
# @option arguments [List] :index A comma-separated list of index names to restrict the operation;
|
16
|
+
# use `_all` or empty string to perform the operation on all indices
|
17
|
+
# @option arguments [Hash] :body The request definition
|
18
|
+
# @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore `missing` ones
|
19
|
+
# (options: none, missing)
|
20
|
+
# @option arguments [String] :preference Specify the node or shard the operation should be performed on
|
21
|
+
# (default: random)
|
22
|
+
# @option arguments [String] :routing Specific routing value
|
23
|
+
# @option arguments [String] :source The URL-encoded request definition (instead of using request body)
|
24
|
+
#
|
25
|
+
# @since 0.90
|
26
|
+
#
|
27
|
+
# @see http://elasticsearch.org/guide/reference/api/search/suggest/
|
28
|
+
#
|
29
|
+
def suggest(arguments={})
|
30
|
+
method = HTTP_POST
|
31
|
+
path = Utils.__pathify( Utils.__listify(arguments[:index]), '_suggest' )
|
32
|
+
|
33
|
+
params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
|
34
|
+
body = arguments[:body]
|
35
|
+
|
36
|
+
perform_request(method, path, params, body).body
|
37
|
+
end
|
38
|
+
|
39
|
+
# Register this action with its valid params when the module is loaded.
|
40
|
+
#
|
41
|
+
# @since 6.2.0
|
42
|
+
ParamsRegistry.register(:suggest, [
|
43
|
+
:ignore_indices,
|
44
|
+
:preference,
|
45
|
+
:routing,
|
46
|
+
:source ].freeze)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'client#delete_template' do
|
4
|
+
|
5
|
+
let(:expected_args) do
|
6
|
+
[
|
7
|
+
'DELETE',
|
8
|
+
'_search/template/foo',
|
9
|
+
{},
|
10
|
+
nil
|
11
|
+
]
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'performs the request' do
|
15
|
+
expect(client_double.delete_template(id: 'foo')).to eq({})
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'client#get_template' do
|
4
|
+
|
5
|
+
let(:expected_args) do
|
6
|
+
[
|
7
|
+
'GET',
|
8
|
+
url,
|
9
|
+
params,
|
10
|
+
nil
|
11
|
+
]
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:params) do
|
15
|
+
{ }
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:client) do
|
19
|
+
Class.new { include Elasticsearch::API }.new
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when the `lang` parameter is specified' do
|
23
|
+
|
24
|
+
let(:url) do
|
25
|
+
'_scripts/foo'
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'performs the request' do
|
29
|
+
expect(client_double.get_template(id: 'foo')).to eq({})
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when the request raises a NotFound exception' do
|
34
|
+
|
35
|
+
before do
|
36
|
+
expect(client).to receive(:perform_request).and_raise(NotFound)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'raises the exception' do
|
40
|
+
expect {
|
41
|
+
client.get_template(id: 'foo')
|
42
|
+
}.to raise_exception(NotFound)
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when the ignore parameter is specified' do
|
46
|
+
|
47
|
+
it 'returns false' do
|
48
|
+
expect(client.get_template(id: 'foo', ignore: 404)).to eq(false)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'client.indices#delete_mapping' do
|
4
|
+
|
5
|
+
let(:expected_args) do
|
6
|
+
[
|
7
|
+
'DELETE',
|
8
|
+
url,
|
9
|
+
params,
|
10
|
+
nil,
|
11
|
+
nil
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:params) do
|
16
|
+
{}
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when there is no index specified' do
|
20
|
+
|
21
|
+
let(:client) do
|
22
|
+
Class.new { include Elasticsearch::API }.new
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'raises an exception' do
|
26
|
+
expect {
|
27
|
+
client.indices.delete_mapping(type: 'foo')
|
28
|
+
}.to raise_exception(ArgumentError)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when there is no type specified' do
|
33
|
+
|
34
|
+
let(:client) do
|
35
|
+
Class.new { include Elasticsearch::API }.new
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'raises an exception' do
|
39
|
+
expect {
|
40
|
+
client.indices.delete_mapping(index: 'foo')
|
41
|
+
}.to raise_exception(ArgumentError)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when an index and type are specified' do
|
46
|
+
|
47
|
+
let(:url) do
|
48
|
+
'foo/bar'
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'performs the request' do
|
52
|
+
expect(client_double.indices.delete_mapping(index: 'foo', type: 'bar')).to eq({})
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when multiple indices are specified' do
|
57
|
+
|
58
|
+
let(:url) do
|
59
|
+
'foo,bar/baz'
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'performs the request' do
|
63
|
+
expect(client_double.indices.delete_mapping(index: ['foo','bar'], type: 'baz')).to eq({})
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when the path must be URL-escaped' do
|
68
|
+
|
69
|
+
let(:url) do
|
70
|
+
'foo%5Ebar/bar%2Fbam'
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'performs the request' do
|
74
|
+
expect(client_double.indices.delete_mapping(index: 'foo^bar', type: 'bar/bam')).to eq({})
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'client.indices#delete_warmer' do
|
4
|
+
|
5
|
+
let(:expected_args) do
|
6
|
+
[
|
7
|
+
'DELETE',
|
8
|
+
url,
|
9
|
+
params,
|
10
|
+
nil,
|
11
|
+
nil
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:params) do
|
16
|
+
{}
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when an index is not specified' do
|
20
|
+
|
21
|
+
let(:client) do
|
22
|
+
Class.new { include Elasticsearch::API }.new
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'raises an exception' do
|
26
|
+
expect {
|
27
|
+
client.indices.delete_warmer
|
28
|
+
}.to raise_exception(ArgumentError)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when an index is specified' do
|
33
|
+
|
34
|
+
let(:url) do
|
35
|
+
'foo/_warmer'
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'performs the request' do
|
39
|
+
expect(client_double.indices.delete_warmer(index: 'foo')).to eq({})
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when multiple indices are specified' do
|
44
|
+
|
45
|
+
let(:url) do
|
46
|
+
'foo,bar/_warmer'
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'performs the request' do
|
50
|
+
expect(client_double.indices.delete_warmer(index: ['foo', 'bar'])).to eq({})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'when a single warmer is specified' do
|
55
|
+
|
56
|
+
let(:url) do
|
57
|
+
'foo/_warmer/bar'
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'performs the request' do
|
61
|
+
expect(client_double.indices.delete_warmer(index: 'foo', name: 'bar')).to eq({})
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'when a multiple warmers are specified' do
|
66
|
+
|
67
|
+
let(:url) do
|
68
|
+
'foo/_warmer/bar,baz'
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'performs the request' do
|
72
|
+
expect(client_double.indices.delete_warmer(index: 'foo', name: ['bar', 'baz'])).to eq({})
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when the path needs to be URL-escaped' do
|
77
|
+
|
78
|
+
let(:url) do
|
79
|
+
'foo%5Ebar/_warmer/bar%2Fbam'
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'performs the request' do
|
83
|
+
expect(client_double.indices.delete_warmer(index: 'foo^bar', name: 'bar/bam')).to eq({})
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'client.cluster#get_aliases' do
|
4
|
+
|
5
|
+
let(:expected_args) do
|
6
|
+
[
|
7
|
+
'GET',
|
8
|
+
url,
|
9
|
+
{},
|
10
|
+
nil,
|
11
|
+
nil
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:url) do
|
16
|
+
'_aliases'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'performs the request' do
|
20
|
+
expect(client_double.indices.get_aliases).to eq({})
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when an index is specified' do
|
24
|
+
|
25
|
+
let(:url) do
|
26
|
+
'foo/_aliases'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'performs the request' do
|
30
|
+
expect(client_double.indices.get_aliases(index: 'foo')).to eq({})
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when a specified alias is specified' do
|
35
|
+
|
36
|
+
let(:url) do
|
37
|
+
'foo/_aliases/bar'
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'performs the request' do
|
41
|
+
expect(client_double.indices.get_aliases(index: 'foo', name: 'bar')).to eq({})
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when the path needs to be URL-escaped' do
|
46
|
+
|
47
|
+
let(:url) do
|
48
|
+
'foo%5Ebar/_aliases'
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'performs the request' do
|
52
|
+
expect(client_double.indices.get_aliases(index: 'foo^bar')).to eq({})
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'client.indices#get_warmer' do
|
4
|
+
|
5
|
+
let(:expected_args) do
|
6
|
+
[
|
7
|
+
'GET',
|
8
|
+
url,
|
9
|
+
params,
|
10
|
+
nil,
|
11
|
+
nil
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:params) do
|
16
|
+
{}
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:url) do
|
20
|
+
'_all/_warmer'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'performs the request' do
|
24
|
+
expect(client_double.indices.get_warmer(index: '_all')).to eq({})
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when a specified warmer is specified' do
|
28
|
+
|
29
|
+
let(:url) do
|
30
|
+
'foo/_warmer/bar'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'performs the request' do
|
34
|
+
expect(client_double.indices.get_warmer(index: 'foo', name: 'bar')).to eq({})
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when the path must be URL-escaped' do
|
39
|
+
|
40
|
+
let(:url) do
|
41
|
+
'foo%5Ebar/_warmer/bar%2Fbam'
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'performs the request' do
|
45
|
+
expect(client_double.indices.get_warmer(index: 'foo^bar', name: 'bar/bam')).to eq({})
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|