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

Add replica indices to the secured api search key #316

Open JanMisker opened 1 year ago

JanMisker commented 1 year ago

The api key generated via Algolia::searchKey is too restrictive, it only includes the primary index in its restrictIndices array. When using replicas for sorting with that key it fails, because the replicas are not included. This happens when sending the (secured) search key to a frontend javascript that only has one api key.

This change loads the replicas setting from the associated index config file and appends that to the restrictIndices.

There is probably a better way to load the config, I didn't dive that deep in the code. Perhaps it should be loaded from the remote index instead of via the local synced config file?