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
There's this method should_update, defined in haystack.indexes.SearchIndex and inherited by CelerySearchIndex. By default, should_update returns True always. Also, there is this method called update_object in SearchIndex. It updates the object only if should_update returns True.
However, should_update takes some arguments, instance being one. For some applications, the object should be updated only if certain fields have been changed. So overriding should_update means checking all the fields that have changed in model instance and then return True if those changed fields are among the ones we want to be updated.
Since enqueue method in signals.CelerySignalProcessor already checks if the should_update for this is True or not before enqueuing, perhaps a update_object method should be included in CelerySearchIndex that just updates the object without checking for should_update again.
This is needed beacuse when should_update is called for second time (in update_object), the instance is already saved and instance.changed_fields is [].
The text was updated successfully, but these errors were encountered:
micahscopes
added a commit
to micahscopes/celery-haystack
that referenced
this issue
Jun 25, 2019
There's this method
should_update
, defined inhaystack.indexes.SearchIndex
and inherited byCelerySearchIndex
. By default,should_update
returns True always. Also, there is this method calledupdate_object
inSearchIndex
. It updates the object only ifshould_update
returns True.However,
should_update
takes some arguments,instance
being one. For some applications, the object should be updated only if certain fields have been changed. So overridingshould_update
means checking all the fields that have changed in model instance and then return True if those changed fields are among the ones we want to be updated.Since
enqueue
method insignals.CelerySignalProcessor
already checks if theshould_update
for this is True or not before enqueuing, perhaps aupdate_object
method should be included inCelerySearchIndex
that just updates the object without checking forshould_update
again.This is needed beacuse when
should_update
is called for second time (inupdate_object
), the instance is already saved andinstance.changed_fields
is[]
.The text was updated successfully, but these errors were encountered: