esse 0.2.0 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/lib/esse/cli/event_listener.rb +13 -0
  3. data/lib/esse/cli/generate.rb +53 -14
  4. data/lib/esse/cli/index/base_operation.rb +5 -13
  5. data/lib/esse/cli/index/close.rb +1 -1
  6. data/lib/esse/cli/index/create.rb +1 -1
  7. data/lib/esse/cli/index/delete.rb +1 -1
  8. data/lib/esse/cli/index/import.rb +6 -2
  9. data/lib/esse/cli/index/open.rb +1 -1
  10. data/lib/esse/cli/index/reset.rb +1 -1
  11. data/lib/esse/cli/index/update_aliases.rb +2 -2
  12. data/lib/esse/cli/index/update_mapping.rb +9 -5
  13. data/lib/esse/cli/index/update_settings.rb +1 -1
  14. data/lib/esse/cli/index.rb +11 -4
  15. data/lib/esse/cli/templates/collection.rb.erb +29 -0
  16. data/lib/esse/cli/templates/config.rb.erb +13 -3
  17. data/lib/esse/cli/templates/document.rb.erb +34 -0
  18. data/lib/esse/cli/templates/index.rb.erb +63 -114
  19. data/lib/esse/cli/templates/mappings.json +27 -0
  20. data/lib/esse/cli/templates/settings.json +62 -0
  21. data/lib/esse/cli.rb +5 -0
  22. data/lib/esse/cluster.rb +93 -12
  23. data/lib/esse/cluster_engine.rb +42 -0
  24. data/lib/esse/collection.rb +18 -0
  25. data/lib/esse/config.rb +14 -2
  26. data/lib/esse/core.rb +28 -7
  27. data/lib/esse/deprecations/cluster.rb +27 -0
  28. data/lib/esse/deprecations/deprecate.rb +29 -0
  29. data/lib/esse/deprecations/index.rb +37 -0
  30. data/lib/esse/deprecations/index_backend_delegator.rb +217 -0
  31. data/lib/esse/deprecations/repository.rb +34 -0
  32. data/lib/esse/deprecations/repository_backend_delegator.rb +110 -0
  33. data/lib/esse/deprecations/serializer.rb +14 -0
  34. data/lib/esse/deprecations.rb +7 -0
  35. data/lib/esse/document.rb +91 -0
  36. data/lib/esse/dynamic_template.rb +43 -0
  37. data/lib/esse/errors.rb +60 -2
  38. data/lib/esse/events/event.rb +4 -19
  39. data/lib/esse/events.rb +13 -2
  40. data/lib/esse/hash_document.rb +38 -0
  41. data/lib/esse/import/bulk.rb +106 -0
  42. data/lib/esse/import/request_body.rb +60 -0
  43. data/lib/esse/index/aliases.rb +50 -0
  44. data/lib/esse/index/attributes.rb +107 -0
  45. data/lib/esse/index/base.rb +17 -53
  46. data/lib/esse/index/documents.rb +236 -0
  47. data/lib/esse/index/indices.rb +171 -0
  48. data/lib/esse/index/inheritance.rb +30 -0
  49. data/lib/esse/index/mappings.rb +6 -19
  50. data/lib/esse/index/object_document_mapper.rb +36 -0
  51. data/lib/esse/index/plugins.rb +42 -0
  52. data/lib/esse/index/search.rb +27 -0
  53. data/lib/esse/index/settings.rb +2 -2
  54. data/lib/esse/index/type.rb +51 -11
  55. data/lib/esse/index.rb +14 -9
  56. data/lib/esse/index_mapping.rb +10 -2
  57. data/lib/esse/index_setting.rb +3 -1
  58. data/lib/esse/null_document.rb +35 -0
  59. data/lib/esse/plugins.rb +12 -0
  60. data/lib/esse/primitives/hstring.rb +1 -1
  61. data/lib/esse/{index_type → repository}/actions.rb +1 -1
  62. data/lib/esse/repository/documents.rb +13 -0
  63. data/lib/esse/repository/object_document_mapper.rb +157 -0
  64. data/lib/esse/repository.rb +17 -0
  65. data/lib/esse/search/query.rb +105 -0
  66. data/lib/esse/search/response.rb +46 -0
  67. data/lib/esse/template_loader.rb +1 -1
  68. data/lib/esse/transport/aliases.rb +36 -0
  69. data/lib/esse/transport/documents.rb +199 -0
  70. data/lib/esse/transport/health.rb +30 -0
  71. data/lib/esse/transport/indices.rb +192 -0
  72. data/lib/esse/transport/search.rb +48 -0
  73. data/lib/esse/transport.rb +44 -0
  74. data/lib/esse/version.rb +1 -1
  75. data/lib/esse.rb +20 -5
  76. metadata +55 -50
  77. data/lib/esse/backend/index/aliases.rb +0 -73
  78. data/lib/esse/backend/index/close.rb +0 -54
  79. data/lib/esse/backend/index/create.rb +0 -67
  80. data/lib/esse/backend/index/delete.rb +0 -39
  81. data/lib/esse/backend/index/documents.rb +0 -23
  82. data/lib/esse/backend/index/existance.rb +0 -22
  83. data/lib/esse/backend/index/open.rb +0 -54
  84. data/lib/esse/backend/index/refresh.rb +0 -43
  85. data/lib/esse/backend/index/reset.rb +0 -33
  86. data/lib/esse/backend/index/update.rb +0 -143
  87. data/lib/esse/backend/index.rb +0 -54
  88. data/lib/esse/backend/index_type/documents.rb +0 -214
  89. data/lib/esse/backend/index_type.rb +0 -37
  90. data/lib/esse/cli/templates/type_collection.rb.erb +0 -41
  91. data/lib/esse/cli/templates/type_mappings.json +0 -6
  92. data/lib/esse/cli/templates/type_serializer.rb.erb +0 -23
  93. data/lib/esse/index/backend.rb +0 -14
  94. data/lib/esse/index/naming.rb +0 -64
  95. data/lib/esse/index_type/backend.rb +0 -14
  96. data/lib/esse/index_type/mappings.rb +0 -42
  97. data/lib/esse/index_type.rb +0 -15
  98. data/lib/esse/object_document_mapper.rb +0 -110
@@ -0,0 +1,192 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Esse
4
+ class Transport
5
+ module InstanceMethods
6
+ # Creates an index with optional settings and mappings.
7
+ #
8
+ # @param options [Hash] Options hash
9
+ # @option [String] :index The name of the index
10
+ # @option [String] :wait_for_active_shards Set the number of active shards to wait for before the operation returns.
11
+ # @option [Time] :timeout Explicit operation timeout
12
+ # @option [Time] :master_timeout Specify timeout for connection to master
13
+ # @option [Hash] :headers Custom HTTP headers
14
+ # @option [Hash] :body The configuration for the index (`settings` and `mappings`)
15
+ # @option [String] :wait_for_status Wait until cluster is in a specific state (options: green, yellow, red)
16
+ #
17
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html
18
+ def create_index(index:, wait_for_status: nil, **options)
19
+ throw_error_when_readonly!
20
+
21
+ Esse::Events.instrument('elasticsearch.create_index') do |payload|
22
+ payload[:request] = opts = options.merge(index: index)
23
+ payload[:response] = response = coerce_exception { client.indices.create(**opts) }
24
+ if response && response['acknowledged']
25
+ coerce_exception do
26
+ cluster.wait_for_status!(status: (wait_for_status || cluster.wait_for_status), index: index)
27
+ end
28
+ end
29
+ response
30
+ end
31
+ end
32
+
33
+ # Returns information about whether a particular index exists.
34
+ #
35
+ # @option [List] :index A comma-separated list of index names
36
+ # @option [Boolean] :local Return local information, do not retrieve the state from master node (default: false)
37
+ # @option [Boolean] :ignore_unavailable Ignore unavailable indexes (default: false)
38
+ # @option [Boolean] :allow_no_indices Ignore if a wildcard expression resolves to no concrete indices (default: false)
39
+ # @option [String] :expand_wildcards Whether wildcard expressions should get expanded to open or closed indices (default: open) (options: open, closed, hidden, none, all)
40
+ # @option [Boolean] :flat_settings Return settings in flat format (default: false)
41
+ # @option [Boolean] :include_defaults Whether to return all default setting for each of the indices.
42
+ # @option [Hash] :headers Custom HTTP headers
43
+ #
44
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-exists.html
45
+ def index_exist?(index:, **options)
46
+ Esse::Events.instrument('elasticsearch.index_exist') do |payload|
47
+ payload[:request] = opts = options.merge(index: index)
48
+ payload[:response] = coerce_exception { client.indices.exists(**opts) }
49
+ end
50
+ end
51
+
52
+ # Deletes an index.
53
+ #
54
+ # @option [List] :index A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices
55
+ # @option [Time] :timeout Explicit operation timeout
56
+ # @option [Time] :master_timeout Specify timeout for connection to master
57
+ # @option [Boolean] :ignore_unavailable Ignore unavailable indexes (default: false)
58
+ # @option [Boolean] :allow_no_indices Ignore if a wildcard expression resolves to no concrete indices (default: false)
59
+ # @option [String] :expand_wildcards Whether wildcard expressions should get expanded to open, closed, or hidden indices (options: open, closed, hidden, none, all)
60
+ # @option [Hash] :headers Custom HTTP headers
61
+ # @option [String] :wait_for_status Wait until cluster is in a specific state (options: green, yellow, red)
62
+ #
63
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html
64
+ def delete_index(index:, wait_for_status: nil, **options)
65
+ throw_error_when_readonly!
66
+
67
+ Esse::Events.instrument('elasticsearch.delete_index') do |payload|
68
+ payload[:request] = opts = options.merge(index: index)
69
+ payload[:response] = response = coerce_exception { client.indices.delete(**opts) }
70
+ if response && response['acknowledged']
71
+ coerce_exception do
72
+ cluster.wait_for_status!(status: (wait_for_status || cluster.wait_for_status), index: index)
73
+ end
74
+ end
75
+ response
76
+ end
77
+ end
78
+
79
+ # Open a previously closed index
80
+ #
81
+ # @option options [List] :index A comma separated list of indices to open
82
+ # @option options [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
83
+ # are open, closed or both. (options: open, closed)
84
+ # @option options [String] :ignore_indices When performed on multiple indices, allows to ignore
85
+ # `missing` ones (options: none, missing) @until 1.0
86
+ # @option options [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
87
+ # unavailable (missing, closed, etc)
88
+ # @option options [Time] :timeout Explicit operation timeout
89
+ # @raise [Esse::Transport::ServerError]
90
+ # in case of failure
91
+ # @return [Hash] the elasticsearch response
92
+ #
93
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-open.html
94
+ def open(index:, **options)
95
+ throw_error_when_readonly!
96
+
97
+ Esse::Events.instrument('elasticsearch.open') do |payload|
98
+ payload[:request] = attributes = options.merge(index: index)
99
+ payload[:response] = coerce_exception { client.indices.open(**attributes) }
100
+ end
101
+ end
102
+
103
+ # Close an index (keep the data on disk, but deny operations with the index).
104
+ #
105
+ # @option options [List] :index A comma separated list of indices to open
106
+ # @option options [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
107
+ # are open, closed or both. (options: open, closed)
108
+ # @option options [String] :ignore_indices When performed on multiple indices, allows to ignore
109
+ # `missing` ones (options: none, missing) @until 1.0
110
+ # @option options [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
111
+ # unavailable (missing, closed, etc)
112
+ # @option options [Time] :timeout Explicit operation timeout
113
+ # @raise [Esse::Transport::ServerError] in case of failure
114
+ # @return [Hash] the elasticsearch response
115
+ #
116
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html
117
+ def close(index:, **options)
118
+ throw_error_when_readonly!
119
+
120
+ Esse::Events.instrument('elasticsearch.close') do |payload|
121
+ payload[:request] = attributes = options.merge(index: index)
122
+ payload[:response] = coerce_exception { client.indices.close(**attributes) }
123
+ end
124
+ end
125
+
126
+ # Performs the refresh operation in one or more indices.
127
+ #
128
+ # @option options [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
129
+ # @option options [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
130
+ # @option options [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
131
+ # @option options [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
132
+ # @option options [Hash] :headers Custom HTTP headers
133
+ #
134
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html
135
+ def refresh(index:, **options)
136
+ throw_error_when_readonly!
137
+
138
+ Esse::Events.instrument('elasticsearch.refresh') do |payload|
139
+ payload[:request] = attributes = options.merge(index: index)
140
+ payload[:response] = coerce_exception { client.indices.refresh(**attributes) }
141
+ end
142
+ end
143
+
144
+ # Updates the index mappings.
145
+ #
146
+ # @option options [List] :index A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices.
147
+ # @option options [Time] :timeout Explicit operation timeout
148
+ # @option options [Time] :master_timeout Specify timeout for connection to master
149
+ # @option options [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
150
+ # @option options [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
151
+ # @option options [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
152
+ # @option options [Boolean] :write_index_only When true, applies mappings only to the write index of an alias or data stream
153
+ # @option options [Hash] :headers Custom HTTP headers
154
+ # @option options [Hash] :body The mapping definition (*Required*)
155
+ #
156
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html
157
+ def update_mapping(index:, body:, **options)
158
+ throw_error_when_readonly!
159
+
160
+ Esse::Events.instrument('elasticsearch.update_mapping') do |payload|
161
+ payload[:request] = opts = options.merge(index: index, body: body)
162
+ payload[:response] = coerce_exception { client.indices.put_mapping(**opts) }
163
+ end
164
+ end
165
+
166
+ # Updates the index settings.
167
+ #
168
+ # @option options [List] :index A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
169
+ # @option options [Time] :master_timeout Specify timeout for connection to master
170
+ # @option options [Time] :timeout Explicit operation timeout
171
+ # @option options [Boolean] :preserve_existing Whether to update existing settings. If set to `true` existing settings on an index remain unchanged, the default is `false`
172
+ # @option options [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
173
+ # @option options [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
174
+ # @option options [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
175
+ # @option options [Boolean] :flat_settings Return settings in flat format (default: false)
176
+ # @option options [Hash] :headers Custom HTTP headers
177
+ # @option options [Hash] :body The index settings to be updated (*Required*)
178
+ #
179
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html
180
+ def update_settings(index:, body:, **options)
181
+ throw_error_when_readonly!
182
+
183
+ Esse::Events.instrument('elasticsearch.update_settings') do |payload|
184
+ payload[:request] = opts = options.merge(index: index, body: body)
185
+ payload[:response] = coerce_exception { client.indices.put_settings(**opts) }
186
+ end
187
+ end
188
+ end
189
+
190
+ include InstanceMethods
191
+ end
192
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Esse
4
+ class Transport
5
+ module InstanceMethods
6
+ # Returns results matching a query.
7
+ # @param [Hash] options
8
+ # @option [String] :index The comma-separated list of index names to search; use `_all` to perform the operation on all indices
9
+ def search(index:, **options)
10
+ definition = options.merge(
11
+ index: index,
12
+ )
13
+
14
+ Esse::Events.instrument('elasticsearch.search') do |payload|
15
+ payload[:request] = definition
16
+ payload[:response] = coerce_exception { client.search(definition) }
17
+ end
18
+ end
19
+
20
+ # Allows to retrieve a large numbers of results from a single search request.
21
+ #
22
+ # @param [Hash] options
23
+ # @option [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search
24
+ # @option [Boolean] :rest_total_hits_as_int Indicates whether hits.total should be rendered as an integer or an object in the rest search response
25
+ # @option [Hash] :body The scroll ID
26
+ def scroll(scroll:, **definition)
27
+ unless definition[:body]
28
+ raise ArgumentError, 'scroll search must have a :body with the :scroll_id'
29
+ end
30
+ Esse::Events.instrument('elasticsearch.search') do |payload|
31
+ payload[:request] = definition
32
+ payload[:response] = coerce_exception { client.scroll(scroll: scroll, **definition) }
33
+ end
34
+ end
35
+
36
+ # Explicitly clears the search context for a scroll.
37
+ #
38
+ # @param [Hash] options
39
+ # @option [Hash] :body Body with the "scroll_id" (string or array of strings) Scroll IDs to clear.
40
+ # To clear all scroll IDs, use _all.
41
+ def clear_scroll(body:, **options)
42
+ coerce_exception { client.clear_scroll(body: body, **options) }
43
+ end
44
+ end
45
+
46
+ include InstanceMethods
47
+ end
48
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Esse
4
+ class Transport
5
+ require_relative './transport/aliases'
6
+ require_relative './transport/health'
7
+ require_relative './transport/indices'
8
+ require_relative './transport/search'
9
+ require_relative './transport/documents'
10
+
11
+ extend Forwardable
12
+
13
+ def_delegators :@cluster, :client, :throw_error_when_readonly!
14
+
15
+ attr_reader :cluster
16
+
17
+ def initialize(cluster)
18
+ @cluster = cluster
19
+ end
20
+
21
+ # Elasticsearch::Transport was renamed to Elastic::Transport in 8.0
22
+ # This lib should support both versions that's why we are wrapping up the transport
23
+ # errors to local errors.
24
+ #
25
+ # We are not only coercing exceptions but also the response body. Elasticsearch-ruby >= 8.0 returns
26
+ # the response wrapped in a Elasticsearch::API::Response::Response object. We are unwrapping it
27
+ # to keep the same interface. But we may want to coerce it to some internal object in the future.
28
+ def coerce_exception
29
+ resp = yield
30
+ if resp.class.name.start_with?('Elasticsearch::API::Response')
31
+ resp = resp.body
32
+ end
33
+ resp
34
+ rescue => exception
35
+ name = Hstring.new(exception.class.name)
36
+ if /^(Elasticsearch|Elastic|OpenSearch)?::Transport::Transport::Errors/.match?(name.value) && \
37
+ (exception_class = Esse::Transport::ERRORS[name.demodulize.value])
38
+ raise exception_class.new(exception.message)
39
+ else
40
+ raise exception
41
+ end
42
+ end
43
+ end
44
+ end
data/lib/esse/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Esse
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.3'
5
5
  end
data/lib/esse.rb CHANGED
@@ -1,12 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'esse/core'
4
- require_relative 'esse/errors'
5
- require_relative 'esse/index'
3
+ require 'multi_json'
4
+ require 'forwardable'
5
+
6
+ begin
7
+ require 'elasticsearch'
8
+ rescue LoadError
9
+ end
10
+
11
+ begin
12
+ require 'opensearch'
13
+ rescue LoadError
14
+ end
6
15
 
7
16
  module Esse
8
- SETTING_ROOT_KEY = 'settings'
9
- MAPPING_ROOT_KEY = 'mappings'
17
+ SETTING_ROOT_KEY = :settings
18
+ MAPPING_ROOT_KEY = :mappings
19
+ DEFAULT_REPO_NAME = 'default'
10
20
  CLI_IGNORE_OPTS = %i[
11
21
  require
12
22
  silent
@@ -17,3 +27,8 @@ module Esse
17
27
  config/initializers/esse.rb
18
28
  ].freeze
19
29
  end
30
+
31
+ require_relative 'esse/plugins'
32
+ require_relative 'esse/core'
33
+ require_relative 'esse/errors'
34
+ require_relative 'esse/index'
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos G. Zimmermann
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exec
10
10
  cert_chain: []
11
- date: 2022-03-22 00:00:00.000000000 Z
11
+ date: 2023-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: elasticsearch
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: multi_json
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +100,14 @@ dependencies:
114
100
  requirements:
115
101
  - - "~>"
116
102
  - !ruby/object:Gem::Version
117
- version: '3.0'
103
+ version: '3.12'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
108
  - - "~>"
123
109
  - !ruby/object:Gem::Version
124
- version: '3.0'
110
+ version: '3.12'
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: webmock
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -212,9 +198,11 @@ dependencies:
212
198
  - - "~>"
213
199
  - !ruby/object:Gem::Version
214
200
  version: '2.4'
215
- description: All the elegance of ruby with the elasticsearch flexibility. This gem
216
- is a pretty simple but excential helpers to deal with mapping, indexing, serialization
217
- and search.
201
+ description: With all elegance of Ruby and ElasticSearch flexibility this gem brings
202
+ to you the best of both worlds. Provides a solid architecture allowing to easily
203
+ Extract, Transform, Enrich and Load data from any data source into ElasticSearch/OpenSearch
204
+ and also to search it. It is framework-agnostic, which means you can use it with
205
+ any Ruby framework or even without any framework at all.
218
206
  email:
219
207
  - mgzmaster@gmail.com
220
208
  executables:
@@ -224,19 +212,6 @@ extra_rdoc_files: []
224
212
  files:
225
213
  - exec/esse
226
214
  - lib/esse.rb
227
- - lib/esse/backend/index.rb
228
- - lib/esse/backend/index/aliases.rb
229
- - lib/esse/backend/index/close.rb
230
- - lib/esse/backend/index/create.rb
231
- - lib/esse/backend/index/delete.rb
232
- - lib/esse/backend/index/documents.rb
233
- - lib/esse/backend/index/existance.rb
234
- - lib/esse/backend/index/open.rb
235
- - lib/esse/backend/index/refresh.rb
236
- - lib/esse/backend/index/reset.rb
237
- - lib/esse/backend/index/update.rb
238
- - lib/esse/backend/index_type.rb
239
- - lib/esse/backend/index_type/documents.rb
240
215
  - lib/esse/cli.rb
241
216
  - lib/esse/cli/base.rb
242
217
  - lib/esse/cli/event_listener.rb
@@ -252,42 +227,72 @@ files:
252
227
  - lib/esse/cli/index/update_aliases.rb
253
228
  - lib/esse/cli/index/update_mapping.rb
254
229
  - lib/esse/cli/index/update_settings.rb
230
+ - lib/esse/cli/templates/collection.rb.erb
255
231
  - lib/esse/cli/templates/config.rb.erb
232
+ - lib/esse/cli/templates/document.rb.erb
256
233
  - lib/esse/cli/templates/index.rb.erb
257
- - lib/esse/cli/templates/type_collection.rb.erb
258
- - lib/esse/cli/templates/type_mappings.json
259
- - lib/esse/cli/templates/type_serializer.rb.erb
234
+ - lib/esse/cli/templates/mappings.json
235
+ - lib/esse/cli/templates/settings.json
260
236
  - lib/esse/cluster.rb
237
+ - lib/esse/cluster_engine.rb
238
+ - lib/esse/collection.rb
261
239
  - lib/esse/config.rb
262
240
  - lib/esse/core.rb
241
+ - lib/esse/deprecations.rb
242
+ - lib/esse/deprecations/cluster.rb
243
+ - lib/esse/deprecations/deprecate.rb
244
+ - lib/esse/deprecations/index.rb
245
+ - lib/esse/deprecations/index_backend_delegator.rb
246
+ - lib/esse/deprecations/repository.rb
247
+ - lib/esse/deprecations/repository_backend_delegator.rb
248
+ - lib/esse/deprecations/serializer.rb
249
+ - lib/esse/document.rb
250
+ - lib/esse/dynamic_template.rb
263
251
  - lib/esse/errors.rb
264
252
  - lib/esse/events.rb
265
253
  - lib/esse/events/bus.rb
266
254
  - lib/esse/events/event.rb
267
255
  - lib/esse/events/publisher.rb
256
+ - lib/esse/hash_document.rb
257
+ - lib/esse/import/bulk.rb
258
+ - lib/esse/import/request_body.rb
268
259
  - lib/esse/index.rb
269
260
  - lib/esse/index/actions.rb
270
- - lib/esse/index/backend.rb
261
+ - lib/esse/index/aliases.rb
262
+ - lib/esse/index/attributes.rb
271
263
  - lib/esse/index/base.rb
272
264
  - lib/esse/index/descendants.rb
265
+ - lib/esse/index/documents.rb
266
+ - lib/esse/index/indices.rb
273
267
  - lib/esse/index/inheritance.rb
274
268
  - lib/esse/index/mappings.rb
275
- - lib/esse/index/naming.rb
269
+ - lib/esse/index/object_document_mapper.rb
270
+ - lib/esse/index/plugins.rb
271
+ - lib/esse/index/search.rb
276
272
  - lib/esse/index/settings.rb
277
273
  - lib/esse/index/type.rb
278
274
  - lib/esse/index_mapping.rb
279
275
  - lib/esse/index_setting.rb
280
- - lib/esse/index_type.rb
281
- - lib/esse/index_type/actions.rb
282
- - lib/esse/index_type/backend.rb
283
- - lib/esse/index_type/mappings.rb
284
276
  - lib/esse/logging.rb
285
- - lib/esse/object_document_mapper.rb
277
+ - lib/esse/null_document.rb
278
+ - lib/esse/plugins.rb
286
279
  - lib/esse/primitives.rb
287
280
  - lib/esse/primitives/hash_utils.rb
288
281
  - lib/esse/primitives/hstring.rb
289
282
  - lib/esse/primitives/output.rb
283
+ - lib/esse/repository.rb
284
+ - lib/esse/repository/actions.rb
285
+ - lib/esse/repository/documents.rb
286
+ - lib/esse/repository/object_document_mapper.rb
287
+ - lib/esse/search/query.rb
288
+ - lib/esse/search/response.rb
290
289
  - lib/esse/template_loader.rb
290
+ - lib/esse/transport.rb
291
+ - lib/esse/transport/aliases.rb
292
+ - lib/esse/transport/documents.rb
293
+ - lib/esse/transport/health.rb
294
+ - lib/esse/transport/indices.rb
295
+ - lib/esse/transport/search.rb
291
296
  - lib/esse/version.rb
292
297
  homepage: https://github.com/marcosgz/esse
293
298
  licenses:
@@ -296,7 +301,7 @@ metadata:
296
301
  homepage_uri: https://github.com/marcosgz/esse
297
302
  source_code_uri: https://github.com/marcosgz/esse
298
303
  changelog_uri: https://github.com/marcosgz/esse/blob/master/CHANGELOG.md
299
- post_install_message:
304
+ post_install_message:
300
305
  rdoc_options: []
301
306
  require_paths:
302
307
  - lib
@@ -311,9 +316,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
311
316
  - !ruby/object:Gem::Version
312
317
  version: '0'
313
318
  requirements: []
314
- rubygems_version: 3.0.3.1
315
- signing_key:
319
+ rubygems_version: 3.2.32
320
+ signing_key:
316
321
  specification_version: 4
317
- summary: Pure Ruby toolkit based on official elasticsearch-ruby library. (No! It isn't
318
- a new DSL)
322
+ summary: Pure Ruby and framework-agnostic ElasticSearch/OpenSearch toolkit for building
323
+ indexers and searchers
319
324
  test_files: []
@@ -1,73 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Esse
4
- module Backend
5
- class Index
6
- module InstanceMethods
7
- # Return a list of index aliases.
8
- #
9
- # @param options [Hash] Hash of paramenters that will be passed along to elasticsearch request
10
- # @param options [Array] :index list of serialized documents to be indexed(Optional)
11
- #
12
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/indices-aliases.html
13
- def aliases(**options)
14
- response = client.indices.get_alias({ index: index_name, name: '*' }.merge(options))
15
- idx_name = response.keys.find { |idx| idx.start_with?(index_name) }
16
- return [] unless idx_name
17
-
18
- response.dig(idx_name, 'aliases')&.keys || []
19
- rescue Elasticsearch::Transport::Transport::Errors::NotFound
20
- []
21
- end
22
-
23
- # Returns a list of indices.
24
- #
25
- # @param options [Hash] Hash of paramenters that will be passed along to elasticsearch request
26
- # @return [Array] list of indices that match with `index_name`.
27
- def indices(**options)
28
- client.indices.get_alias({ name: index_name }.merge(options)).keys
29
- rescue Elasticsearch::Transport::Transport::Errors::NotFound
30
- []
31
- end
32
-
33
- # Replaces all existing aliases by the respective suffixed index from argument.
34
- #
35
- # @param options [Hash] Hash of paramenters that will be passed along to elasticsearch request
36
- # @option [String] :suffix The suffix of the index used for versioning.
37
- # @raise [Elasticsearch::Transport::Transport::Errors::NotFound] in case of failure
38
- # @return [Hash] the elasticsearch response
39
- def update_aliases!(suffix:, **options)
40
- raise(ArgumentError, 'index suffix cannot be nil') if suffix.nil?
41
-
42
- options[:body] = {
43
- actions: [
44
- *indices.map do |index|
45
- { remove: { index: index, alias: index_name } }
46
- end,
47
- { add: {index: build_real_index_name(suffix), alias: index_name } }
48
- ],
49
- }
50
-
51
- Esse::Events.instrument('elasticsearch.update_aliases') do |payload|
52
- payload[:request] = options
53
- payload[:response] = client.indices.update_aliases(options)
54
- end
55
- end
56
-
57
- # Replaces all existing aliases by the respective suffixed index from argument.
58
- #
59
- # @param options [Hash] Hash of paramenters that will be passed along to elasticsearch request
60
- # @option [String] :suffix The suffix of the index used for versioning.
61
- # @raise [Elasticsearch::Transport::Transport::Errors::NotFound] in case of failure
62
- # @return [Hash] the elasticsearch response, or an hash with 'errors' as true in case of failure
63
- def update_aliases(suffix:, **options)
64
- update_aliases!(suffix: suffix, **options)
65
- rescue Elasticsearch::Transport::Transport::Errors::NotFound
66
- { 'errors' => true }
67
- end
68
- end
69
-
70
- include InstanceMethods
71
- end
72
- end
73
- end
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Esse
4
- module Backend
5
- class Index
6
- module InstanceMethods
7
- # Close an index (keep the data on disk, but deny operations with the index).
8
- #
9
- # @option options [String, nil] :suffix The index suffix. Defaults to the index_version.
10
- # Use nil if you want to check existence of the `index_name` index or alias.
11
- # @option options [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
12
- # are open, closed or both. (options: open, closed)
13
- # @option options [String] :ignore_indices When performed on multiple indices, allows to ignore
14
- # `missing` ones (options: none, missing) @until 1.0
15
- # @option options [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
16
- # unavailable (missing, closed, etc)
17
- # @option options [Time] :timeout Explicit operation timeout
18
- # @raise [Elasticsearch::Transport::Transport::Errors::BadRequest, Elasticsearch::Transport::Transport::Errors::NotFound]
19
- # in case of failure
20
- # @return [Hash] the elasticsearch response
21
- #
22
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html
23
- def close!(suffix: index_version, **options)
24
- Esse::Events.instrument('elasticsearch.close') do |payload|
25
- payload[:request] = attributes = options.merge(index: index_name(suffix: suffix))
26
- payload[:response] = client.indices.close(**attributes)
27
- end
28
- end
29
-
30
- # Close an index (keep the data on disk, but deny operations with the index).
31
- #
32
- # @option options [String, nil] :suffix The index suffix. Defaults to the index_version.
33
- # Use nil if you want to check existence of the `index_name` index or alias.
34
- # @option options [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that
35
- # are open, closed or both. (options: open, closed)
36
- # @option options [String] :ignore_indices When performed on multiple indices, allows to ignore
37
- # `missing` ones (options: none, missing) @until 1.0
38
- # @option options [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
39
- # unavailable (missing, closed, etc)
40
- # @option options [Time] :timeout Explicit operation timeout
41
- # @return [Hash] the elasticsearch response, or an hash with 'errors' as true in case of failure
42
- #
43
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html
44
- def close(suffix: index_version, **options)
45
- close!(suffix: suffix, **options)
46
- rescue Elasticsearch::Transport::Transport::ServerError
47
- { 'errors' => true }
48
- end
49
- end
50
-
51
- include InstanceMethods
52
- end
53
- end
54
- end