scout-extended icon indicating copy to clipboard operation
scout-extended copied to clipboard

$model->searchable() does not update aggregates

Open JayBizzle opened this issue 6 years ago • 4 comments

I'm not sure if this is just a limitation of this package, but when calling searchable() or unsearchable() directly on a Model, any aggregators that the Model is part of do not get updated.

Not sure if there is an easy fix for this, but for now we just do the following...

$user = User::find(16);

$user->searchable();

\App\Search\UserAggregate::create($user)->searchable();

JayBizzle avatar Mar 18 '19 10:03 JayBizzle

@JayBizzle Have you added this into your service provider?

\App\Search\UserAggregate::bootSearchable();

nunomaduro avatar Mar 18 '19 11:03 nunomaduro

Yes, we have done that 👍

JayBizzle avatar Mar 18 '19 11:03 JayBizzle

@JayBizzle Can you try investigate the bug please?

nunomaduro avatar Mar 20 '19 21:03 nunomaduro

Isn't the issue that the Aggregates register Model event listeners, and get fired when Models are saved and updated etc, but when calling $model->searchable() or $model->unsearchable() the Model doesn't actually change, so no events are fired, hence the Aggregate doesn't get updated?

JayBizzle avatar Mar 21 '19 07:03 JayBizzle