esearch 0.2.1 → 0.2.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 +4 -4
- data/.rubocop.yml +6 -0
- data/.travis.yml +2 -5
- data/Changelog.md +5 -0
- data/Gemfile +1 -1
- data/Gemfile.devtools +22 -18
- data/config/flay.yml +2 -2
- data/config/reek.yml +5 -4
- data/config/rubocop.yml +81 -0
- data/esearch.gemspec +7 -7
- data/lib/esearch.rb +3 -1
- data/lib/esearch/cluster.rb +6 -5
- data/lib/esearch/command.rb +15 -7
- data/lib/esearch/command/cluster.rb +6 -4
- data/lib/esearch/command/document.rb +13 -13
- data/lib/esearch/command/exist.rb +6 -4
- data/lib/esearch/command/index.rb +7 -5
- data/lib/esearch/command/search.rb +5 -4
- data/lib/esearch/command/status.rb +5 -3
- data/lib/esearch/connection.rb +4 -3
- data/lib/esearch/document.rb +4 -2
- data/lib/esearch/index.rb +4 -2
- data/lib/esearch/indices.rb +8 -6
- data/lib/esearch/mixin.rb +8 -6
- data/lib/esearch/presenter.rb +5 -3
- data/lib/esearch/presenter/aspect.rb +5 -3
- data/lib/esearch/presenter/aspect/range.rb +11 -9
- data/lib/esearch/presenter/aspect/term.rb +6 -4
- data/lib/esearch/presenter/cluster.rb +6 -4
- data/lib/esearch/presenter/document.rb +12 -10
- data/lib/esearch/presenter/facet.rb +9 -9
- data/lib/esearch/presenter/hit.rb +9 -8
- data/lib/esearch/presenter/hits.rb +8 -7
- data/lib/esearch/presenter/index.rb +9 -7
- data/lib/esearch/presenter/search.rb +7 -5
- data/lib/esearch/presenter/status.rb +6 -4
- data/lib/esearch/request.rb +5 -3
- data/lib/esearch/type.rb +5 -2
- data/spec/integration/esearch/spike_spec.rb +15 -10
- data/spec/spec_helper.rb +6 -5
- data/spec/support/example_group_methods.rb +2 -0
- data/spec/support/ice_nine_config.rb +2 -0
- data/spec/unit/esearch/cluster_spec.rb +59 -0
- data/spec/unit/esearch/command/class_methods/run_spec.rb +3 -1
- data/spec/unit/esearch/command/cluster/health/run_spec.rb +2 -0
- data/spec/unit/esearch/command/document/delete/run_spec.rb +3 -1
- data/spec/unit/esearch/command/document/get/result_spec.rb +5 -3
- data/spec/unit/esearch/command/document/index/create/run_spec.rb +6 -2
- data/spec/unit/esearch/command/document/index/run_create_spec.rb +6 -2
- data/spec/unit/esearch/command/document/index/run_spec.rb +3 -1
- data/spec/unit/esearch/command/document/index/run_update_spec.rb +6 -2
- data/spec/unit/esearch/command/document/index/update/run_spec.rb +6 -2
- data/spec/unit/esearch/command/exist/result_spec.rb +5 -3
- data/spec/unit/esearch/command/index/create/run_spec.rb +2 -0
- data/spec/unit/esearch/command/index/delete/run_spec.rb +3 -1
- data/spec/unit/esearch/command/index/refresh/run_spec.rb +3 -1
- data/spec/unit/esearch/command/result_spec.rb +17 -7
- data/spec/unit/esearch/command/search/run_spec.rb +2 -0
- data/spec/unit/esearch/command/status/run_spec.rb +3 -1
- data/spec/unit/esearch/connection/class_methods/build_spec.rb +2 -0
- data/spec/unit/esearch/connection/run_spec.rb +6 -4
- data/spec/unit/esearch/document_spec.rb +44 -0
- data/spec/unit/esearch/index_spec.rb +42 -0
- data/spec/unit/esearch/indices/all_spec.rb +16 -0
- data/spec/unit/esearch/indices_spec.rb +18 -0
- data/spec/unit/esearch/mixin/document/index_create_spec.rb +2 -0
- data/spec/unit/esearch/mixin/document/index_spec.rb +2 -0
- data/spec/unit/esearch/mixin/document/index_update_spec.rb +2 -0
- data/spec/unit/esearch/mixin/exist/exist_predicate_spec.rb +2 -0
- data/spec/unit/esearch/mixin/index/refresh_spec.rb +2 -0
- data/spec/unit/esearch/mixin/index/status_spec.rb +2 -0
- data/spec/unit/esearch/mixin/search/search_spec.rb +2 -0
- data/spec/unit/esearch/presenter/aspect/range/from_spec.rb +2 -0
- data/spec/unit/esearch/presenter/aspect/range/to_spec.rb +2 -0
- data/spec/unit/esearch/presenter/class_methods/new_spec.rb +2 -0
- data/spec/unit/esearch/presenter/facet_spec.rb +60 -0
- data/spec/unit/esearch/presenter/hit/fields_spec.rb +2 -0
- data/spec/unit/esearch/presenter/hit/source_spec.rb +2 -0
- data/spec/unit/esearch/presenter/hits/each_spec.rb +7 -5
- data/spec/unit/esearch/presenter/hits/size_spec.rb +5 -3
- data/spec/unit/esearch/presenter/search_spec.rb +50 -0
- data/spec/unit/esearch/request_spec.rb +96 -0
- data/spec/unit/esearch/type_spec.rb +37 -0
- metadata +34 -50
- data/spec/unit/esearch/cluster/class_methods/connect_spec.rb +0 -16
- data/spec/unit/esearch/cluster/health_spec.rb +0 -10
- data/spec/unit/esearch/cluster/index_spec.rb +0 -11
- data/spec/unit/esearch/cluster/indices_spec.rb +0 -11
- data/spec/unit/esearch/cluster/path_spec.rb +0 -11
- data/spec/unit/esearch/document/connection_spec.rb +0 -12
- data/spec/unit/esearch/document/delete_spec.rb +0 -12
- data/spec/unit/esearch/document/get_spec.rb +0 -12
- data/spec/unit/esearch/index/create_spec.rb +0 -12
- data/spec/unit/esearch/index/delete_spec.rb +0 -11
- data/spec/unit/esearch/index/type_spec.rb +0 -12
- data/spec/unit/esearch/indices/all/path_spec.rb +0 -12
- data/spec/unit/esearch/presenter/facet/build_spec.rb +0 -26
- data/spec/unit/esearch/presenter/facet/class_methods/build_spec.rb +0 -26
- data/spec/unit/esearch/request/initialize_spec.rb +0 -39
- data/spec/unit/esearch/request/run_spec.rb +0 -39
- data/spec/unit/esearch/type/connection_spec.rb +0 -15
- data/spec/unit/esearch/type/document_spec.rb +0 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: acafe41081092b280de121a3e1aa8a6a3813c6c2
|
|
4
|
+
data.tar.gz: 099294a0951e736419480912c320339b909a1f7a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cc1e336abde1a44a9f80d3317963eed6a6257cb3cd0f7e37cf32f067e312a071b8118d6dc3034cc958dd55d4c1db93d6f6de68f0a29e52bde0a0a2172d7832ad
|
|
7
|
+
data.tar.gz: 6067f7779ff252a74aefc24350ed215748be3382fc399c1d938d77b152e7d67fff3705be46829fe25f65e3ecd0ad70969d6d30976476d2fd02403603e3298435
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
data/Changelog.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.devtools
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
3
|
group :development do
|
|
4
|
-
gem 'rake',
|
|
5
|
-
gem 'rspec',
|
|
6
|
-
gem '
|
|
4
|
+
gem 'rake', '~> 10.2.1'
|
|
5
|
+
gem 'rspec', '~> 2.14.1'
|
|
6
|
+
gem 'rspec-core', '~> 2.14.8'
|
|
7
|
+
gem 'yard', '~> 0.8.7.4'
|
|
7
8
|
|
|
8
9
|
platform :rbx do
|
|
9
10
|
gem 'rubysl-singleton', '~> 2.0.0'
|
|
@@ -11,23 +12,23 @@ group :development do
|
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
group :yard do
|
|
14
|
-
gem 'kramdown', '~> 1.3.
|
|
15
|
+
gem 'kramdown', '~> 1.3.3'
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
group :guard do
|
|
18
|
-
gem 'guard', '~> 2.
|
|
19
|
+
gem 'guard', '~> 2.6.0'
|
|
19
20
|
gem 'guard-bundler', '~> 2.0.0'
|
|
20
|
-
gem 'guard-rspec', '~> 4.2.
|
|
21
|
-
gem 'guard-rubocop', '~> 1.0.
|
|
21
|
+
gem 'guard-rspec', '~> 4.2.8'
|
|
22
|
+
gem 'guard-rubocop', '~> 1.0.2'
|
|
22
23
|
|
|
23
24
|
# file system change event handling
|
|
24
|
-
gem 'listen', '~> 2.
|
|
25
|
+
gem 'listen', '~> 2.7.1'
|
|
25
26
|
gem 'rb-fchange', '~> 0.0.6', require: false
|
|
26
|
-
gem 'rb-fsevent', '~> 0.9.
|
|
27
|
-
gem 'rb-inotify', '~> 0.9.
|
|
27
|
+
gem 'rb-fsevent', '~> 0.9.4', require: false
|
|
28
|
+
gem 'rb-inotify', '~> 0.9.3', require: false
|
|
28
29
|
|
|
29
30
|
# notification handling
|
|
30
|
-
gem 'libnotify', '~> 0.8.
|
|
31
|
+
gem 'libnotify', '~> 0.8.2', require: false
|
|
31
32
|
gem 'rb-notifu', '~> 0.0.4', require: false
|
|
32
33
|
gem 'terminal-notifier-guard', '~> 1.5.3', require: false
|
|
33
34
|
end
|
|
@@ -36,23 +37,26 @@ group :metrics do
|
|
|
36
37
|
gem 'coveralls', '~> 0.7.0'
|
|
37
38
|
gem 'flay', '~> 2.4.0'
|
|
38
39
|
gem 'flog', '~> 4.2.0'
|
|
39
|
-
gem 'reek', '~> 1.3.
|
|
40
|
-
gem 'rubocop', '~> 0.
|
|
40
|
+
gem 'reek', '~> 1.3.7'
|
|
41
|
+
gem 'rubocop', '~> 0.19.1'
|
|
41
42
|
gem 'simplecov', '~> 0.8.2'
|
|
42
|
-
gem 'yardstick', '~> 0.9.
|
|
43
|
+
gem 'yardstick', '~> 0.9.9'
|
|
44
|
+
|
|
45
|
+
platforms :mri do
|
|
46
|
+
gem 'mutant', '~> 0.5.9'
|
|
47
|
+
gem 'mutant-rspec', '~> 0.5.3'
|
|
48
|
+
end
|
|
43
49
|
|
|
44
50
|
platforms :ruby_19, :ruby_20 do
|
|
45
|
-
gem 'mutant', '~> 0.3.0', git: 'https://github.com/mbj/mutant.git'
|
|
46
|
-
gem 'unparser', '~> 0.1.5', git: 'https://github.com/mbj/unparser.git'
|
|
47
51
|
gem 'yard-spellcheck', '~> 0.1.5'
|
|
48
52
|
end
|
|
49
53
|
|
|
50
54
|
platform :rbx do
|
|
51
55
|
gem 'json', '~> 1.8.1'
|
|
52
|
-
gem 'racc', '~> 1.4.
|
|
56
|
+
gem 'racc', '~> 1.4.11'
|
|
53
57
|
gem 'rubysl-logger', '~> 2.0.0'
|
|
54
58
|
gem 'rubysl-open-uri', '~> 2.0.0'
|
|
55
|
-
gem 'rubysl-prettyprint', '~> 2.0.
|
|
59
|
+
gem 'rubysl-prettyprint', '~> 2.0.3'
|
|
56
60
|
end
|
|
57
61
|
end
|
|
58
62
|
|
data/config/flay.yml
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
---
|
|
2
|
-
threshold: 12
|
|
3
|
-
total_score:
|
|
2
|
+
threshold: 12
|
|
3
|
+
total_score: 195
|
data/config/reek.yml
CHANGED
|
@@ -23,7 +23,7 @@ UncommunicativeMethodName:
|
|
|
23
23
|
- !ruby/regexp /[0-9]$/
|
|
24
24
|
- !ruby/regexp /[A-Z]/
|
|
25
25
|
LongParameterList:
|
|
26
|
-
max_params: 2
|
|
26
|
+
max_params: 2
|
|
27
27
|
exclude:
|
|
28
28
|
- Esearch::Request#initialize # 4 parameters, acceptable it is a DTO
|
|
29
29
|
enabled: true
|
|
@@ -55,10 +55,11 @@ NestedIterators:
|
|
|
55
55
|
max_allowed_nesting: 1
|
|
56
56
|
TooManyStatements:
|
|
57
57
|
max_statements: 5
|
|
58
|
-
exclude:
|
|
58
|
+
exclude:
|
|
59
|
+
- Esearch::Connection#run
|
|
59
60
|
enabled: true
|
|
60
61
|
DuplicateMethodCall:
|
|
61
|
-
allow_calls:
|
|
62
|
+
allow_calls:
|
|
62
63
|
- util.debug
|
|
63
64
|
exclude: []
|
|
64
65
|
enabled: true
|
|
@@ -88,7 +89,7 @@ DataClump:
|
|
|
88
89
|
max_copies: 1
|
|
89
90
|
min_clump_size: 3
|
|
90
91
|
ControlParameter:
|
|
91
|
-
exclude:
|
|
92
|
+
exclude:
|
|
92
93
|
- Esearch::Index#read
|
|
93
94
|
enabled: true
|
|
94
95
|
LongYieldList:
|
data/config/rubocop.yml
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
inherit_from: ../.rubocop.yml
|
|
2
|
+
|
|
3
|
+
# Avoid parameter lists longer than five parameters.
|
|
4
|
+
ParameterLists:
|
|
5
|
+
Max: 5 # For DSL method. Subject specific exclude not available
|
|
6
|
+
CountKeywordArgs: true
|
|
7
|
+
|
|
8
|
+
# Avoid more than `Max` levels of nesting.
|
|
9
|
+
BlockNesting:
|
|
10
|
+
Max: 3
|
|
11
|
+
|
|
12
|
+
# Align with the style guide.
|
|
13
|
+
CollectionMethods:
|
|
14
|
+
PreferredMethods:
|
|
15
|
+
collect: 'map'
|
|
16
|
+
inject: 'reduce'
|
|
17
|
+
find: 'detect'
|
|
18
|
+
find_all: 'select'
|
|
19
|
+
|
|
20
|
+
# Do not force public/protected/private keyword to be indented at the same
|
|
21
|
+
# level as the def keyword. My personal preference is to outdent these keywords
|
|
22
|
+
# because I think when scanning code it makes it easier to identify the
|
|
23
|
+
# sections of code and visually separate them. When the keyword is at the same
|
|
24
|
+
# level I think it sort of blends in with the def keywords and makes it harder
|
|
25
|
+
# to scan the code and see where the sections are.
|
|
26
|
+
AccessModifierIndentation:
|
|
27
|
+
Enabled: false
|
|
28
|
+
|
|
29
|
+
MethodLength:
|
|
30
|
+
CountComments: false
|
|
31
|
+
Max: 17 # TODO: Bring down to 10
|
|
32
|
+
|
|
33
|
+
RegexpLiteral: # I do not agree %r(\A) is more readable than /\A/
|
|
34
|
+
Enabled: false
|
|
35
|
+
|
|
36
|
+
Eval:
|
|
37
|
+
Enabled: false # Mutant must use Kernel#eval to inject mutated source
|
|
38
|
+
|
|
39
|
+
# Limit line length
|
|
40
|
+
LineLength:
|
|
41
|
+
Max: 124 # TODO: lower to 79
|
|
42
|
+
|
|
43
|
+
# Disable documentation checking until a class needs to be documented once
|
|
44
|
+
Documentation:
|
|
45
|
+
Enabled: false
|
|
46
|
+
|
|
47
|
+
# Do not favor modifier if/unless usage when you have a single-line body
|
|
48
|
+
IfUnlessModifier:
|
|
49
|
+
Enabled: false
|
|
50
|
+
|
|
51
|
+
# Mutant needs to define methods like def bar; end in specs
|
|
52
|
+
Semicolon:
|
|
53
|
+
Enabled: false
|
|
54
|
+
|
|
55
|
+
# Mutant needs to define multiple methods on same line in specs
|
|
56
|
+
EmptyLineBetweenDefs:
|
|
57
|
+
Enabled: false
|
|
58
|
+
|
|
59
|
+
# Mutant needs to define singleton methods like Foo.bar in specs
|
|
60
|
+
ClassMethods:
|
|
61
|
+
Enabled: false
|
|
62
|
+
|
|
63
|
+
# Allow case equality operator (in limited use within the specs)
|
|
64
|
+
CaseEquality:
|
|
65
|
+
Enabled: false
|
|
66
|
+
|
|
67
|
+
# Constants do not always have to use SCREAMING_SNAKE_CASE
|
|
68
|
+
ConstantName:
|
|
69
|
+
Enabled: false
|
|
70
|
+
|
|
71
|
+
# Not all trivial readers/writers can be defined with attr_* methods
|
|
72
|
+
TrivialAccessors:
|
|
73
|
+
Enabled: false
|
|
74
|
+
|
|
75
|
+
# And also have a differend opinion here
|
|
76
|
+
AndOr:
|
|
77
|
+
Enabled: false
|
|
78
|
+
|
|
79
|
+
# Allow empty lines around body
|
|
80
|
+
EmptyLinesAroundBody:
|
|
81
|
+
Enabled: false
|
data/esearch.gemspec
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |gem|
|
|
4
4
|
gem.name = 'esearch'
|
|
5
|
-
gem.version = '0.2.
|
|
5
|
+
gem.version = '0.2.2'
|
|
6
6
|
gem.authors = [ 'Markus Schirp' ]
|
|
7
7
|
gem.email = [ 'mbj@schirp-dso.com' ]
|
|
8
8
|
gem.description = 'Esearch driver for ruby'
|
|
@@ -16,11 +16,11 @@ Gem::Specification.new do |gem|
|
|
|
16
16
|
gem.extra_rdoc_files = %w[TODO]
|
|
17
17
|
|
|
18
18
|
gem.add_runtime_dependency('descendants_tracker', '~> 0.0.1')
|
|
19
|
-
gem.add_runtime_dependency('concord', '~> 0.1.
|
|
20
|
-
gem.add_runtime_dependency('faraday', '~> 0.
|
|
21
|
-
gem.add_runtime_dependency('adamantium', '~> 0.
|
|
22
|
-
gem.add_runtime_dependency('equalizer', '~> 0.0.
|
|
23
|
-
gem.add_runtime_dependency('abstract_type', '~> 0.0.
|
|
24
|
-
gem.add_runtime_dependency('multi_json', '~> 1.
|
|
19
|
+
gem.add_runtime_dependency('concord', '~> 0.1.4')
|
|
20
|
+
gem.add_runtime_dependency('faraday', '~> 0.9.0')
|
|
21
|
+
gem.add_runtime_dependency('adamantium', '~> 0.2.0')
|
|
22
|
+
gem.add_runtime_dependency('equalizer', '~> 0.0.9')
|
|
23
|
+
gem.add_runtime_dependency('abstract_type', '~> 0.0.7')
|
|
24
|
+
gem.add_runtime_dependency('multi_json', '~> 1.9.2')
|
|
25
25
|
gem.add_runtime_dependency('null_logger', '~> 0.0.1')
|
|
26
26
|
end
|
data/lib/esearch.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
1
3
|
require 'multi_json'
|
|
2
4
|
require 'faraday'
|
|
3
5
|
require 'adamantium'
|
|
@@ -13,7 +15,7 @@ module Esearch
|
|
|
13
15
|
class RemoteError < StandardError; end
|
|
14
16
|
# Error raised when protocol is violated
|
|
15
17
|
class ProtocolError < StandardError; end
|
|
16
|
-
end
|
|
18
|
+
end # Esearch
|
|
17
19
|
|
|
18
20
|
require 'esearch/request'
|
|
19
21
|
require 'esearch/mixin'
|
data/lib/esearch/cluster.rb
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
1
3
|
module Esearch
|
|
2
4
|
# Handle for an elasticsearch cluster
|
|
3
5
|
class Cluster
|
|
6
|
+
PATH = Pathname.new('/').freeze
|
|
4
7
|
|
|
5
8
|
include Adamantium::Flat, Concord.new(:connection)
|
|
6
9
|
|
|
@@ -55,11 +58,9 @@ module Esearch
|
|
|
55
58
|
# @api private
|
|
56
59
|
#
|
|
57
60
|
def path
|
|
58
|
-
|
|
61
|
+
PATH
|
|
59
62
|
end
|
|
60
63
|
|
|
61
|
-
PATH = Pathname.new('/')
|
|
62
|
-
|
|
63
64
|
# Return handler for all indices
|
|
64
65
|
#
|
|
65
66
|
# @return [Indices::All]
|
|
@@ -81,5 +82,5 @@ module Esearch
|
|
|
81
82
|
new(Connection.build(*args))
|
|
82
83
|
end
|
|
83
84
|
|
|
84
|
-
end
|
|
85
|
-
end
|
|
85
|
+
end # Cluster
|
|
86
|
+
end # Esearch
|
data/lib/esearch/command.rb
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
1
3
|
module Esearch
|
|
2
4
|
# Abstract base class for elasticsearch commands
|
|
3
|
-
class Command
|
|
5
|
+
class Command
|
|
4
6
|
include Adamantium::Flat, AbstractType, Concord.new(:context)
|
|
5
7
|
|
|
6
|
-
EXPECTED_STATI = [
|
|
8
|
+
EXPECTED_STATI = [200].freeze
|
|
7
9
|
JSON_CONTENT_TYPE = 'application/json; charset=UTF-8'.freeze
|
|
8
10
|
|
|
9
11
|
# Run command
|
|
@@ -86,7 +88,7 @@ module Esearch
|
|
|
86
88
|
# Return expected response stati
|
|
87
89
|
#
|
|
88
90
|
# @return [Enumerable<Fixnum>]
|
|
89
|
-
#
|
|
91
|
+
#
|
|
90
92
|
# @api private
|
|
91
93
|
#
|
|
92
94
|
def expected_response_stati
|
|
@@ -112,7 +114,13 @@ module Esearch
|
|
|
112
114
|
# @api private
|
|
113
115
|
#
|
|
114
116
|
def raise_status_error
|
|
115
|
-
|
|
117
|
+
message = format(
|
|
118
|
+
'expected response stati: %s but got: %s, remote message: %s',
|
|
119
|
+
expected_response_stati,
|
|
120
|
+
response.status,
|
|
121
|
+
remote_message.inspect
|
|
122
|
+
)
|
|
123
|
+
fail ProtocolError, message
|
|
116
124
|
end
|
|
117
125
|
|
|
118
126
|
# Return remote message
|
|
@@ -137,7 +145,7 @@ module Esearch
|
|
|
137
145
|
#
|
|
138
146
|
def parsed_json
|
|
139
147
|
unless json_content_type?
|
|
140
|
-
|
|
148
|
+
fail ProtocolError, "Expected json content type, but got: #{content_type.inspect}"
|
|
141
149
|
end
|
|
142
150
|
MultiJson.load(response.body)
|
|
143
151
|
end
|
|
@@ -154,5 +162,5 @@ module Esearch
|
|
|
154
162
|
end
|
|
155
163
|
memoize :response
|
|
156
164
|
|
|
157
|
-
end
|
|
158
|
-
end
|
|
165
|
+
end # Command
|
|
166
|
+
end # Esearch
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
1
3
|
module Esearch
|
|
2
4
|
class Command
|
|
3
5
|
# Base class for cluster commands
|
|
@@ -21,8 +23,8 @@ module Esearch
|
|
|
21
23
|
Request.get('/_cluster/health', {}, options)
|
|
22
24
|
end
|
|
23
25
|
|
|
24
|
-
end
|
|
26
|
+
end # Health
|
|
25
27
|
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
28
|
+
end # Cluster
|
|
29
|
+
end # Command
|
|
30
|
+
end # Esearch
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
1
3
|
module Esearch
|
|
2
4
|
class Command
|
|
3
5
|
|
|
@@ -8,7 +10,7 @@ module Esearch
|
|
|
8
10
|
class Index < self
|
|
9
11
|
include Concord.new(:context, :document, :options)
|
|
10
12
|
|
|
11
|
-
EXPECTED_STATI = [
|
|
13
|
+
EXPECTED_STATI = [200, 201].freeze
|
|
12
14
|
PRESENTER = Presenter::Document::Operation::Index
|
|
13
15
|
|
|
14
16
|
FORCE_OPTIONS = {}
|
|
@@ -37,21 +39,21 @@ module Esearch
|
|
|
37
39
|
|
|
38
40
|
# Document index update command
|
|
39
41
|
class Update < self
|
|
40
|
-
EXPECTED_STATI = [
|
|
41
|
-
FORCE_OPTIONS = { :
|
|
42
|
+
EXPECTED_STATI = [200].freeze
|
|
43
|
+
FORCE_OPTIONS = { op_type: :index }.freeze
|
|
42
44
|
end
|
|
43
45
|
|
|
44
46
|
# Document index create command
|
|
45
47
|
class Create < self
|
|
46
|
-
EXPECTED_STATI = [
|
|
47
|
-
FORCE_OPTIONS = { :
|
|
48
|
+
EXPECTED_STATI = [201].freeze
|
|
49
|
+
FORCE_OPTIONS = { op_type: :create }.freeze
|
|
48
50
|
end
|
|
49
51
|
end
|
|
50
52
|
|
|
51
53
|
# Present get document command result
|
|
52
54
|
class Get < self
|
|
53
|
-
|
|
54
|
-
EXPECTED_STATI = [
|
|
55
|
+
|
|
56
|
+
EXPECTED_STATI = [200, 404].freeze
|
|
55
57
|
PRESENTER = Presenter::Document::Get
|
|
56
58
|
|
|
57
59
|
# Return result
|
|
@@ -68,8 +70,6 @@ module Esearch
|
|
|
68
70
|
assert_success
|
|
69
71
|
if response.status == 200
|
|
70
72
|
presenter.new(parsed_json)
|
|
71
|
-
else
|
|
72
|
-
nil
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
75
|
|
|
@@ -104,8 +104,8 @@ module Esearch
|
|
|
104
104
|
Request.delete(context_path)
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
-
end
|
|
107
|
+
end # Delete
|
|
108
108
|
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|
|
109
|
+
end # Document
|
|
110
|
+
end # Command
|
|
111
|
+
end # Esearch
|