zelastic 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/lib/zelastic/index_manager.rb +24 -9
- data/lib/zelastic/indexer.rb +2 -4
- data/lib/zelastic/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04e31f09152172933b5800dfd711a673e6d22c6c
|
4
|
+
data.tar.gz: d943d84ef9ee7770c4597b4853f75cfd83ec9ab1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c81a965e8b108be4ff1b4cacdee26fceb6a2164af583e93b06bd9d1919aa9bffb5d29a39220d01c26d0b41f6f0f60da6dffefa6e23b47d4a54edc748344b861e
|
7
|
+
data.tar.gz: f5ce82aac1b74cbac4526c36bdecf4694b39fc7ac2b1f234298fc635aa883e51f22552954963383b785f15558f27c2e1307d34359c2e5c620ecb34ea300a46ea
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -10,24 +10,23 @@ module Zelastic
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def create_index(unique_name)
|
13
|
-
|
13
|
+
index_name = index_name_from_unique(unique_name)
|
14
14
|
|
15
15
|
client.indices.create(
|
16
|
-
index:
|
16
|
+
index: index_name,
|
17
17
|
body: config.index_definition
|
18
18
|
)
|
19
19
|
|
20
|
-
client.indices.put_alias(index:
|
20
|
+
client.indices.put_alias(index: index_name, name: config.write_alias)
|
21
21
|
end
|
22
22
|
|
23
23
|
def populate_index(unique_name = nil, batch_size: 3000)
|
24
|
-
index_name =
|
25
|
-
[config.read_alias, unique_name].join('_')
|
26
|
-
else
|
27
|
-
config.write_alias
|
28
|
-
end
|
24
|
+
index_name = index_name_from_unique(unique_name)
|
29
25
|
|
30
|
-
config.data_source.find_in_batches(batch_size: batch_size) do |batch|
|
26
|
+
config.data_source.find_in_batches(batch_size: batch_size).with_index do |batch, i|
|
27
|
+
logger.info(
|
28
|
+
"ES: (ESTIMATED: #{indexed_percent(batch_size, i + 1)}%) Indexing #{config.type} records"
|
29
|
+
)
|
31
30
|
indexer.index_batch(batch, client: client, index_name: index_name)
|
32
31
|
end
|
33
32
|
end
|
@@ -106,5 +105,21 @@ module Zelastic
|
|
106
105
|
def indexer
|
107
106
|
@indexer ||= Indexer.new(config)
|
108
107
|
end
|
108
|
+
|
109
|
+
def index_name_from_unique(unique_name)
|
110
|
+
if unique_name
|
111
|
+
[config.read_alias, unique_name].join('_')
|
112
|
+
else
|
113
|
+
config.write_alias
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def current_index_size
|
118
|
+
@current_index_size ||= client.count(index: config.read_alias, type: config.type)['count']
|
119
|
+
end
|
120
|
+
|
121
|
+
def indexed_percent(batch_size, batch_number)
|
122
|
+
(batch_size * batch_number.to_f / current_index_size * 100).round(2)
|
123
|
+
end
|
109
124
|
end
|
110
125
|
end
|
data/lib/zelastic/indexer.rb
CHANGED
@@ -18,12 +18,10 @@ module Zelastic
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def index_batch(batch, client: nil, index_name: nil)
|
21
|
-
logger.info("ES: Indexing #{config.type} record")
|
22
|
-
|
23
21
|
version = current_version
|
24
|
-
execute_bulk(client: client, index_name: index_name) do |
|
22
|
+
execute_bulk(client: client, index_name: index_name) do |index|
|
25
23
|
batch.map do |record|
|
26
|
-
index_command(index:
|
24
|
+
index_command(index: index, version: version, record: record)
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
data/lib/zelastic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zelastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- carwow Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|