Commit e112b2a190dc78584aefd8bc6d8b3ce9a2d0dc2e

Authored by Andrew Kane
1 parent 873816e2

Improved code [skip ci]

Showing 1 changed file with 11 additions and 10 deletions   Show diff stats
lib/searchkick/index.rb
... ... @@ -211,16 +211,8 @@ module Searchkick
211 211  
212 212 def reindex(object, method_name: nil, full: false, **options)
213 213 if object.is_a?(Array)
214   - mode = options.delete(:mode)
215   - mode ||= Searchkick.callbacks_value || @options[:callbacks] || true
216   - mode = :inline if mode == :bulk
217   -
218   - refresh = options.delete(:refresh)
219   -
220   - # note: always want full to be false here
221   - result = RecordIndexer.new(self).reindex(object, mode: mode, method_name: method_name, full: false, **options)
222   - self.refresh if refresh
223   - return result
  214 + # note: purposefully skip full
  215 + return reindex_records(object, method_name: method_name, **options)
224 216 end
225 217  
226 218 if !object.respond_to?(:searchkick_klass)
... ... @@ -330,6 +322,15 @@ module Searchkick
330 322 index.import_scope(relation, **import_options)
331 323 end
332 324  
  325 + def reindex_records(object, mode: nil, refresh: false, **options)
  326 + mode ||= Searchkick.callbacks_value || @options[:callbacks] || true
  327 + mode = :inline if mode == :bulk
  328 +
  329 + result = RecordIndexer.new(self).reindex(object, mode: mode, full: false, **options)
  330 + self.refresh if refresh
  331 + result
  332 + end
  333 +
333 334 # https://gist.github.com/jarosan/3124884
334 335 # http://www.elasticsearch.org/blog/changing-mapping-with-zero-downtime/
335 336 # TODO deprecate async in favor of mode: :async, wait: true/false
... ...