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

Defer to model's way of limiting the model set #291

Closed srlbarron closed 2 years ago

srlbarron commented 2 years ago

This will allow optimization per model

Avoid indexing models you don't want to be indexed anymore.

When the indexing process hits shouldBeSearchable it is already iterating through a lot of "probably" unnecessary models.

Q A
Bug fix? no
New feature? yes
BC breaks? no
Related Issue
Need Doc update yes

Describe your change

When using aggregators, this implelents MakeAllSearchable independently of how each model is implementing it.

What problem is this fixing?

At the moment, this only looks for soft deletes in order to limit the set algolia needs to evaluate before indexing it. With this change, the aggregator will look for a per model implementation of MakeAllSearchableUsing in order for add extra rules to limit the set Algolia need to iterate to index.


class MyModel extends model;

use Searchable;

   public function makeAllSearchableUsing($query)
   {
        return $query->where('active', 1);
   }
srlbarron commented 2 years ago

Needs more work