esse 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/esse/cli/event_listener.rb +4 -5
- data/lib/esse/cli/generate.rb +14 -16
- data/lib/esse/cli/index/close.rb +1 -1
- data/lib/esse/cli/index/create.rb +1 -1
- data/lib/esse/cli/index/delete.rb +1 -1
- data/lib/esse/cli/index/import.rb +2 -2
- data/lib/esse/cli/index/open.rb +1 -1
- data/lib/esse/cli/index/reset.rb +1 -1
- data/lib/esse/cli/index/update_aliases.rb +2 -2
- data/lib/esse/cli/index/update_mapping.rb +8 -3
- data/lib/esse/cli/index/update_settings.rb +1 -1
- data/lib/esse/cli/index.rb +9 -4
- data/lib/esse/cli/templates/collection.rb.erb +6 -6
- data/lib/esse/cli/templates/{serializer.rb.erb → document.rb.erb} +6 -6
- data/lib/esse/cli/templates/index.rb.erb +39 -34
- data/lib/esse/cli.rb +5 -0
- data/lib/esse/cluster.rb +38 -12
- data/lib/esse/core.rb +7 -3
- data/lib/esse/deprecations/cluster.rb +5 -5
- data/lib/esse/deprecations/deprecate.rb +29 -0
- data/lib/esse/deprecations/index.rb +21 -3
- data/lib/esse/deprecations/index_backend_delegator.rb +217 -0
- data/lib/esse/deprecations/repository.rb +19 -4
- data/lib/esse/deprecations/repository_backend_delegator.rb +110 -0
- data/lib/esse/deprecations/serializer.rb +14 -0
- data/lib/esse/deprecations.rb +4 -0
- data/lib/esse/{serializer.rb → document.rb} +17 -2
- data/lib/esse/dynamic_template.rb +4 -0
- data/lib/esse/errors.rb +8 -1
- data/lib/esse/events.rb +13 -5
- data/lib/esse/hash_document.rb +1 -1
- data/lib/esse/import/bulk.rb +21 -11
- data/lib/esse/index/aliases.rb +50 -0
- data/lib/esse/index/attributes.rb +14 -5
- data/lib/esse/index/base.rb +17 -53
- data/lib/esse/index/documents.rb +236 -0
- data/lib/esse/index/indices.rb +171 -0
- data/lib/esse/index/object_document_mapper.rb +0 -59
- data/lib/esse/index/type.rb +2 -3
- data/lib/esse/index.rb +4 -3
- data/lib/esse/null_document.rb +1 -1
- data/lib/esse/repository/{backend.rb → documents.rb} +2 -3
- data/lib/esse/repository/object_document_mapper.rb +20 -20
- data/lib/esse/repository.rb +1 -2
- data/lib/esse/search/query.rb +8 -8
- data/lib/esse/template_loader.rb +1 -1
- data/lib/esse/transport/aliases.rb +36 -0
- data/lib/esse/transport/documents.rb +199 -0
- data/lib/esse/transport/health.rb +30 -0
- data/lib/esse/transport/indices.rb +192 -0
- data/lib/esse/{client_proxy → transport}/search.rb +9 -5
- data/lib/esse/transport.rb +44 -0
- data/lib/esse/version.rb +1 -1
- metadata +28 -28
- data/lib/esse/backend/index/aliases.rb +0 -73
- data/lib/esse/backend/index/close.rb +0 -54
- data/lib/esse/backend/index/create.rb +0 -67
- data/lib/esse/backend/index/delete.rb +0 -39
- data/lib/esse/backend/index/documents.rb +0 -270
- data/lib/esse/backend/index/existance.rb +0 -22
- data/lib/esse/backend/index/open.rb +0 -54
- data/lib/esse/backend/index/refresh.rb +0 -45
- data/lib/esse/backend/index/reset.rb +0 -33
- data/lib/esse/backend/index/update.rb +0 -143
- data/lib/esse/backend/index.rb +0 -56
- data/lib/esse/backend/repository_backend.rb +0 -105
- data/lib/esse/client_proxy.rb +0 -32
- 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
|
data/lib/esse/client_proxy.rb
DELETED
@@ -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
|
data/lib/esse/index/backend.rb
DELETED