Commit a6598a18cfac2412df108144a19dcdc64f6d3808
1 parent
82b3c9a5
Exists in
master
and in
21 other branches
Fixed import
Showing
1 changed file
with
10 additions
and
0 deletions
Show diff stats
lib/searchkick/index.rb
@@ -39,5 +39,15 @@ module Searchkick | @@ -39,5 +39,15 @@ module Searchkick | ||
39 | ) | 39 | ) |
40 | end | 40 | end |
41 | 41 | ||
42 | + def import(records) | ||
43 | + if records.any? | ||
44 | + Searchkick.client.bulk( | ||
45 | + index: name, | ||
46 | + type: records.first.document_type, | ||
47 | + body: records.map{|r| {index: {_id: r.id, data: r.as_indexed_json}} } | ||
48 | + ) | ||
49 | + end | ||
50 | + end | ||
51 | + | ||
42 | end | 52 | end |
43 | end | 53 | end |