esse 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/lib/esse/cli/event_listener.rb +4 -5
  3. data/lib/esse/cli/generate.rb +14 -16
  4. data/lib/esse/cli/index/close.rb +1 -1
  5. data/lib/esse/cli/index/create.rb +1 -1
  6. data/lib/esse/cli/index/delete.rb +1 -1
  7. data/lib/esse/cli/index/import.rb +2 -2
  8. data/lib/esse/cli/index/open.rb +1 -1
  9. data/lib/esse/cli/index/reset.rb +1 -1
  10. data/lib/esse/cli/index/update_aliases.rb +2 -2
  11. data/lib/esse/cli/index/update_mapping.rb +8 -3
  12. data/lib/esse/cli/index/update_settings.rb +1 -1
  13. data/lib/esse/cli/index.rb +9 -4
  14. data/lib/esse/cli/templates/collection.rb.erb +6 -6
  15. data/lib/esse/cli/templates/{serializer.rb.erb → document.rb.erb} +6 -6
  16. data/lib/esse/cli/templates/index.rb.erb +39 -34
  17. data/lib/esse/cli.rb +5 -0
  18. data/lib/esse/cluster.rb +38 -12
  19. data/lib/esse/core.rb +7 -3
  20. data/lib/esse/deprecations/cluster.rb +5 -5
  21. data/lib/esse/deprecations/deprecate.rb +29 -0
  22. data/lib/esse/deprecations/index.rb +21 -3
  23. data/lib/esse/deprecations/index_backend_delegator.rb +217 -0
  24. data/lib/esse/deprecations/repository.rb +19 -4
  25. data/lib/esse/deprecations/repository_backend_delegator.rb +110 -0
  26. data/lib/esse/deprecations/serializer.rb +14 -0
  27. data/lib/esse/deprecations.rb +4 -0
  28. data/lib/esse/{serializer.rb → document.rb} +17 -2
  29. data/lib/esse/dynamic_template.rb +4 -0
  30. data/lib/esse/errors.rb +8 -1
  31. data/lib/esse/events.rb +13 -5
  32. data/lib/esse/hash_document.rb +1 -1
  33. data/lib/esse/import/bulk.rb +21 -11
  34. data/lib/esse/index/aliases.rb +50 -0
  35. data/lib/esse/index/attributes.rb +14 -5
  36. data/lib/esse/index/base.rb +17 -53
  37. data/lib/esse/index/documents.rb +236 -0
  38. data/lib/esse/index/indices.rb +171 -0
  39. data/lib/esse/index/object_document_mapper.rb +0 -59
  40. data/lib/esse/index/type.rb +2 -3
  41. data/lib/esse/index.rb +4 -3
  42. data/lib/esse/null_document.rb +1 -1
  43. data/lib/esse/repository/{backend.rb → documents.rb} +2 -3
  44. data/lib/esse/repository/object_document_mapper.rb +20 -20
  45. data/lib/esse/repository.rb +1 -2
  46. data/lib/esse/search/query.rb +8 -8
  47. data/lib/esse/template_loader.rb +1 -1
  48. data/lib/esse/transport/aliases.rb +36 -0
  49. data/lib/esse/transport/documents.rb +199 -0
  50. data/lib/esse/transport/health.rb +30 -0
  51. data/lib/esse/transport/indices.rb +192 -0
  52. data/lib/esse/{client_proxy → transport}/search.rb +9 -5
  53. data/lib/esse/transport.rb +44 -0
  54. data/lib/esse/version.rb +1 -1
  55. metadata +28 -28
  56. data/lib/esse/backend/index/aliases.rb +0 -73
  57. data/lib/esse/backend/index/close.rb +0 -54
  58. data/lib/esse/backend/index/create.rb +0 -67
  59. data/lib/esse/backend/index/delete.rb +0 -39
  60. data/lib/esse/backend/index/documents.rb +0 -270
  61. data/lib/esse/backend/index/existance.rb +0 -22
  62. data/lib/esse/backend/index/open.rb +0 -54
  63. data/lib/esse/backend/index/refresh.rb +0 -45
  64. data/lib/esse/backend/index/reset.rb +0 -33
  65. data/lib/esse/backend/index/update.rb +0 -143
  66. data/lib/esse/backend/index.rb +0 -56
  67. data/lib/esse/backend/repository_backend.rb +0 -105
  68. data/lib/esse/client_proxy.rb +0 -32
  69. data/lib/esse/index/backend.rb +0 -14
@@ -1,105 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'forwardable'
4
-
5
- module Esse
6
- module Backend
7
- class RepositoryBackend
8
- extend Forwardable
9
-
10
- # Type delegators
11
- def_delegators :@repo, :document_type, :index, :serialize
12
-
13
- def initialize(repo)
14
- @repo = repo
15
- end
16
-
17
- def import(**kwargs)
18
- elasticsearch.import(document_type, **kwargs)
19
- end
20
-
21
- def import!(**kwargs)
22
- elasticsearch.import!(document_type, **kwargs)
23
- end
24
-
25
- def bulk!(**kwargs)
26
- elasticsearch.bulk!(**kwargs, type: document_type)
27
- end
28
-
29
- def bulk(**kwargs)
30
- elasticsearch.bulk(**kwargs, type: document_type)
31
- end
32
-
33
- def index!(**kwargs)
34
- elasticsearch.index!(**kwargs, type: document_type)
35
- end
36
-
37
- def index(**kwargs)
38
- elasticsearch.index(**kwargs, type: document_type)
39
- end
40
-
41
- # @param [Esse::Serializer] document A document instance
42
- def index_document(document, **kwargs)
43
- return unless document.is_a?(Esse::Serializer)
44
- return if document.ignore_on_index?
45
- return unless document.id
46
-
47
- kwargs[:id] = document.id
48
- kwargs[:routing] = document.routing if document.routing
49
- kwargs[:type] = document.type || document_type
50
- kwargs[:body] = document.source&.to_h
51
- elasticsearch.index(**kwargs)
52
- end
53
-
54
- def update!(**kwargs)
55
- elasticsearch.update!(**kwargs, type: document_type)
56
- end
57
-
58
- def update(**kwargs)
59
- elasticsearch.update(**kwargs, type: document_type)
60
- end
61
-
62
- def delete!(**kwargs)
63
- elasticsearch.delete!(**kwargs, type: document_type)
64
- end
65
-
66
- def delete(**kwargs)
67
- elasticsearch.delete(**kwargs, type: document_type)
68
- end
69
-
70
- # @param [Esse::Serializer] document A document instance
71
- def delete_document(document, **kwargs)
72
- return unless document.is_a?(Esse::Serializer)
73
- return if document.ignore_on_delete?
74
- return unless document.id
75
-
76
- kwargs[:id] = document.id
77
- kwargs[:routing] = document.routing if document.routing
78
- kwargs[:type] = document.type || document_type
79
- elasticsearch.delete(**kwargs)
80
- end
81
-
82
- def exist?(**kwargs)
83
- elasticsearch.exist?(**kwargs, type: document_type)
84
- end
85
-
86
- def count(**kwargs)
87
- elasticsearch.count(**kwargs, type: document_type)
88
- end
89
-
90
- def find!(**kwargs)
91
- elasticsearch.find!(**kwargs, type: document_type)
92
- end
93
-
94
- def find(**kwargs)
95
- elasticsearch.find(**kwargs, type: document_type)
96
- end
97
-
98
- protected
99
-
100
- def elasticsearch
101
- @repo.index.elasticsearch
102
- end
103
- end
104
- end
105
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Esse
4
- class ClientProxy
5
- require_relative './client_proxy/search'
6
-
7
- extend Forwardable
8
-
9
- def_delegators :@cluster, :client
10
-
11
- attr_reader :cluster
12
-
13
- def initialize(cluster)
14
- @cluster = cluster
15
- end
16
-
17
- # Elasticsearch::Transport was renamed to Elastic::Transport in 8.0
18
- # This lib should support both versions that's why we are wrapping up the transport
19
- # errors to local errors.
20
- def coerce_exception
21
- yield
22
- rescue => exception
23
- name = Hstring.new(exception.class.name)
24
- if /^(Elasticsearch|Elastic|OpenSearch)?::Transport::Transport::Errors/.match?(name.value) && \
25
- (exception_class = Esse::Backend::ERRORS[name.demodulize.value])
26
- raise exception_class.new(exception.message)
27
- else
28
- raise exception
29
- end
30
- end
31
- end
32
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Esse
4
- class Index
5
- module ClassMethods
6
- def elasticsearch
7
- Esse::Backend::Index.new(self)
8
- end
9
- alias_method :backend, :elasticsearch
10
- end
11
-
12
- extend ClassMethods
13
- end
14
- end