You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently the suggested way to perform the reindexing conditionally is
classProduct < ApplicationRecordsearchkickcallbacks: false# add the callbacks manuallyafter_commit:reindex,if: ->(model){model.previous_changes.key?("name")}# use your own conditionend
The problem is that this approach is likely about the copy/paste action from Searchkick internals into the host application. The client is forced to investigate the sources of Searchkick, understand in details how and why it uses after_commit callback, paste the same into own application, apply the customizations, and as it always happen with code duplication - keep tracking the upstream sources in order to catch & reflect the breaking changes.
For instance, the suggested conditional reindexing approach from above relies on :inline callbacks mode under the hood. If a client normally uses :async and just wants to skip reindexing sometimes - it have to do something like:
classProduct < ApplicationRecordsearchkickcallbacks: false# add the callbacks manuallyafter_commit(if: ->(model){model.previous_changes.key?("name")}{reindex(mode: :async)}end
And still some important parts or Searchkick functionality might be broken now (or will be broken later after Searchkick upgrade) - for instance the global callbacks mode. This way the full-weight suggestion turns into:
Is your feature request related to a problem? Please describe.
Currently the suggested way to perform the reindexing conditionally is
The problem is that this approach is likely about the copy/paste action from Searchkick internals into the host application. The client is forced to investigate the sources of Searchkick, understand in details how and why it uses
after_commit
callback, paste the same into own application, apply the customizations, and as it always happen with code duplication - keep tracking the upstream sources in order to catch & reflect the breaking changes.For instance, the suggested conditional reindexing approach from above relies on
:inline
callbacks mode under the hood. If a client normally uses:async
and just wants to skip reindexing sometimes - it have to do something like:And still some important parts or Searchkick functionality might be broken now (or will be broken later after Searchkick upgrade) - for instance the global callbacks mode. This way the full-weight suggestion turns into:
And still it does not fully respect the global callbacks mode such as
Searchkick.callbacks(:bulk) do; end
..Describe the solution you'd like
Let's introduce the possibility to define callbacks mode as lambda for the model as follows:
It will be evaluated within generic
after_commit
Searchkick callback.I'm ready to provide PR once the feature will be accepted in general by code owners )
The text was updated successfully, but these errors were encountered: