shouldBeSearchable
is not called during processing of MakeSearchable
with SCOUT_QUEUE=true
#756
Labels
shouldBeSearchable
is not called during processing of MakeSearchable
with SCOUT_QUEUE=true
#756
Scout Version
10.2.4
Scout Driver
Algolia
Laravel Version
10.19.0
PHP Version
8.1.21
Database Driver & Version
No response
SDK Version
Other (ElasticSearch)
Meilisearch CLI Version
No response
Description
Hey.
Scout allows specifying
shouldBeSearchable
method that checks whether a given model should even indexed into search. WithSCOUT_QUEUE=false
it works as expected: ifshouldBeSearchable
returns true, then that same model instance is synchronously converted to array withtoSearchableArray
and sent to a search driver.With
SCOUT_QUEUE=true
it doesn't quite work as expected: ifshouldBeSearchable
initially returns true, then that model ID is sent to queue. A queue worker then pulls that item from the database andshouldBeSearchable
might now returnfalse
if said item changed in between dispatching the job and it actually being processed. This, in turn, may lead totoSearchableArray
throwing an error.It might be a good idea to also be checking
shouldBeSearchable
inside theMakeSearchable
job, after the models have been fetched from the database, to make sure that the job is still relevant.Steps To Reproduce
SCOUT_QUEUE=true
->searchable()
on a model that hasshouldBeSearchable()
returningtrue
shouldBeSearchable()
to be returningfalse
toSearchableArray()
was called even thoughshouldBeSearchable()
is now returning falseThe text was updated successfully, but these errors were encountered: