algolia / scout-extended

Scout Extended: The Full Power of Algolia in Laravel
https://www.algolia.com/doc/framework-integration/laravel/getting-started/introduction-to-scout-extended/
MIT License
393 stars 85 forks source link

Refactored the DeleteJob to use 'deleteObjects' instead of 'deleteBy' #334

Closed simonworkhouse closed 4 months ago

simonworkhouse commented 5 months ago
Q A
Bug fix? yes
New feature? no
BC breaks? no
Related Issue Fix #311
Need Doc update yes

Describe your change

This change is to account for the fact that the 'deleteBy' method has been deprecated on the new NeuralSearch infrastructure.

We have been advised of this by the Algolia support team and they have stated that it's a requirement in order to use the new infrastructure.

This update should also address the issue outlined in https://github.com/algolia/scout-extended/issues/311

simonworkhouse commented 4 months ago

@DevinCodes No troubles, I have updated the tests to account for the updated DeleteJob behaviour.

simonworkhouse commented 4 months ago

@DevinCodes We were informed by the Algolia support team that the deleteBy operation had been deprecated, is that not the case? Or is that perhaps just for the new "NeuralSearch" infrastructure? To be honest, I wasn't able to find that documented anywhere but the support team were adamant that it is the case.

Yes, it's probably a good idea to have it set up as a configurable option regardless, but maybe I'll first triple check with the support team just to make sure that they aren't confused.

DevinCodes commented 4 months ago

It is deprecated only for the new infrastructure indeed: plans on the old infra should still have access to this operation 🙂

simonworkhouse commented 4 months ago

I have added a configuration option scout.algolia.use_deprecated_delete_by that controls whether or not to use the deprecated deleteBy method. Tests have also been updated to account for both methods of deletion.

A check for this has been added into the DeleteJob with a default fallback value of true so that it does not change existing behaviour.

...
if (config('scout.algolia.use_deprecated_delete_by', true)) {
...

I did also consider the possibility of implementing and dispatching a new Job class instead, but rejected that idea due to the potential for breaking backwards compatibility. It would have potentially caused issues if someone is either manually dispatching DeleteJobs or if they have extended that class.

DevinCodes commented 4 months ago

This is released and available in v3.0.1! Thank you again for your contribution!