Search code examples
ruby-on-railsrubyelasticsearchsearchkick

Does searchkick automatically update the index after model has been created?


When I include searchkick in an AR model like so:

class Dog < ActiveRecord::Base
  searchkick # callbacks: :async
end

Is the index synced automatically when I create a new Dog model, or do I have to implement this is an after_commit callback? I found the docs to be somewhat ambiguous on that point and I have not been able to verify this behavior in my tests.


Solution

  • They should auto reindex. Unless you have something blocking them.

    By default, all records are indexed. To control which records are indexed, use the should_index? method together with the search_import scope.

    https://github.com/ankane/searchkick#indexing