esse 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tool-versions +1 -0
- data/.yardopts +2 -0
- data/Gemfile.lock +19 -17
- data/bin/console +8 -8
- data/esse.gemspec +2 -1
- data/lib/esse/backend/index.rb +2 -0
- data/lib/esse/backend/index/delete.rb +2 -4
- data/lib/esse/backend/index/refresh.rb +43 -0
- data/lib/esse/backend/index/reset.rb +35 -0
- data/lib/esse/backend/index_type/documents.rb +25 -25
- data/lib/esse/cli/generate.rb +2 -1
- data/lib/esse/cli/templates/index.rb.erb +5 -5
- data/lib/esse/cli/templates/serializer.rb.erb +13 -9
- data/lib/esse/cluster.rb +5 -5
- data/lib/esse/core.rb +3 -3
- data/lib/esse/index_type/serializer.rb +1 -1
- data/lib/esse/version.rb +1 -1
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c1da621c23c6e5ed445c51dc56d789e117874b545dd647e377ca69202d60a3c
|
4
|
+
data.tar.gz: 60c5e597a2ed96b98af47cb90b7e29e4959b3d7dad0d842ea9858d2308a44e75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8e3de9e3f05a9f404eaf80ce334d3d9afb06f33040ef6240db1d3535ec657e32107c25df35c8eede19551c7e4fb162c92e0fb775baea4a743aab64768d3f1b0
|
7
|
+
data.tar.gz: 5863ce26c2aaa3617fa665de6f85309866613f827a1b2a27490808aeb2c9a68e85b0fee7a0e59b0c3353140d5e7cc5062ced0e225728b9ea06048a4e4a2b556b
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.6.2
|
data/.yardopts
ADDED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
esse (0.0.
|
4
|
+
esse (0.0.5)
|
5
5
|
elasticsearch
|
6
6
|
multi_json
|
7
7
|
thor (>= 0.19)
|
@@ -10,40 +10,41 @@ GEM
|
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
12
|
awesome_print (1.8.0)
|
13
|
-
coderay (1.1.
|
14
|
-
diff-lcs (1.
|
13
|
+
coderay (1.1.3)
|
14
|
+
diff-lcs (1.4.4)
|
15
15
|
dotenv (2.7.5)
|
16
|
-
elasticsearch (7.
|
17
|
-
elasticsearch-api (= 7.
|
18
|
-
elasticsearch-transport (= 7.
|
19
|
-
elasticsearch-api (7.
|
16
|
+
elasticsearch (7.8.0)
|
17
|
+
elasticsearch-api (= 7.8.0)
|
18
|
+
elasticsearch-transport (= 7.8.0)
|
19
|
+
elasticsearch-api (7.8.0)
|
20
20
|
multi_json
|
21
|
-
elasticsearch-transport (7.
|
21
|
+
elasticsearch-transport (7.8.0)
|
22
22
|
faraday (~> 1)
|
23
23
|
multi_json
|
24
24
|
faraday (1.0.1)
|
25
25
|
multipart-post (>= 1.2, < 3)
|
26
|
-
method_source (0.
|
27
|
-
multi_json (1.
|
26
|
+
method_source (1.0.0)
|
27
|
+
multi_json (1.15.0)
|
28
28
|
multipart-post (2.1.1)
|
29
|
-
pry (0.
|
30
|
-
coderay (~> 1.1
|
31
|
-
method_source (~>
|
29
|
+
pry (0.13.1)
|
30
|
+
coderay (~> 1.1)
|
31
|
+
method_source (~> 1.0)
|
32
32
|
rake (12.3.3)
|
33
33
|
rspec (3.9.0)
|
34
34
|
rspec-core (~> 3.9.0)
|
35
35
|
rspec-expectations (~> 3.9.0)
|
36
36
|
rspec-mocks (~> 3.9.0)
|
37
|
-
rspec-core (3.9.
|
38
|
-
rspec-support (~> 3.9.
|
39
|
-
rspec-expectations (3.9.
|
37
|
+
rspec-core (3.9.2)
|
38
|
+
rspec-support (~> 3.9.3)
|
39
|
+
rspec-expectations (3.9.2)
|
40
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
41
|
rspec-support (~> 3.9.0)
|
42
42
|
rspec-mocks (3.9.1)
|
43
43
|
diff-lcs (>= 1.2.0, < 2.0)
|
44
44
|
rspec-support (~> 3.9.0)
|
45
|
-
rspec-support (3.9.
|
45
|
+
rspec-support (3.9.3)
|
46
46
|
thor (1.0.1)
|
47
|
+
yard (0.9.25)
|
47
48
|
|
48
49
|
PLATFORMS
|
49
50
|
ruby
|
@@ -55,6 +56,7 @@ DEPENDENCIES
|
|
55
56
|
pry
|
56
57
|
rake (~> 12.3)
|
57
58
|
rspec (~> 3.0)
|
59
|
+
yard (~> 0.9.20)
|
58
60
|
|
59
61
|
BUNDLED WITH
|
60
62
|
2.1.4
|
data/bin/console
CHANGED
@@ -9,14 +9,14 @@ require 'awesome_print'
|
|
9
9
|
Esse.config.clusters.client = { url: ENV.fetch('ELASTICSEARCH_URL', 'http://localhost:9200') }
|
10
10
|
Esse.config.clusters.index_prefix = 'esse_console'
|
11
11
|
|
12
|
-
class ApplicationIndex < Esse::Index
|
13
|
-
|
14
|
-
end
|
15
|
-
class GeosIndex < ApplicationIndex
|
16
|
-
|
12
|
+
# class ApplicationIndex < Esse::Index
|
13
|
+
# self.abstract_class = true
|
14
|
+
# end
|
15
|
+
# class GeosIndex < ApplicationIndex
|
16
|
+
# self.index_version = 'v1'
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
end
|
18
|
+
# define_type :county
|
19
|
+
# define_type :city
|
20
|
+
# end
|
21
21
|
|
22
22
|
Pry.start
|
data/esse.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
25
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
26
|
end
|
27
|
-
spec.bindir = '
|
27
|
+
spec.bindir = 'exec'
|
28
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ['lib']
|
30
30
|
|
@@ -36,4 +36,5 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_development_dependency 'pry'
|
37
37
|
spec.add_development_dependency 'rake', '~> 12.3'
|
38
38
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
39
|
+
spec.add_development_dependency 'yard', '~> 0.9.20'
|
39
40
|
end
|
data/lib/esse/backend/index.rb
CHANGED
@@ -10,6 +10,8 @@ module Esse
|
|
10
10
|
require_relative 'index/delete'
|
11
11
|
require_relative 'index/existance'
|
12
12
|
require_relative 'index/update'
|
13
|
+
require_relative 'index/refresh'
|
14
|
+
require_relative 'index/reset'
|
13
15
|
require_relative 'index/documents'
|
14
16
|
require_relative 'index/open'
|
15
17
|
require_relative 'index/close'
|
@@ -8,8 +8,7 @@ module Esse
|
|
8
8
|
#
|
9
9
|
# UsersIndex.backend.delete_index! # deletes `<prefix_>users<_suffix|_index_version|_timestamp>` index
|
10
10
|
#
|
11
|
-
# @param
|
12
|
-
# @option [String, nil] :suffix The index suffix Use nil if you want to delete the current index.
|
11
|
+
# @param suffix [String, nil] The index suffix Use nil if you want to delete the current index.
|
13
12
|
# @raise [Elasticsearch::Transport::Transport::Errors::NotFound] when index does not exists
|
14
13
|
# @return [Hash] elasticsearch response
|
15
14
|
def delete_index!(suffix:)
|
@@ -20,8 +19,7 @@ module Esse
|
|
20
19
|
#
|
21
20
|
# UsersIndex.backend.delete_index # deletes `<prefix_>users<_suffix|_index_version|_timestamp>` index
|
22
21
|
#
|
23
|
-
# @param
|
24
|
-
# @option [String] :suffix The index suffix. Use nil if you want to delete the current index.
|
22
|
+
# @param suffix [String, nil] The index suffix Use nil if you want to delete the current index.
|
25
23
|
# @return [Hash, false] elasticsearch response, of false in case of error.
|
26
24
|
def delete_index(suffix: index_version)
|
27
25
|
delete_index!(suffix: suffix)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Esse
|
4
|
+
module Backend
|
5
|
+
class Index
|
6
|
+
module InstanceMethods
|
7
|
+
# Performs the refresh operation in one or more indices.
|
8
|
+
#
|
9
|
+
# @note The refresh operation can adversely affect indexing throughput when used too frequently.
|
10
|
+
# @param :suffix [String, nil] :suffix The index suffix. Defaults to the index_version.
|
11
|
+
# A uniq index name will be generated if one index already exist with the given alias.
|
12
|
+
# @param options [Hash] Options hash
|
13
|
+
# @raise [Elasticsearch::Transport::Transport::Errors::BadRequest, Elasticsearch::Transport::Transport::Errors::NotFound]
|
14
|
+
# in case of failure
|
15
|
+
# @return [Hash] the elasticsearch response
|
16
|
+
#
|
17
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-refresh.html
|
18
|
+
def refresh!(suffix: index_version, **options)
|
19
|
+
client.indices.refresh(
|
20
|
+
options.merge(index: index_name(suffix: suffix)),
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Performs the refresh operation in one or more indices.
|
25
|
+
#
|
26
|
+
# @note The refresh operation can adversely affect indexing throughput when used too frequently.
|
27
|
+
# @param :suffix [String, nil] :suffix The index suffix. Defaults to the index_version.
|
28
|
+
# A uniq index name will be generated if one index already exist with the given alias.
|
29
|
+
# @param options [Hash] Options hash
|
30
|
+
# @return [Hash, false] the elasticsearch response, or false in case of failure
|
31
|
+
#
|
32
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-refresh.html
|
33
|
+
def refresh(suffix: index_version, **options)
|
34
|
+
refresh!(suffix: suffix, **options)
|
35
|
+
rescue Elasticsearch::Transport::Transport::ServerError
|
36
|
+
false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
include InstanceMethods
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Esse
|
4
|
+
module Backend
|
5
|
+
class Index
|
6
|
+
module InstanceMethods
|
7
|
+
# Deletes, creates and imports data to the index. Performs zero-downtime index resetting.
|
8
|
+
#
|
9
|
+
# @option options [String, nil] :suffix The index suffix. Defaults to the index_version.
|
10
|
+
# A uniq index name will be generated if one index already exist with the given alias.
|
11
|
+
# @option options [Time] :timeout Explicit operation timeout
|
12
|
+
# @raise [Elasticsearch::Transport::Transport::Errors::BadRequest, Elasticsearch::Transport::Transport::Errors::NotFound]
|
13
|
+
# in case of failure
|
14
|
+
# @return [Hash] the elasticsearch response
|
15
|
+
#
|
16
|
+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html
|
17
|
+
def reset_index!(suffix: index_version, **options)
|
18
|
+
existing = []
|
19
|
+
suffix ||= Esse.timestamp
|
20
|
+
while exist?(suffix: suffix).tap { |exist| existing << suffix if exist }
|
21
|
+
suffix = Esse.timestamp
|
22
|
+
end
|
23
|
+
|
24
|
+
create_index!(suffix: suffix, **options)
|
25
|
+
import!(suffix: suffix, **options)
|
26
|
+
update_aliases!(suffix: suffix)
|
27
|
+
existing.each { |s| delete_index!(suffix: suffix, **options) }
|
28
|
+
true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
include InstanceMethods
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -21,10 +21,10 @@ module Esse
|
|
21
21
|
# This reduces overhead and can greatly increase indexing speed.
|
22
22
|
#
|
23
23
|
# @param options [Hash] Hash of paramenters that will be passed along to elasticsearch request
|
24
|
-
# @
|
25
|
-
# @
|
26
|
-
# @
|
27
|
-
# @
|
24
|
+
# @option [String, nil] :suffix The index suffix. Defaults to the nil.
|
25
|
+
# @option [Array] :index list of serialized documents to be indexed(Optional)
|
26
|
+
# @option [Array] :delete list of serialized documents to be deleted(Optional)
|
27
|
+
# @option [Array] :create list of serialized documents to be created(Optional)
|
28
28
|
# @return [Hash, nil] the elasticsearch response or nil if there is no data.
|
29
29
|
#
|
30
30
|
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-bulk.html
|
@@ -61,9 +61,9 @@ module Esse
|
|
61
61
|
# UsersIndex::User.index(id: 1, body: { name: 'name' }) # { '_id' => 1, ...}
|
62
62
|
#
|
63
63
|
# @param options [Hash] Hash of paramenters that will be passed along to elasticsearch request
|
64
|
-
# @
|
65
|
-
# @
|
66
|
-
# @
|
64
|
+
# @option [String, Integer] :id The `_id` of the elasticsearch document
|
65
|
+
# @option [Hash] :body The JSON document that will be indexed (Required)
|
66
|
+
# @option [String, nil] :suffix The index suffix. Defaults to the nil.
|
67
67
|
# @return [Hash] the elasticsearch response Hash
|
68
68
|
#
|
69
69
|
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-index_.html
|
@@ -79,9 +79,9 @@ module Esse
|
|
79
79
|
# UsersIndex::User.update!(id: 1, body: { doc: { ... } }) # { '_id' => 1, ...}
|
80
80
|
#
|
81
81
|
# @param options [Hash] Hash of paramenters that will be passed along to elasticsearch request
|
82
|
-
# @
|
83
|
-
# @
|
84
|
-
# @
|
82
|
+
# @option [String, Integer] :id The `_id` of the elasticsearch document
|
83
|
+
# @option [Hash] :body the body of the request
|
84
|
+
# @option [String, nil] :suffix The index suffix. Defaults to the nil.
|
85
85
|
# @raise [Elasticsearch::Transport::Transport::Errors::NotFound] when the doc does not exist
|
86
86
|
# @return [Hash] elasticsearch response hash
|
87
87
|
#
|
@@ -97,9 +97,9 @@ module Esse
|
|
97
97
|
# UsersIndex::User.update(id: 1, body: { doc: { ... } }) # { '_id' => 1, ...}
|
98
98
|
#
|
99
99
|
# @param options [Hash] Hash of paramenters that will be passed along to elasticsearch request
|
100
|
-
# @
|
101
|
-
# @
|
102
|
-
# @
|
100
|
+
# @option [String, Integer] :id The `_id` of the elasticsearch document
|
101
|
+
# @option [Hash] :body the body of the request
|
102
|
+
# @option [String, nil] :suffix The index suffix. Defaults to the nil.
|
103
103
|
# @return [Hash, false] the elasticsearch response hash, or false in case of failure
|
104
104
|
#
|
105
105
|
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-update.html
|
@@ -115,8 +115,8 @@ module Esse
|
|
115
115
|
# UsersIndex::User.delete!(id: 'missing') # raise Elasticsearch::Transport::Transport::Errors::NotFound
|
116
116
|
#
|
117
117
|
# @param options [Hash] Hash of paramenters that will be passed along to elasticsearch request
|
118
|
-
# @
|
119
|
-
# @
|
118
|
+
# @option [String, Integer] :id The `_id` of the elasticsearch document
|
119
|
+
# @option [String, nil] :suffix The index suffix. Defaults to the nil.
|
120
120
|
# @raise [Elasticsearch::Transport::Transport::Errors::NotFound] when the doc does not exist
|
121
121
|
# @return [Boolean] true when the operation is successfully completed
|
122
122
|
#
|
@@ -131,8 +131,8 @@ module Esse
|
|
131
131
|
# UsersIndex::User.delete(id: 'missing') # false
|
132
132
|
#
|
133
133
|
# @param options [Hash] Hash of paramenters that will be passed along to elasticsearch request
|
134
|
-
# @
|
135
|
-
# @
|
134
|
+
# @option [String, Integer] :id The `_id` of the elasticsearch document
|
135
|
+
# @option [String, nil] :suffix The index suffix. Defaults to the nil.
|
136
136
|
# @raise [Elasticsearch::Transport::Transport::Errors::NotFound] when the doc does not exist
|
137
137
|
# @return [Boolean] true when the operation is successfully completed
|
138
138
|
#
|
@@ -149,8 +149,8 @@ module Esse
|
|
149
149
|
# UsersIndex::User.count(body: { ... }) # 32
|
150
150
|
#
|
151
151
|
# @param options [Hash] Hash of paramenters that will be passed along to elasticsearch request
|
152
|
-
# @
|
153
|
-
# @
|
152
|
+
# @option [Hash] :body A query to restrict the results specified with the Query DSL (optional)
|
153
|
+
# @option [String, nil] :suffix The index suffix. Defaults to the nil.
|
154
154
|
# @return [Integer] amount of documents found
|
155
155
|
#
|
156
156
|
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-count.html
|
@@ -167,8 +167,8 @@ module Esse
|
|
167
167
|
# UsersIndex::User.exist?(id: 'missing') # false
|
168
168
|
#
|
169
169
|
# @param options [Hash] Hash of paramenters that will be passed along to elasticsearch request
|
170
|
-
# @
|
171
|
-
# @
|
170
|
+
# @option [String, Integer] :id The `_id` of the elasticsearch document
|
171
|
+
# @option [String, nil] :suffix The index suffix. Defaults to the nil.
|
172
172
|
# @return [Boolean] true if the document exists
|
173
173
|
def exist?(id:, suffix: nil, **options)
|
174
174
|
client.exists(options.merge(index: index_name(suffix: suffix), type: type_name, id: id))
|
@@ -180,8 +180,8 @@ module Esse
|
|
180
180
|
# UsersIndex::User.find!(id: 'missing') # raise Elasticsearch::Transport::Transport::Errors::NotFound
|
181
181
|
#
|
182
182
|
# @param options [Hash] Hash of paramenters that will be passed along to elasticsearch request
|
183
|
-
# @
|
184
|
-
# @
|
183
|
+
# @option [String, Integer] :id The `_id` of the elasticsearch document
|
184
|
+
# @option [String, nil] :suffix The index suffix. Defaults to the nil.
|
185
185
|
# @raise [Elasticsearch::Transport::Transport::Errors::NotFound] when the doc does not exist
|
186
186
|
# @return [Hash] The elasticsearch document.
|
187
187
|
#
|
@@ -196,8 +196,8 @@ module Esse
|
|
196
196
|
# UsersIndex::User.find(id: 'missing') # nil
|
197
197
|
#
|
198
198
|
# @param options [Hash] Hash of paramenters that will be passed along to elasticsearch request
|
199
|
-
# @
|
200
|
-
# @
|
199
|
+
# @option [String, Integer] :id The `_id` of the elasticsearch document
|
200
|
+
# @option [String, nil] :suffix The index suffix. Defaults to the nil.
|
201
201
|
# @return [Hash, nil] The elasticsearch document
|
202
202
|
#
|
203
203
|
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-get.html
|
data/lib/esse/cli/generate.rb
CHANGED
@@ -17,11 +17,12 @@ module Esse
|
|
17
17
|
def index(name, *types)
|
18
18
|
ns_path = name.split(NAMESPACE_PATTERN_RE).tap(&:pop)
|
19
19
|
@index_name = Hstring.new(name.to_s).modulize.sub(/Index$/, '') + 'Index'
|
20
|
+
@index_name = Hstring.new(@index_name)
|
20
21
|
@types = types.map { |type| Hstring.new(type) }
|
21
22
|
@base_class = base_index_class(*ns_path)
|
22
23
|
|
23
24
|
base_dir = Esse.config.indices_directory.join(*ns_path)
|
24
|
-
index_name =
|
25
|
+
index_name = @index_name.demodulize.underscore.to_s
|
25
26
|
template(
|
26
27
|
'templates/index.rb.erb',
|
27
28
|
base_dir.join("#{index_name}.rb"),
|
@@ -3,8 +3,8 @@
|
|
3
3
|
class <%= @index_name %> < <%= @base_class %>
|
4
4
|
# plugin :active_record
|
5
5
|
# plugin :sequel
|
6
|
-
<%- @types.each do |type| -%>
|
7
6
|
|
7
|
+
<%- @types.each do |type| -%>
|
8
8
|
define_type :<%= type %> do
|
9
9
|
# Collection
|
10
10
|
# ==========
|
@@ -14,10 +14,10 @@ class <%= @index_name %> < <%= @base_class %>
|
|
14
14
|
# Useful for eager loading data from database or any other repository. Below is an example of a rails like
|
15
15
|
# application could load using activerecord.
|
16
16
|
#
|
17
|
-
# collection do |conditions|
|
17
|
+
# collection do |conditions, &block|
|
18
18
|
# context = {}
|
19
19
|
# <%= type.camelize %>.where(conditions).find_in_batches(batch_size: 5000) do |batch|
|
20
|
-
#
|
20
|
+
# block.call batch, context, ...
|
21
21
|
# end
|
22
22
|
# end
|
23
23
|
#
|
@@ -41,11 +41,11 @@ class <%= @index_name %> < <%= @base_class %>
|
|
41
41
|
# end
|
42
42
|
#
|
43
43
|
# And here you specify your serializer classe.
|
44
|
-
# serializer
|
44
|
+
# serializer Serializers::<%= type.camelize %>Serializer
|
45
45
|
#
|
46
46
|
# You can also serialize the collection entry using a block:
|
47
47
|
#
|
48
|
-
# serializer
|
48
|
+
# serializer do |model, context = {}|
|
49
49
|
# hash = {
|
50
50
|
# name: <%= type %>.name,
|
51
51
|
# }
|
@@ -1,14 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class <%= @index_name
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
class <%= @index_name %> < <%= @base_class %>
|
4
|
+
module Serializers
|
5
|
+
class <%= @type.camelize %>Serializer
|
6
|
+
def initialize(<%= @type %>, *_other)
|
7
|
+
@entity = <%= @type %>
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def as_json
|
11
|
+
{
|
12
|
+
id: @entity.id, # This field is required
|
13
|
+
name: @entity.name,
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
data/lib/esse/cluster.rb
CHANGED
@@ -35,14 +35,14 @@ module Esse
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# Define the elasticsearch client connectio
|
38
|
-
# @param
|
38
|
+
# @param es_client [Elasticsearch::Client, Hash] an instance of elasticsearch/api client or an hash
|
39
39
|
# with the settings that will be used to initialize Elasticsearch::Client
|
40
|
-
def client=(
|
41
|
-
@client = if
|
42
|
-
settings =
|
40
|
+
def client=(es_client)
|
41
|
+
@client = if es_client.is_a?(Hash)
|
42
|
+
settings = es_client.each_with_object({}) { |(k,v), r| r[k.to_sym] = v }
|
43
43
|
Elasticsearch::Client.new(settings)
|
44
44
|
else
|
45
|
-
|
45
|
+
es_client
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
data/lib/esse/core.rb
CHANGED
@@ -48,9 +48,9 @@ module Esse
|
|
48
48
|
|
49
49
|
# Simple helper used to fetch Hash value using Symbol and String keys.
|
50
50
|
#
|
51
|
-
# @param [Hash] the JSON document
|
52
|
-
# @
|
53
|
-
# @
|
51
|
+
# @param hash [Hash] the JSON document
|
52
|
+
# @param delete [Array] Removes the hash key and return its value
|
53
|
+
# @param keep [Array] Fetch the hash key and return its value
|
54
54
|
# @return [Array([Integer, String, nil], Hash)] return the key value and the modified hash
|
55
55
|
def self.doc_id!(hash, delete: %w[_id], keep: %w[id])
|
56
56
|
return unless hash.is_a?(Hash)
|
@@ -71,7 +71,7 @@ module Esse
|
|
71
71
|
|
72
72
|
# Wrap collection data into serialized batches
|
73
73
|
#
|
74
|
-
# @param [*Object] Any argument is allowed here. The collection will be called with same arguments.
|
74
|
+
# @param args [*Object] Any argument is allowed here. The collection will be called with same arguments.
|
75
75
|
# And the serializer will be initialized with those arguments too.
|
76
76
|
# @yield [Array, *Object] serialized collection and method arguments
|
77
77
|
def each_serialized_batch(*args, &block)
|
data/lib/esse/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcos G. Zimmermann
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exec
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05
|
11
|
+
date: 2020-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '3.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: yard
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.9.20
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.9.20
|
125
139
|
description: All the elegance of ruby with the elasticsearch flexibility. This gem
|
126
140
|
is a pretty simple but excential helpers to deal with mapping, indexing, serialization
|
127
141
|
and search.
|
@@ -133,6 +147,8 @@ extra_rdoc_files: []
|
|
133
147
|
files:
|
134
148
|
- ".gitignore"
|
135
149
|
- ".rubocop.yml"
|
150
|
+
- ".tool-versions"
|
151
|
+
- ".yardopts"
|
136
152
|
- CHANGELOG.md
|
137
153
|
- Gemfile
|
138
154
|
- Gemfile.lock
|
@@ -152,6 +168,8 @@ files:
|
|
152
168
|
- lib/esse/backend/index/documents.rb
|
153
169
|
- lib/esse/backend/index/existance.rb
|
154
170
|
- lib/esse/backend/index/open.rb
|
171
|
+
- lib/esse/backend/index/refresh.rb
|
172
|
+
- lib/esse/backend/index/reset.rb
|
155
173
|
- lib/esse/backend/index/update.rb
|
156
174
|
- lib/esse/backend/index_type.rb
|
157
175
|
- lib/esse/backend/index_type/documents.rb
|
@@ -208,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
226
|
- !ruby/object:Gem::Version
|
209
227
|
version: '0'
|
210
228
|
requirements: []
|
211
|
-
rubygems_version: 3.
|
229
|
+
rubygems_version: 3.0.3
|
212
230
|
signing_key:
|
213
231
|
specification_version: 4
|
214
232
|
summary: Pure Ruby toolkit based on official elasticsearch-ruby library. (No! It isn't
|