blazpie
blazpie

Reputation: 312

How to use sidekiq and queue as searchkick `callbacks` option

I'm using searchkick to work with elasticsearch on RoR 4 app. Searchkick is great, and surprisingly easy to use but some of it's options are not well described. It's quite heavy traffic site so i'm trying to do most of the work asynchronously with sidekiq. I;m trying to put updating index after creating/updating record to work asynchronously as well but :queue option seems even more fitting my case, as it's doing a bulk updates of missing records.

So, docs are saying to set_up redis, and callbacks option on model, and:

Then, set up a background job to run.

Searchkick::ProcessQueueJob.perform_later(class_name: "Product")

where to put that code?

When I add some records they are invisible until I run that once, so should it by run in a schedule? as CRON task?

Upvotes: 0

Views: 1571

Answers (1)

justi
justi

Reputation: 4106

Yes, you should set up the cron job: create rake task and start executing it. The searchkick callback as queue uses Redis queue. Once the job starts, it takes all accumulated "Product" ids so far and index them. So if you want to your Product's index bring up to date you need to perform that job repeatedly.

Upvotes: 1

Related Questions