Search code examples
ruby-on-railselasticsearchsearchkick

Rails Elastic Search reindex data after update_all


I am using Searchkick for interacting with elastic search api in my Rails app, and it's working fine almost for all the cases, but the problem I am facing is I am having status field in my Model, and through select all check box a User can change the status of all the records, so I am updating my data using update_all which doesn't fire any callback, and searchkick reindex data through after_commit callback. and since, my data is not getting reindexed in Elastic Search this way it's giving same results, what I am suppose to do, is calling Model.reindex manually is a good option??


Solution

  • I actually solved it, without re indexing whole data which would have been a really naive solution, instead of that we can also re index a single record Like below

    product = Product.find 10
    product.reindex
    # or to reindex in the background
    product.reindex_async