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
395 stars 85 forks source link

PhpStorm imports issue #251

Closed goddas closed 3 years ago

goddas commented 3 years ago

Please let me know what might be causing the following behavior. I'm on Laravel 8 (migrated from 7 ) if that makes a difference.

So I have pretty much a brand new laravel/scout and algolia/scout-extended install. The later gives me trouble. Scout without algolia/scout-extended works fine.

Issue: When I run scout:import or scout:reimport

1) The index gets created at algolia, but the index is run through toSearchableArray() function which I have deleted! So I've had this function to experiment with scout, but it seems like my indexing is now stuck in this function even though it is commented-out/deleted. If I change values in DB, they appear correctly in the index, run through the phantom toSearchableArray().

2) I get the following error trying to get results: Algolia\ScoutExtended\Exceptions\ShouldReimportSearchableException ObjectID seems invalid. You may need to re-import your data using thescout-reimportArtisan command.

Here is what I composer installed (in that order): laravel/scout algolia/algoliasearch-client-php algolia/scout-extended

I've tried: php artisan cache:clear php artisan route:clear php artisan config:cache composer dump-autoload

Currently, the only searchable model does not override any scout methods, it just has the Searchable trait. If I uninstall scout-extended, everything works right away without reindexing or anything like that.

Help is much appreciated.

goddas commented 3 years ago

The issue was due to PhpStorm. Resolves by restarting it, but happens consistently. Steps to reproduce: 1) php artisan scout:reimport with a toSearchableArray() on the model 2) modify the toSearchableArray() function 3) run php artisan scout:reimport again, the modifications are ignored. Never noticed this behaviour with PhpStorm, not sure if this is package related?

DevinCodes commented 3 years ago

Hey @goddas , thank you for reporting this issue. I've tried to reproduce the issue you're describing, but without any luck.

Given that the errors seems to be that modifications don't get taken into account, my best guess is that it's related to PhpStorm, and not to Scout Extended. Did you try reproducing this in another editor as well?

goddas commented 3 years ago

The problem was due to me not restarting the laravel queue worker, so it wasn't using the new changes.