ankane / searchkick

Intelligent search made easy
MIT License
6.49k stars 750 forks source link

Customize searchkick reindex queue per model #1634

Open beetlegius-jt opened 1 year ago

beetlegius-jt commented 1 year ago

First Search existing issues to see if it’s been discussed. ✅

Is your feature request related to a problem? Please describe. When there are multiple models that should be indexed, sometimes some of them are more critical than others. Having all the model reindexing jobs in the same generic queue (searchkick) makes them equals, when they're not. Sometimes we want to have some classes to get reindexed as soon as possible when others can have less priority.

Describe the solution you'd like Adding queue_name as a model option could be enough. The current implementation does support the queue_name option globally at the Searchkick class level only.

class Person
  searchkick queue_name: :low_priority
end

class Document
  searchkick queue_name: :critical
end

Additional context The workaround I found is by monkey patching the job:

class Searchkick::ReindexV2Job
  queue_as { "searchkick_#{arguments.first.tableize}" }
end

but would be ideal to replace this with something provided by the gem itself.

lawnchamp commented 1 year ago

I have also added this monkey patch. I agree this would be a nice feature to add