common_indexer 0.3.4 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/common_indexer.rb +2 -2
- data/lib/common_indexer/base.rb +13 -6
- data/lib/common_indexer/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 931029ffbaed76ee103cb5bc8dd88dcd88fa1556494d2d3f562c2893fae77c38
|
4
|
+
data.tar.gz: 662a785dced385458c692e967d96a71c90aab3fdf9c21a09d6551dc014521f93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e042d390d0c68c4d3abc7d38569434be1740a9ceed64330d30e6a019cea5aeb718ad6cef3ec2e1bcdf6278a2e612dade48684c48329ca124a81d22c5c63913d9
|
7
|
+
data.tar.gz: e75f6390d3b751dd0f60e655d1218845454d3b87935c9bfc126f3db25f15b46ff9e32eb3b98417000f455aef3e9ced42fce81cfe292ee6c9063834bb338128cc
|
data/lib/common_indexer.rb
CHANGED
@@ -41,8 +41,8 @@ module CommonIndexer # :nodoc:
|
|
41
41
|
|
42
42
|
def reindex_into(new_index)
|
43
43
|
existing_index = client.indices.get(index: index_name).keys.first
|
44
|
-
raise ArgumentError, "Cannot reindex #{index_name} into itself" if existing_index ==
|
45
|
-
client.reindex(body: { source: { index:
|
44
|
+
raise ArgumentError, "Cannot reindex #{index_name} into itself" if existing_index == new_index
|
45
|
+
client.reindex(body: { source: { index: existing_index }, dest: { index: new_index } })
|
46
46
|
client.indices.delete(index: existing_index)
|
47
47
|
end
|
48
48
|
end
|
data/lib/common_indexer/base.rb
CHANGED
@@ -4,8 +4,11 @@ require 'active_support/concern'
|
|
4
4
|
module CommonIndexer # :nodoc:
|
5
5
|
module Base
|
6
6
|
extend ActiveSupport::Concern
|
7
|
-
|
7
|
+
|
8
8
|
included do
|
9
|
+
extend ActiveModel::Callbacks
|
10
|
+
define_model_callbacks :delete_common_index, :update_common_index
|
11
|
+
|
9
12
|
after_save :update_common_index
|
10
13
|
after_destroy :delete_document
|
11
14
|
end
|
@@ -16,18 +19,22 @@ module CommonIndexer # :nodoc:
|
|
16
19
|
end
|
17
20
|
|
18
21
|
def delete_document
|
19
|
-
|
22
|
+
_run_delete_common_index_callbacks do
|
23
|
+
CommonIndexer.client.delete index: CommonIndexer.index_name,
|
20
24
|
id: id,
|
21
25
|
type: '_doc'
|
26
|
+
end
|
22
27
|
rescue Elasticsearch::Transport::Transport::Error => err
|
23
28
|
Rails.logger.warn("Common Index delete failure: #{err.message}")
|
24
29
|
end
|
25
30
|
|
26
31
|
def update_common_index
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
_run_update_common_index_callbacks do
|
33
|
+
CommonIndexer.client.index index: CommonIndexer.index_name,
|
34
|
+
id: id,
|
35
|
+
type: '_doc',
|
36
|
+
body: to_common_index
|
37
|
+
end
|
31
38
|
rescue Elasticsearch::Transport::Transport::Error => err
|
32
39
|
Rails.logger.warn("Common Indexing failure: #{err.message}")
|
33
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: common_indexer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Klein
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-08-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: active-fedora
|
@@ -207,8 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
209
|
requirements: []
|
210
|
-
|
211
|
-
rubygems_version: 2.6.8
|
210
|
+
rubygems_version: 3.0.1
|
212
211
|
signing_key:
|
213
212
|
specification_version: 4
|
214
213
|
summary: Common Indexing mixin for NUL Digital Collections
|