Commit 16ea97237770e4d1abd1c2a39aff93282ac1f388
1 parent
09b7c7bc
Exists in
master
and in
19 other branches
DRY code
Showing
2 changed files
with
5 additions
and
12 deletions
Show diff stats
lib/searchkick/record_indexer.rb
... | ... | @@ -56,7 +56,7 @@ module Searchkick |
56 | 56 | private |
57 | 57 | |
58 | 58 | def reindex_record(method_name) |
59 | - if record.destroyed? || !record.should_index? | |
59 | + if record.destroyed? || !record.persisted? || !record.should_index? | |
60 | 60 | begin |
61 | 61 | index.remove(record) |
62 | 62 | rescue Elasticsearch::Transport::Transport::Errors::NotFound | ... | ... |
lib/searchkick/reindex_v2_job.rb
... | ... | @@ -21,19 +21,12 @@ module Searchkick |
21 | 21 | nil |
22 | 22 | end |
23 | 23 | |
24 | - index = model.searchkick_index | |
25 | - if !record || !record.should_index? | |
26 | - # hacky | |
27 | - record ||= model.new | |
24 | + unless record | |
25 | + record = model.new | |
28 | 26 | record.id = id |
29 | - begin | |
30 | - index.remove record | |
31 | - rescue Elasticsearch::Transport::Transport::Errors::NotFound | |
32 | - # do nothing | |
33 | - end | |
34 | - else | |
35 | - index.store record | |
36 | 27 | end |
28 | + | |
29 | + RecordIndexer.new(record).reindex(mode: true) | |
37 | 30 | end |
38 | 31 | end |
39 | 32 | end | ... | ... |