esse 0.1.1 → 0.1.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/lib/esse/cli/index/import.rb +26 -0
- data/lib/esse/cli/index.rb +8 -0
- data/lib/esse/cli/templates/type_collection.rb.erb +6 -6
- data/lib/esse/primitives/hash_utils.rb +11 -0
- data/lib/esse/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dff3560f305debeee691263267e43df0e70a17591f6ecfc897025a5c07ada8a
|
4
|
+
data.tar.gz: a8ba452b0bfc81210f104293f852ecacaef585ea23b2e8f24177197fa2555e69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73bfc1a130c18df947cd02120087eed2b571fa174b84009b687dc0e343697aec1a1a20ae00eb0fc8465a9ad603d95318c02d324b98fe811baddc0b08d3533e28
|
7
|
+
data.tar.gz: 160aaf9fdef9da05108c1e966cfc03a45f9357aeb4682d551458546f66dc067d0585e52f0836aa0b4ee8fb5d634d3b705bced6340e91a99013d571fcded5f574
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'base_operation'
|
4
|
+
|
5
|
+
module Esse
|
6
|
+
module CLI
|
7
|
+
class Index::Import < Index::BaseOperation
|
8
|
+
def run
|
9
|
+
validate_options!
|
10
|
+
indices.each do |index|
|
11
|
+
index.elasticsearch.import!(**options)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def options
|
18
|
+
@options.slice(*@options.keys - CLI_IGNORE_OPTS)
|
19
|
+
end
|
20
|
+
|
21
|
+
def validate_options!
|
22
|
+
validate_indices_option!
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/esse/cli/index.rb
CHANGED
@@ -77,6 +77,14 @@ module Esse
|
|
77
77
|
require_relative 'index/open'
|
78
78
|
Open.new(indices: index_classes, **options.to_h.transform_keys(&:to_sym)).run
|
79
79
|
end
|
80
|
+
|
81
|
+
desc 'import *INDEX_CLASSES', 'Import documents from the given classes'
|
82
|
+
option :suffix, type: :string, default: nil, aliases: '-s', desc: 'Suffix to append to index name'
|
83
|
+
option :context, type: :hash, default: {}, required: true, desc: 'List of options to pass to the index class'
|
84
|
+
def import(*index_classes)
|
85
|
+
require_relative 'index/import'
|
86
|
+
Import.new(indices: index_classes, **HashUtils.deep_transform_keys(options.to_h, &:to_sym)).run
|
87
|
+
end
|
80
88
|
end
|
81
89
|
end
|
82
90
|
end
|
@@ -26,15 +26,15 @@ class <%= @index_name %> < <%= @base_class %>
|
|
26
26
|
|
27
27
|
yield(rows, **params)
|
28
28
|
end
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
+
protected
|
31
32
|
|
32
|
-
|
33
|
+
attr_reader :params
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
35
|
+
# @param offset [Number] Offset to start from
|
36
|
+
def find_all(offset)
|
37
|
+
# @TODO load data from persistent store
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -6,6 +6,17 @@ module Esse
|
|
6
6
|
module HashUtils
|
7
7
|
module_function
|
8
8
|
|
9
|
+
def deep_transform_keys(hash, &block)
|
10
|
+
hash.each_with_object({}) do |(key, value), result|
|
11
|
+
result[yield(key)] = \
|
12
|
+
if value.is_a?(Hash)
|
13
|
+
deep_transform_keys(value, &block)
|
14
|
+
else
|
15
|
+
value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
9
20
|
def deep_merge(target, source)
|
10
21
|
target.merge(source) do |key, oldval, newval|
|
11
22
|
if oldval.is_a?(Hash) && newval.is_a?(Hash)
|
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.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcos G. Zimmermann
|
8
8
|
autorequire:
|
9
9
|
bindir: exec
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch
|
@@ -246,6 +246,7 @@ files:
|
|
246
246
|
- lib/esse/cli/index/close.rb
|
247
247
|
- lib/esse/cli/index/create.rb
|
248
248
|
- lib/esse/cli/index/delete.rb
|
249
|
+
- lib/esse/cli/index/import.rb
|
249
250
|
- lib/esse/cli/index/open.rb
|
250
251
|
- lib/esse/cli/index/reset.rb
|
251
252
|
- lib/esse/cli/index/update_aliases.rb
|